var detectedVersion = -1;
function getFlashVersion (baseVersion) {
	if (detectedVersion != -1) return detectedVersion;
	if (baseVersion == null) baseVersion = 10;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var pluginRef = navigator.plugins['Shockwave Flash'];
		if (pluginRef != null) {
			var verIndex = pluginRef.description.indexOf (".");
			detectedVersion = parseInt (pluginRef.description.substr (verIndex - 1, 1));
		}
	}
	else if (navigator.userAgent.indexOf("MSIE") != -1 && parseInt(navigator.appVersion) >= 4 && navigator.platform == "Win32") {
		document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		for (var i = baseVersion; i > 0; i --) {
			document.write('pTest = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + i + '")) \nif (pTest and detectedVersion = -1) then detectedVersion =' + i + '\n');
		}		
		document.write('</scr' + 'ipt\> \n');
	}
	return detectedVersion;
}
function flashEmbed (movieName, failOverImage, failOverURL, width, height, baseVersion) {
	var version = getFlashVersion (baseVersion);
	if ((version != -1) && (version >= baseVersion)) {
		writeFlashTag (movieName, width, height, baseVersion);
	}
	else {
		document.write ('<a href = "' + failOverURL + '"><img src = "' + failOverImage + '" width="' + width + '" height="' + height + '" border = "0"></a>');
	}
}
function writeFlashTag (movieName, width, height, baseVersion) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + baseVersion + ',0,0,0" width="' + width + '" height="' + height + '">\n<param name="movie" value="' + movieName + '">\n<param name=quality value=high>\n');
	document.write ('<embed src="' + movieName + '" TYPE="application/x-shockwave-flash" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width=' + width + ' height=' + height + '></embed>\n</object>');		
}
getFlashVersion ();
