var requiredVersion = 5;		// version the user needs to view site is 5
var useFlashFile = false; 		// "true" loads flash, "false" embeds .gif into current page
var flash2Installed = false;		// boolean. true if flash 2 is installed
var flash3Installed = false;		// boolean. true if flash 3 is installed
var flash4Installed = false;		// boolean. true if flash 4 is installed
var flash5Installed = false;		// boolean. true if flash 5 is installed
var flash6Installed = false;		// boolean. true if flash 6 is installed
var flash7Installed = false;        // boolean. true if flash 7 is installed
var flash8Installed = false;        // boolean. true if flash 8 is installed
var maxVersion = 8;				// highest version we can actually detect
var actualVersion = 0;				
var hasRightVersion = false;

// check the browser and operating system
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

// write vbscript detection if we are using IE and PC
if(isIE && isWin){ 
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');	
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');	
	document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');	
	document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');	
	document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

// check to see if we have flash 5 installed
function detectFlash(strPopUp){	
	if (navigator.plugins){ 
		// this next bit will only fire with NN, and not IE. 		
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]){
			// set 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;
			// we can get the major version by grabbing the character before the period
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			// if the flashversion is 5, set the variable to true
			//alert(flashVersion);
			flash2Installed = flashVersion == 2;		
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
			flash8Installed = flashVersion == 8;
		}
	}
	
	// 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;
	}
	
	//alert(flash7Installed);
	
	// this code is fired regardless of OS or browser.  if we are in IE, it will acccess the VBScript variables
	if (actualVersion >= requiredVersion) { 
		hasRightVersion = true;
	} else {
		hasRightVersion = false;
 		if (strPopUp == true) {
 			window.open("https://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash", null, "height=170,width=420");
 		} 		
 	}
} 


function UpdateSponsorAd()
{
	xmlhttp.open("GET", "SponsorAd.ashx", true);
	xmlhttp.onreadystatechange = function()
		{
			// This is the callback routine
			if (xmlhttp.readyState == 4)
			{
				var result = xmlhttp.responseText;
				var resultArray = result.split(";");
				if (resultArray.length == 2)
				{
					var extensionArray = resultArray[1].split(".");
					
					if (extensionArray.length == 2)
					{
						var displayPane = document.getElementById("displayPane");
						
						if (extensionArray[1] == "swf")
						{
						/*	detectFlash(false);	// call our detector
							
							
							if (hasRightVersion) 
							{
						*/		
								if (displayPane)
								{
									displayPane.innerHTML = "<a href='" + resultArray[0] + "' id='SponsorAdLink' target= '_new'><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='728' height='90' id='" + extensionArray[0] + "' align='middle' VIEWASTEXT>" + "<param name='allowScriptAccess' value='sameDomain' />" + "<param name='movie' value='" + resultArray[1] + "' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='" + resultArray[1] + "' quality='high' bgcolor='#ffffff' width='728' height='90' name='" + extensionArray[0] + "' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' /></object></a>";
								}
								
						/*	} 
							else 
							{
								if (displayPane)
								{
									displayPane.innerHTML = "<a href='http://www.pba.com/clicks.asp?url=http://www.macromedia.com/go/getflashplayer' id='SponsorAdLink' target='_new'><img src='/Images/ads/NoFlash728X90.gif' id='SponsorAdImage' border='0' /></a>";
								}
							}
						*/	
						}
						else
						{
							if (displayPane)
							{
								displayPane.innerHTML = "<a href='" + resultArray[0] + "' id='SponsorAdLink' target= '_new'><img src='" + resultArray[1] + "' id='SponsorAdImage' border='0' /></a>";
							}
						}	
						
					}
					
				
				}
			}
		};
	xmlhttp.setRequestHeader("Accept", "message/x-jl-formresult");
	xmlhttp.send( null );
	return false;
}



function RunFlash(src, width, height)
{
	document.write ("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + width + "' height='" + height + "' id='flashDisplay' align='middle' VIEWASTEXT >" + "<param name='allowScriptAccess' value='sameDomain' />" + "<param name='movie' value='" + src + "' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><param name='wmode' value='opaque'><param name='wmode' value='transparent'> <embed wmode='opaque' src='" + src + "' quality='high' bgcolor='#ffffff' width='" + width + "' height='" + height + "' name='flashDisplay' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' /></object>");		
}


var xmlhttp;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E)
		{
			xmlhttp = false;
		}
	}
@else
	xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
	try
	{
		xmlhttp = new XMLHttpRequest();
	}
	catch (e)
	{
		xmlhttp=false;
	}
}