

var detectableWithVB = false;
var haveFlash = false;			// boolean. does the user have the flash at all?
var haveFlashVer = false;		// boolean. does the user have the correct version of flash? This isn't always required.
var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var maxVersion = 7;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
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
var VBcode = '';
if(isIE && isWin){
  VBcode += '<SCR' + 'IPT LANGUAGE=VBScript\> \n';
  VBcode += '\'do a one-time test for a version of VBScript that can handle this code\n';
  VBcode += 'on error resume next\n';
  VBcode += 'detectableWithVB = True\n';
  
  VBcode += '\'this next function will detect Flash\n';
  VBcode += 'Function detectFlashActiveXControl() \n';
  VBcode += '  on error resume next\n';
  VBcode += '	flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n';
  VBcode += '	if (flash2Installed) then flashVersion=2 \n';
  VBcode += '	flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n';
  VBcode += '	if (flash3Installed) then flashVersion=3 \n';
  VBcode += '	flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n';
  VBcode += '	if (flash4Installed) then flashVersion=4 \n';
  VBcode += '	flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n';  
  VBcode += '	if (flash5Installed) then flashVersion=5 \n';
  VBcode += '	flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n'; 
  VBcode += '	if (flash6Installed) then flashVersion=6 \n';
  VBcode += '	flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n'; 
  VBcode += '	if (flash7Installed) then flashVersion=7 \n';
  VBcode += 'End Function\n'; 
  VBcode += '</SCR' + 'IPT\> \n';
  document.writeln(VBcode);
}

function detectFlash(fVer) {
 if (fVer != null){
 	var requiredVersion = fVer;// Version the user needs to view site (max 7, min 2)
 }else{
 	var requiredVersion = 7;
 }
  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
    	haveFlash = true;
      	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;
		flash6Installed = flashVersion == 6;
		flash7Installed = flashVersion >= 7;
	}else if (detectableWithVB) {
  		detectFlashActiveXControl();
  		if (flash7Installed) haveFlash = true;
  	}
 }
	// 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 we're on webtv, the version supported is 2 (pre-summer2000, or 3, post-summer2000)
	// note that we don't bother sniffing varieties of webtv. you could if you were sadistic...
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;	
	
	//alert("version detected: " + actualVersion);
	//alert("Required Version: " + requiredVersion);
	if (actualVersion >= requiredVersion) {
		haveFlashVer = true;
	}else{
		haveFlashVer = false;
		}
}

function pgSniff()
{
	detectFlash();
	if ( !haveFlashVer )
	{
		document.location.href = '/index.html';
	}
}