var flash2Installed = false;		
var flash3Installed = false;		
var flash4Installed = false;		
var flash5Installed = false;		
var maxVersion = 5;					// highest version we can actually detect
var requiredVersion = 4;			// version of flash the user needsvar actualVersion = 0;				// version the user really has
var hasRightVersion = false;		// boolean. true if users got the right version

// vbscript detection if we're not on mac.
if(is_ie && is_win){ // don't write vbscript tags on anything but ie win
	document.write('<SCR' + 'IPT 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('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function detectFlash(){	

	if (navigator.plugins){								// does navigator.plugins exist?
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]){
			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));

			flash2Installed = flashVersion == 2;		
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
		}
	}
	
	// loop through all versions we're checking, and set actualVersion to highest detected version
	for (var i = 2; i <= maxVersion; i++) {	
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	
	if (actualVersion >= requiredVersion) { 		// user has a new enough version
		hasRightVersion = true;						// flag: we've got the right versions
	}	else {		// for non flash supporting browsers, the code below shows image slide show in place of flash
		// Preload images here
		img1 = new Image(); img1.src = "/grfx/array_img/img03.jpg";
		//img2 = new Image(); img2.src = "/grfx/array_img/img03.jpg";
		//img3 = new Image(); img3.src = "/grfx/array_img/img03.jpg";
		//img4 = new Image(); img4.src = "/grfx/array_img/img03.jpg";
		//img5 = new Image(); img5.src = "/grfx/array_img/img03.jpg";
		src = [img1.src] //, img2.src, img3.src, img4.src, img5.src]	}
}

detectFlash();	// call our flash detector function now that it's safely loaded.	


//determines how long each image is shown
duration = 2;

imgs=[]; ct=0;
function switchImg() {
	var n=(ct+1)%src.length;
	if (imgs[n] && (imgs[n].complete || imgs[n].complete==null)) {
		document["slide_image"].src = imgs[ct=n].src;
	}
	imgs[n=(ct+1)%src.length] = new Image;
	imgs[n].src = src[n];
	setTimeout("switchImg()",duration*1000);
}

onload = function(){
if(!hasRightVersion){
	if (document.images)
		switchImg();
	}
}

function WriteFlash(strFlashFile, strAltFile, strAltText, width, height, MapName)
{
	if(hasRightVersion) {	// if we've detected an acceptable version show flash
			var oeTags = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
				+ 'width="' + width + '" height="' + height +'"'
				+ '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" id=OBJECT1>'
				+ '<PARAM NAME="MOVIE" VALUE="' + strFlashFile + '">'
				+ '<PARAM NAME="QUALITY" VALUE="high">'
				+ '<EMBED SRC="' + strFlashFile + '"'
				+ 'width="' + width + '" height="' + height +'"'
				+ 'QUALITY="high"'
				+ 'TYPE="application/x-shockwave-flash"'
				+ 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
				+ '</EMBED>'
				+ '</OBJECT>';
							
		document.write(oeTags);

	} 
	else 
	{		
		// show non-flash content
		if (MapName != "")
		{
			document.write('\t<IMG SRC="' + strAltFile +'" alt="' + strAltText + '" usemap="#' + MapName + '" border="0">');
			//alert('\t<IMG SRC="' + strAltFile +'" alt="' + strAltText + '" usemap="#' + MapName + '" border="0">')
			//document.write('\t<IMG SRC="' + strAltFile +'" alt="' + strAltText + '" border="0">');
		}
		else
		{
			document.write('\t<IMG SRC="' + strAltFile +'" alt="' + strAltText + '" border="0">');
		}
	}
}

