/////////////////////  DETECT FLASH PLAYER IN BROWSER  ///////////////////////
var detectableWithVB
var pluginFound = false;

function getCookie(NameOfCookie)
{

	// First we check to see if there is a cookie stored.
	// Otherwise the length of document.cookie would be zero.
	
	if (document.cookie.length > 0)
	{
	
	// Second we check to see if the cookie's name is stored in the
	// "document.cookie" object for the page.
	
	// Since more than one cookie can be set on a
	// single page it is possible that our cookie
	// is not present, even though the "document.cookie" object
	// is not just an empty text.
	// If our cookie name is not present the value -1 is stored
	// in the variable called "begin".
	
	begin = document.cookie.indexOf(NameOfCookie+"=");
	if (begin != -1) // Note: != means "is not equal to"
	{
	
	// Our cookie was set.
	// The value stored in the cookie is returned from the function.
	
	begin += NameOfCookie.length+1;
	end = document.cookie.indexOf(";", begin);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(begin, end)); }
	}
	return null;
	
	// Our cookie was not set.
	// The value "null" is returned from the function.

}


function setCookie(NameOfCookie, value, expiredays)
{

	// Three variables are used to set the new cookie.
	// The name of the cookie, the value to be stored,
	// and finally the number of days until the cookie expires.
	// The first lines in the function convert
	// the number of days to a valid date.
	
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	
	// The next line stores the cookie, simply by assigning
	// the values to the "document.cookie" object.
	// Note the date is converted to Greenwich Mean time using
	// the "toGMTstring()" function.
	
	document.cookie = NameOfCookie + "=" + escape(value) +
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}


function delCookie (NameOfCookie)
{

	// The function simply checks to see if the cookie is set.
	// If so, the expiration date is set to Jan. 1st 1970.
	
	if (getCookie(NameOfCookie)) {
	document.cookie = NameOfCookie + "=" +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

canDetectPlugins()

if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<scr'+'ipt language="VBscript">');
    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');
    document.writeln('</scr' + 'ipt>');
}



function detectPlugin() {
// allow for multiple checks in a single pass
var daPlugins = detectPlugin.arguments;
// consider pluginFound to be false until proven true
pluginFound = false;
   // if plugins array is there and not fake
   if (navigator.plugins && navigator.plugins.length > 0) {
   var pluginsArrayLength = navigator.plugins.length;
   // for each plugin...
      for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
        // loop through all desired names and check each against the current plugin name
        var numFound = 0;
         for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
	     // if desired plugin name is found in either plugin name or description
	     if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
	       // this name was found
	       numFound++;
	     }   
	  }
         // now that we have checked all the required names against this one plugin,
         // if the number we found matches the total number provided then we were successful
         if(numFound == daPlugins.length) {
	    pluginFound = true;
	    // if we've found the plugin, we can stop looking through at the rest of the plugins
	    break;
	  }
      }
   }
    return pluginFound;
} // detectPlugin

function detectFlash() {
    pluginFound = detectPlugin('Shockwave','Flash'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
 }

/////////////////////////////  END DETECT FLASH PLAYER IN BROWSER  ///////////////////////////


/////////////////////////////  START LOGIC  ////////////////////////////////////

// Flash player detected?? ( returns pluginFound true or false )
detectFlash()

var playFlash

// If there is a preference cookie set, or if the user has not yet selected a preference, play flash
if(getCookie('flashOn') == "true"){
	playFlash = "true"
}
else
if(getCookie('flashOn') == null){
	playFlash = "true"
}
else
{
	playFlash = "false"
}

// User desires to view Flash??
function flashOnOff(toggle){
	if(toggle == "on"){
		//alert("Turning Flash ON...")
		setCookie('flashOn','true',360)
		playFlash = "true"
		history.go(0)
	}
	if(toggle == "off"){
		//alert("Turning Flash OFF...")
		setCookie('flashOn','false',360)
		playFlash = "false"
		history.go(0)
	}
}

////////////////////////////////////  END LOGIC  ///////////////////////////////////////////