// Flash detection script for versions 2 -> 5
var flash_version = 0;
var flash_2Installed = false;
var flash_3Installed = false;
var flash_4Installed = false;
var flash_5Installed = false;
var flash_maxVersion = 5;

function flash_detect(){
	// detection for Windows IE
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	if(isIE && isWin) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('flash_2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
		document.write('flash_3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.write('flash_4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.write('flash_5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
		document.write('</SCR' + 'IPT\> \n');
	}

	// detection for Netscape
	if(navigator.plugins) {
		if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			// set convenient references to flash 2 and the plugin description
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			// a flash plugin-description looks like this: Shockwave Flash 4.0 r5
			// so we can get the major version by grabbing the character before the period
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

			// we know the version, now set appropriate version flags
			flash_2Installed = (flashVersion == 2);
			flash_3Installed = (flashVersion == 3);
			flash_4Installed = (flashVersion == 4);
			flash_5Installed = (flashVersion == 5);
		}
	}

	// loop through all versions we're checking, and set actualVersion to highest detected version
	for(var i = 2; i <= flash_maxVersion; i++) {
		if(eval("flash_" + i + "Installed") == true) flash_version = i;
	}

	//alert("version detected: " + flash_version);
}
flash_detect();

// Flash insertion function
function flash_insert(file_name, name, height, width, loop, bgcolor, live_connect) {
	var strTags = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ ' WIDTH="'+width+'" HEIGHT="'+height+'"'
		+ ' ID="'+name+'" swLiveConnect="'+live_connect+'"'
		+ ' CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0">'
		+ '<PARAM NAME="MOVIE" VALUE="'+file_name+'">'
		+ '<PARAM NAME="PLAY" VALUE="true">'
		+ '<PARAM NAME="LOOP" VALUE="'+loop+'">'
		+ '<PARAM NAME="QUALITY" VALUE="high">'
		+ '<PARAM NAME="MENU" VALUE="false">'
		+ '<PARAM NAME="BGCOLOR" VALUE="'+bgcolor+'">'
		+ '<EMBED SRC="'+file_name+'"'
		+ ' WIDTH="'+width+'" HEIGHT="'+height+'"'
		+ ' NAME="'+name+'"'
		+ ' swLiveConnect='+live_connect+''
		+ ' PLAY="true"'
		+ ' LOOP="'+loop+'"'
		+ ' QUALITY="high"'
		+ ' MENU="false"'
		+ ' BGCOLOR="'+bgcolor+'"'
		+ ' TYPE="application/x-shockwave-flash"'
		+ ' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
		+ '</EMBED>'
		+ '</OBJECT>';
	document.write(strTags);
}

// Flash object definition function
function flash_define(movie_name) {
	if(navigator.appName.indexOf("Microsoft") != -1)
		movie = eval("window.document." + movie_name);
	else
		movie = eval("window.document.embeds." + movie_name);
	return movie;
}