var strJavascript = "JavaScript: Enabled";
var strCookies = "Cookies: unknown";
var strBrowser = "Browser: unknown";
var strResolution = "Resolution: unknown";
var strFlash = "Flash: unknown";
var strReturnDest = getParameter('retdest');

var verJS = "";
var verBrowser = "";
var verFlash = "";
var verJava = "";
var verRes = ""; 

function initializeAllChecks()
{
	var boolCookies = checkCookies();
	var boolBrowser = checkBrowser();
	var boolResolution = checkResolution();
	var boolFlash = checkFlash();

	strCookies = statusCookies("Cookies:", boolCookies);
	strBrowser = statusBrowser("Browser:", boolBrowser);
	strResolution = statusResolution("Resolution:", boolResolution);
	strFlash = statusFlash("Flash:", boolFlash);
}

function redirectUser()
{
	//location.replace("CWLaunchF.asp");
	//location.replace(strReturnDest);
}

function statusCookies(inString, inBool)
{

	if (inBool) 
	{
		inString = inString+" Enabled"

	} else {

		inString = "<font size='1' color='#CC0000' face='Verdana, Arial, Helvetica, sans-serif'><strong>"+inString+" Not Enabled! You must enable cookies.</strong></font>"		

	}
	
	return inString
}

function statusBrowser(inString, inBool)
{

	if (inBool) 
	{
		inString = inString+" OK - " + verBrowser;

	} else {

		inString = "<font size='1' color='#CC0000' face='Verdana, Arial, Helvetica, sans-serif'><strong>"+inString+" "+verBrowser+" - Your browser is not supported.</strong></font>"

	}

	//return "<strong>userAgent=</strong> "+navigator.userAgent + " <strong>; appName=</strong> " + navigator.appName  + " <strong>; appCodeName=</strong> " + navigator.appCodeName  + " <strong>; appVersion=</strong> " + navigator.appVersion;
	return inString;
}

function statusResolution(inString, inBool)
{

	if (inBool) 
	{
		inString = inString+" OK - " + verRes;

	} else {

		inString = "<font size='1' color='#CC0000' face='Verdana, Arial, Helvetica, sans-serif'><strong>"+inString+" "+verRes+" - You must adjust your monitor resolution.</strong></font>"

	}
	
	return inString
}


function statusFlash(inString, inBool)
{

	if (inBool) 
	{
		inString = inString+" OK - " + verFlash;

	} else {

		inString = "<font size='1' color='#CC0000' face='Verdana, Arial, Helvetica, sans-serif'><strong>"+inString+" "+verFlash+" - You must upgrade your browser's Flash plugin. Click <a href='http://www.adobe.com/products/flashplayer/'>here</a> to update your Flash Player.</strong></font>"

	}
	
	return inString

}

function checkCookies()
{

	var bool;

	if (document.cookie != "") 
	{

		bool= true;
 
	} else {

		bool= false;

	}

	return bool;
}

function checkBrowser()
{
	var bool;

	// Windows: IE6, IE7, Firefox 3.0
	// OSX: Safari 2.0.4, Firefox 3.0
	var numMSIE = 6;
	var numFirefox = 3;
	var numSafari = 522.11;

	var strAppVersion = navigator.appVersion;
	var strAppName = navigator.appName;
	var strUserAgent = navigator.userAgent;


	// CHECK os (appVersion):
	if(strAppVersion.indexOf("Windows") != -1){
		// this is a windows machine
		if (strAppName == "Microsoft Internet Explorer") {
			// this is an IE browser
			// check version: 
			verBrowser = "PC Internet Explorer";
			if (strAppVersion.indexOf("MSIE") != -1)
			{
				temp = strAppVersion.split("MSIE")
				if(parseFloat(temp[1]) >= numMSIE)
				{					
					bool = true;
				} else {
					bool = false;
				}
				verBrowser += ' ' + parseFloat(temp[1]);
			} else {
				//
				bool = false;
			}
		} else if (strAppName == "Netscape") {
			//
			if(strUserAgent.indexOf("Firefox") != -1)
			{
				// this is a Firefox browser
				// check version:
				verBrowser = "PC Firefox";
				var index=strUserAgent.lastIndexOf("/")+1;
				if (parseInt(strUserAgent.substring(index)) >= numFirefox)
				{					
					bool = true;
				} else {
					bool = false;
				}
				verBrowser += ' ' + parseInt(strUserAgent.substring(index));
			} else {
				// this is some browser other than Firefox
				bool = false;
			}
		} else {
			// this is some unknown Windows browser
			bool = false;
		}
	} else if (strAppVersion.indexOf("Macintosh") != -1){
		// this is a mac
		if(strAppName == "Netscape")
		{
			if(strUserAgent.indexOf("Firefox") != -1)
			{
				// this is a Firefox browser
				verBrowser = "Mac Firefox";
				// check version:
				var index=strUserAgent.lastIndexOf("/")+1;
				if (parseInt(strUserAgent.substring(index)) >= numFirefox)
				{					
					bool = true;
				} else {
					bool = false;
				}
				verBrowser += ' ' + parseInt(strUserAgent.substring(index));
			} else if (strUserAgent.indexOf("Safari") != -1) {
				// this is a Safari browser
				verBrowser = "Mac Safari";
				// check version:
				var index=strUserAgent.lastIndexOf("/")+1;
				if (parseFloat(strUserAgent.substring(index)) >= numSafari)
				{				
					bool = true;
					if (parseFloat(strUserAgent.substring(index)) >= 500)
						verBrowser += ' 3';

				} else {
					bool = false;
					verBrowser += ' ' + parseFloat(strUserAgent.substring(index));
				}

			} else {
				// unknown browser
				bool = false;
			}


		} else {
			// this is some unknown Macintosh browser
			bool = false;
		}
	} else {
		// no recognizable OS
		bool = false;
	}

	return bool;
}

function checkResolution()
{
	var bool;

	if ((screen.width>800) && (screen.height>640))
	{
 		bool = true;
	}
	else
	{
 		bool = false;
	}

	verRes = screen.width + "x" + screen.height;
	return bool;
}

function checkFlash()
{
	var bool;

	// This script will test up to the following version.
	flash_versions = 20;
	// the minimum operable flash version is:
	flash_min_version = 8;
	
	// Initialize variables and arrays
	var flash = new Object();
	flash.installed=false;
	flash.version='0.0';

	// Dig through Netscape-compatible plug-ins first.
	if (navigator.plugins && navigator.plugins.length) {
		for (x=0; x < navigator.plugins.length; x++) {
			if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
				flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
				flash.installed = true;
				break;
			}
		}
	}

	// Then, dig through ActiveX-style plug-ins afterwords
	else if (window.ActiveXObject) {
		for (x = 2; x <= flash_versions; x++) {
			try {
				oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
				if(oFlash) {
					flash.installed = true;
					flash.version = x + '.0';
				}
			}
			catch(e) {}
		}
	}

	// Create sniffing variables in the following style: flash.ver[x]:
	flash.ver = Array();
	for(i = 4; i <= flash_versions; i++) {
		eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
	}

	if (parseInt(flash.version) >= flash_min_version){
		bool = true;
	} else {
		bool = false;
	}
	if (!flash.installed)
		verFlash = "Not Installed";
	else
		verFlash = parseFloat(flash.version);

	return bool;
}

function getParameter( parameterName ) {
  var queryString = window.location.search.substring(1).toLowerCase();
  //alert(queryString);
  //if (queryString.length==0) {return "null";}
  var parameters = new Array();
  parameters = queryString.split('&');
  for(var i = 0; i < parameters.length; i++) {
    //alert(parameters[i]);
    //alert(parameters[i].indexOf(parameterName));
    if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {
      //alert(parameters[i]);
      var parameterValue = new Array();
      parameterValue = parameters[i].split('=');
      return parameterValue[1];
    }
  }
  return "null";
}


// create a cookie to check that cookies are enabled:
document.cookie = 'killme' + escape('nothing');

