// Flash default variables
var flashMin = 5;
var ShockMode = false;

// Sniff Netscape's arrays for Flash
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
 if (navigator.plugins && navigator.plugins["Shockwave Flash"])
   ShockMode = 1;
}

// Use VBScript to sniff for IE Flash
if (navigator.userAgent.indexOf("Mac")==-1)
{
 document.write('<SCRIPT LANGUAGE="VBScript"> \n');
 document.write('on error resume next \n');
 document.write('ShockMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")) \n');
 var aTempVar="</S";
 aTempVar+="CRIPT> \n";
 document.write(aTempVar);
}

var flash2Detected,flash3Detected,flash4Detected,flash5Detected,flash6Detected,fv,pgloc

function detectFlash(){
  var maxVersion=6;
	var actualVersion=0;

    var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;		// true if we're on ie
    var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

    if(isIE && isWin){ // don't write vbscript tags on anything but ie win
	  with(document){
	    write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	    write('on error resume next \n');
	    write('flash2Detected = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	    write('flash3Detected = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	    write('flash4Detected = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	    write('flash5Detected = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	    write('flash6Detected = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	    write('</SCR' + 'IPT\> \n');} // break up end tag so it doesn't end our script
    }

	if (navigator.plugins){								// navigator.plugins exist?
		if (navigator.plugins["Shockwave Flash 2.0"] 	// is it Flash 2?
		|| navigator.plugins["Shockwave Flash"]){		// is it Flash 3?

			// set convenient references to flash 2+ plugin description
			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));

			// set appropriate version flags
			 flash2Detected = flashVersion == 2;
			 flash3Detected = flashVersion == 3;
			 flash4Detected = flashVersion == 4;
			 flash5Detected = flashVersion == 5;
			 flash6Detected = flashVersion == 6;
		}
	}

	// loop and set actualVersion to highest detected version
	for (var i = 2; i <= maxVersion; i++) {
		if (eval("flash" + i + "Detected") == true) actualVersion = i;
	}
	return(actualVersion);
}

var FlashVersion = detectFlash();

if(FlashVersion >= flashMin){
  ShockMode = true;
}else{
  ShockMode = false;
}

//ShockMode Switch
if(location.search.indexOf("SM=off") > 0 ) ShockMode = false;
if(location.search.indexOf("SM=on") > 0 ) ShockMode = true;


function flashCtrl(base){
	var filename = base;
	if(!ns3){ filename += '_ctrl';}
	filename += '.swf';
	alert(filename);
	return filename;
}

function wflash(filename,wide,high,color,altHtml,moviename, doPlay){
  var flsh = '';
  if(moviename == null)moviename = 'movie';
  if ( ShockMode && doPlay ) {
    flsh += '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
    flsh += ' codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#navVersion=3,0,0,0"';
    flsh += ' ID='+moviename+' WIDTH="' + wide + '" HEIGHT="' + high + '">';
    flsh += '<PARAM NAME=movie VALUE="' + filename+ '">';
    flsh += '<PARAM NAME=quality VALUE=high>';
    flsh += '<PARAM NAME=menu VALUE=true>';
    flsh += '<param name=wmode value=transparent>';
    flsh += '<PARAM NAME=bgcolor VALUE=' + color + '>';
    flsh += '<EMBED src="' + filename + '" ';
	 flsh += 'quality=high ';
	 flsh += 'bgcolor=' + color + ' ';
	 flsh += 'menu=true ';
	 flsh += 'wmode=transparent ';
	 flsh += 'WIDTH="' + wide + '" ';
	 flsh += 'HEIGHT="' + high + '" ';
	 flsh += 'NAME='+moviename+' ';
	 flsh += 'swLiveConnect=true ';
	 flsh += 'TYPE="application/x-shockwave-flash" ';
	 flsh += 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
    flsh += '</EMBED><NOEMBED>' + altHtml + '</NOEMBED></OBJECT>';
  } else {flsh += altHtml;}
  document.write(flsh);
}
