

/********************************************/
/************ FLASH DETECTION **************/
/* Copyright 2004 Boede & Partners, Inc. */
/******************************************/

// Initialize Flash detection variables
function InitFlash(maxFlash)
{
	actualVersion = 0;	// version the user really has
	for(x = 2;x <= maxFlash;x++)
	{
		eval("flash" +x+ "Installed = false;");
		eval("foo"+x+"=false;");
	}
}

// Detect Flash object
function DetectFlash(maxFlash, requiredFlash) {
	var rightVersion = false
	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
	
	//Check Plugin Version for IE on Windows
	if(isIE && isWin){
	  document.write('<scr' + 'ipt type="text/vbscript"\> \n');
	  document.write('On Error Resume Next \n');
	  
	  for(x = 2; x <= maxFlash; x++)
	  {
		 	document.write('flash' +x+ 'Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' +x+ '"))) \n')
	  }
	  document.write('</scr' + 'ipt\> \n');
	}
	
	//Check Plugin Version all other Platfoms
	if (navigator.plugins) {
	  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));
	    
	    for(x = 2;x <= maxFlash; x++)
	    {
	    	if(x != maxFlash)
	    	{
	    		eval("flash" +x+ "Installed = flashVersion == " +x+ ";");
	    	}
	    	else
	    	{
	    		eval("flash" +x+ "Installed = flashVersion >= " +x+ ";");
	    	}
	    }
	  }
	}
	//Grab the Actual Version detected
	for (var i = 2; i <= maxVersion; i++) { if (eval("flash" + i + "Installed") == true) actualVersion = i }
	// Match Detected Version against Rquired Version
	actualVersion >= requiredFlash ? rightVersion = true : rightVersion = false;
	//Hand back boolean value
	return (rightVersion);
}


// Embed Flash Object
function BuildFlash (width,height,url,wmode,vars){
	var html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'
	    + 'width="' +width+ '" height="' +height+ '"\n'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">\n'
	    + '<param name="movie" value="' +url+ '" />\n'
	    + '<param name="play" value="true" />\n'
	    + '<param name="loop" value="false" />\n'
	    + '<param name="quality" value="high" />\n'
	    + '<param name="menu" value="false" />\n'
	    + '<param name="wmode" value="' +wmode+ '" />'
	    + '<param name="flashvars" value="' +vars+ '" />\n'
	    + '<embed src="' +url+ '" \n'
	    + 'width="' +width+'" height="' +height+ '" \n'
	    + 'play="true" \n'
	    + 'loop="false" \n'
	    + 'quality="high" \n'
	    + 'menu="false" \n'
	    + 'wmode="' +wmode+ '" \n'
	    +	'flashvars="' +vars+ '" \n'
	    + 'type="application/x-shockwave-flash" \n'
	    + 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> \n'
	    + '</embed> \n'
	    + '</object>\n';
    return (html);
}

// display flash object
function DisplayFlash(redirect,detect)
{
 	if(detect && DetectFlash(maxVersion, requiredVersion))
	{
	  document.write(BuildFlash(width, height, url, wmode, flashVars));
	}
	else
	{
		// Redirect or not for non-Flash display. Boolean
		redirect ? document.location.replace(noFlash) : document.write(noFlash);
	}
}
