// do detect; system globals
var flash2Installed = false;		// boolean. true if flash 2 is installed
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 5 is installed
		
var shockwave7Installed = false;	// boolean; true if shockwave 7 is installed
var shockwave8Installed = false;	// boolean; true if shockwave 8 is installed
var shockwave85Installed = false;	// boolean; true if shockwave 8 is installed
		
var maxFlashVersion = 6;		// highest version we can actually detect
var actualFlashVersion = 0;		// version the user really has
var actualShockwaveVersion = 0;	// version the user really has

// write vbscript detection if we're on ie win
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;	// true if we're on ie
var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false; // true if we're on mac

// *************
// Flash/Shockwave Detection
// *************

	if ( (readCookie('detected')=='') || (readCookie ('flashActualVersion')=='') || (readCookie ('shockwaveActualVersion')==''))
		doFullDetect();
	else
	{
		actualFlashVersion = readCookie ("flashActualVersion");
		actualShockwaveVersion = readCookie ("shockwaveActualVersion");
		isIE = readCookie ("isIE");
		isMac = readCookie ("isMac");
	}

	function doFullDetect()
	{
		doIEDetect();
		doNetscapeDetect(true);
		doProcessing();
	}

	function doIEDetect()
	{
		// don't write vbscript tags on anything but ie win
		if (isIE && !isMac) 
		{
			document.write('<SCRIPT LANGUAGE=VBScript\> \n');
			document.write('on error resume next \n');
			document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \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('shockwave7Installed = (IsObject(CreateObject("Macromedia.ActiveShockwave.7"))) \n');	
			document.write('shockwave8Installed = (IsObject(CreateObject("Macromedia.ActiveShockwave.8"))) \n');	
			document.write('shockwave85Installed = (IsObject(CreateObject("Macromedia.ActiveShockwave.8.5"))) \n');	

			document.write('if not shockwave7Installed then shockwave7Installed = (IsObject(CreateObject("SWCtl.SWCtl.7"))) \n');	
			document.write('if not shockwave8Installed then shockwave8Installed = (IsObject(CreateObject("SWCtl.SWCtl.8"))) \n');	
			document.write('if not shockwave85Installed then shockwave85Installed = (IsObject(CreateObject("SWCtl.SWCtl.8.5"))) \n');	
		
			document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
		}
	}

	function doNetscapeDetect(bDontWriteCookies)
	{
		if ((navigator.plugins) && (readCookie('detected')==''))				// does navigator.plugins exist?		
		{ 								
			if (navigator.plugins["Shockwave Flash"])	// is flash 3+ installed?
			{
				var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; 					// flash 2 ref.
				var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;		// plugin description
				var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));	// plugin version
		
				if (flashVersion == 2) flash2Installed = true;	// set appropriate version flag
				if (flashVersion == 3) flash3Installed = true;
				if (flashVersion == 4) flash4Installed = true;
				if (flashVersion == 5) flash5Installed = true;
				if (flashVersion == 6) flash6Installed = true;
			}
		
			if (navigator.plugins["Shockwave for Director"]) 	// is Shockwave 7+ installed?
			{
				var isVersion7 = navigator.plugins["Shockwave for Director 7.0"] ? " 7.0" : ""; 			// shockwave 7 ref.
				var shockwaveDescription = navigator.plugins["Shockwave for Director" + isVersion7].description;	// plugin description
				var shockwaveVersion = parseInt(shockwaveDescription.charAt(shockwaveDescription.indexOf(".") - 1));	// plugin version
				var shockwaveVersionExt = parseInt(shockwaveDescription.charAt(shockwaveDescription.indexOf(".") + 1));// plugin version

				if (shockwaveVersion == 7) shockwave7Installed = true;	// set appropriate version flag
				if (shockwaveVersion == 8) shockwave8Installed = true;
				if ((shockwaveVersion == 8) && (shockwaveVersionExt == 5)) shockwave85Installed = true;
			}
		
			if (bDontWriteCookies==null)
			{
				doProcessing();
			}

		}
	}

	function doProcessing()
	{
		//flash
		var bInstalled = false;
		for (var i = 2; i <= maxFlashVersion; i++)	// loop through all versions we're checking
		{
			bInstalled = eval("flash" + i + "Installed");
			if (bInstalled == true)
				actualFlashVersion = i; // set actualVersion to highest detected version
		}
		
		//shockwave
		if (shockwave85Installed)
			actualShockwaveVersion = 8.5;
		else if (shockwave8Installed)
			actualShockwaveVersion = 8;
			
		//write cookies	
		writeCookie ("flashActualVersion", actualFlashVersion);
		writeCookie ("shockwaveActualVersion", actualShockwaveVersion);
		writeCookie ("isIE", isIE);
		writeCookie ("isMac", isMac);
		writeCookie ("detected", "true");
	}

	//alert ('Shockwave version: ' + actualShockwaveVersion);

// *************
// END Flash/Shockwave Detection
// *************

// **********
// Cookie functions
// **********
	function writeCookie (cookieName, cookieValue, expiry) 
	{
		var expDate = new Date();
		if (expiry)
		{
			expDate.setTime (expDate.getTime() + expiry);
			document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString();
		}
		else
		{
			if (cookieValue==true)
				document.cookie = cookieName + "=" + 'true';
			else if (cookieValue==false)
				document.cookie = cookieName + "=" + 'false';
			else
				document.cookie = cookieName + "=" + escape (cookieValue);
		}
	}
	
	function readCookie(CookieName) 
	{
		var CookieString = document.cookie;
		var CookieSet = CookieString.split (';');
		var SetSize = CookieSet.length;
		var CookiePieces
		var ReturnValue = "";
		var x = 0;
	
		for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
		{
			CookiePieces = CookieSet[x].split ('=');
		
			if (CookiePieces[0].substring (0,1) == ' ')
				CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
		
			if (CookiePieces[0] == CookieName)
				ReturnValue = CookiePieces[1];
		}
	
		return ReturnValue;
	}
	
// **********
// END Cookie functions
// **********

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}