var detect_flashDate="072008";
// Sets the value of useFlash to true or false
var useFlash = false;
if (typeof(requiredVersion) == typeof(notDefined)) requiredVersion=5;
testNoFlash=false; // used to turn off flaslh for testing

var flash3Installed = false;		// boolean. true if flash 3 is installed
var flash4Installed = false;		// boolean. true if flash 4 is installed
var flash5Installed = false;		// boolean. true if flash 5 is installed
var flash6Installed = false;		// boolean. true if flash 6 is installed
var flash7Installed = false;		// boolean. true if flash 7 is installed
var flash8Installed = false;		// boolean. true if flash 8 is installed
var flash9Installed = false;		// boolean. true if flash 9 is installed
var flash10Installed = false;		// boolean. true if flash 10 is installed

var maxVersion = 10;					// highest version we can actually detect
var actualVersion = 0;
// check the browser...we're looking for ie/win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

// write vbscript detection if we're not on mac.
if(isIE && isWin){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
	document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
	document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \n');
	document.write('</SCR' + 'IPT\> \n');
}

function detectFlash(argRequiredVersion)
{
	if (typeof(argRequiredVersion) == "undefined")
		argRequiredVersion = (typeof(requiredVersion) == "undefined") ? 5 : requiredVersion;
	if (navigator.plugins)			// does navigator.plugins exist? IE 5.0 only
	{
		if (navigator.plugins["Shockwave Flash 2.0"]	 // yes>> then is Flash 2
		|| navigator.plugins["Shockwave Flash"])		// or flash 3+ installed?
		{
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
			flash8Installed = flashVersion == 8;
			flash9Installed = flashVersion == 9;
			flash10Installed = flashVersion == 10;
		}
	}

	for (var i = 3; i <= maxVersion; i++) {
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	// if we're on webtv, the version supported is 2 (pre-summer2000, or 3, post-summer2000)
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;

	// uncomment next line to display flash version during testing
	// alert("version detected: " + actualVersion);

// test for different versions of flash
	//actualVersion=5;
// *************************************

	useFlash = false;
	if (actualVersion >= parseInt(argRequiredVersion)) useFlash = true;

	// check for ActiveX being enabled
	ThisPage=new MlPage();
	if (ThisPage.isIE)
	{
		var activeXenabled=ThisPage.hasActiveX();
		if (!activeXenabled) useFlash = false;
	}
	if (testNoFlash) useFlash = false;
// Uncomment the next line to test for not having flash.
//	useFlash = false;

	return useFlash;
}

function insertFlash(name,width,height,bgcolor,quality)
{
	var imageCode = "";
	if (useFlash == true)
	{
		if (typeof(name) == "undefined")
		{
			if (typeof(fName) != "undefined")
				name = fName;
			else
				alert("name must be provided to insertFlash()");
		}
		if (typeof(width) == "undefined")
		{
			if (typeof(fWidth) != "undefined")
				width = fWidth;
			else
				alert("width must be provided to insertFlash()");
		}
		if (typeof(height) == "undefined")
		{
			if (typeof(fHeight) != "undefined")
				height = fHeight;
			else
				alert("height must be provided to insertFlash()");
		}
		if (typeof(bgcolor) == "undefined")
			bgcolor = (typeof(fBgcolor) == "undefined") ? "#000000" : fBgcolor;

		if (typeof(quality) == "undefined")
			quality = (typeof(fQuality) == "undefined") ? "autolow" : fQuality;

		imageCode="<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"" +
			" WIDTH=\"" + width + "\" HEIGHT=\"" + height+"\"" +
			" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + requiredVersion + ",0,0,0\">" +
			"<PARAM NAME=\"MOVIE\" VALUE=\"" + rootDir + "/shared/images/" + name + ".swf\">" +
			"<PARAM NAME=\"QUALITY\" VALUE=\"" + quality + "\">" +
			"<PARAM NAME=\"bgcolor\" VALUE=" + bgcolor + ">" +
			"<EMBED SRC=\"" + rootDir + "/shared/images/" + name +".swf\" WIDTH=\"" + width + "\" HEIGHT=\"" + height +"\" QUALITY=\"" +quality +"\"" +
			" WMODE=\"transparent\" bgcolor=\"" + bgcolor + "\"" +
			" swLiveConnect=FALSE" +
			" TYPE=\"application/x-shockwave-flash\">" +
			"</EMBED></OBJECT>";
	}
	else
	{
		imageCode= "<IMG SRC=\"" + rootDir + "/shared/images/" + name + ".gif\"" +
			" WIDTH=" + width + " HEIGHT=" + height + " BORDER=0>";
	}
	document.write(imageCode);
}

detectFlash();// call our detector now that it's safely loaded.
