var passedColour = "#008000";
var failedColour = "#800000";
var detectableWithVB = false;

var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);


var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
          && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
          && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) ||
                    (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));

var is_netscape = (agt.indexOf('netscape') != -1);
var is_netscape7_2 = (is_netscape && (agt.indexOf("netscape/7.2") != -1 ));

var is_opera = (agt.indexOf('opera') != -1);
var is_opera9 = (is_opera && (is_major > 8));

var is_gecko = (agt.indexOf('gecko') != -1);

var is_firefox = (agt.indexOf('firefox') != -1);
var is_firefox1_5 = (is_firefox && (agt.indexOf("firefox/1.5") != -1 ));
var is_firefox2_0 = (is_firefox && (agt.indexOf("firefox/2.0") != -1 ));
var is_firefox3_0 = (is_firefox && (agt.indexOf("firefox/3.0") != -1 ));

var is_safari = (agt.indexOf('safari') != -1);
var is_safari1_3 = (is_safari && (agt.indexOf("safari/1.3") != -1 ));
var is_safari2_0 = (is_safari && (agt.indexOf("safari/2.0") != -1 ));
var is_safari3_0 = (is_safari && (agt.indexOf("safari/3.0") != -1 ));

var is_mozilla = ( is_gecko && is_firefox == -1 && is_netscape == -1 && is_safari == -1 )
var is_mozilla1_7 = (is_mozilla && (agt.indexOf("rv:1.7") != -1 ));

var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up = (is_ie && (is_major >= 4));
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var is_ie7 = (is_ie && (is_major == 4) && (agt.indexOf("msie 7.")!=-1) );
var is_ie7up = (is_ie && !is_ie3 && !is_ie4 && !is_ie6 && !is_ie6up);

var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
var is_win16 = ((agt.indexOf("win16")!=-1) ||
         (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
         (agt.indexOf("windows 16-bit")!=-1) );
var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
              (agt.indexOf("windows 16-bit")!=-1));
var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));
var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 ||
              ((is_major >= 4) && (navigator.platform == "Win32")) ||
              (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
var is_win2k = is_winnt && (agt.indexOf("5.0") != -1);
var is_winxp = is_winnt && (agt.indexOf("5.1") != -1);
var is_os2 = ((agt.indexOf("os/2")!=-1) ||
              (navigator.appVersion.indexOf("OS/2")!=-1) ||
              (agt.indexOf("ibm-webexplorer")!=-1));

var is_mac = (agt.indexOf("mac")!=-1);
if (is_mac && is_ie5up) is_js = 1.4;
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                         (agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                          (agt.indexOf("powerpc")!=-1)));
                          

// These terms are overridden
var JTHelp = "Help";

var BTDescription = "<p>A current browser such as the latest version of Microsoft Internet Explorer is recommended to ensure full functionality of all components.</p>";
var BTRecommendationMac = "";
var BTRecommendationWindows = "";
var BTRecommendationLinux = "";

var BTResultPass = "<p>Your browser is sufficient.</p>";
var BTResultFail_1 = "<p>Your browser is not a sufficient browser, please <a href='upgrade_browser.asp?ou=";
var BTResultFail_2 = "'>upgrade</a> your browser.</p>";
var BTName = "<h3>Browser</h3>";

var BTFullyCompatible = "FC";
var BTCurrentlyTesting = "CT";
var BTOldBrowser = "OB";
var BTFailed = "Failed";

var BTHelp = "Help";

function browsertest() {

	var pass = false;
	result_text = BTFailed;
	
	if ( is_ie ) {
		if ( is_ie6up || is_ie7up ) {
			result_text = BTFullyCompatible;
			pass = true;
		}			
	}
	
	if ( is_firefox ) {
		if ( is_firefox1_5 ) {
			result_text = BTFullyCompatible;
			pass = true;
		}
		if ( is_firefox2_0 ) {
			result_text = BTFullyCompatible;
			pass = true;
		}
		if ( is_firefox3_0 ) {
			result_text = BTFullyCompatible;
			pass = true;
		}
	}
	
	if ( is_netscape ) {
		if ( is_netscape7_2 ) {
			result_text = BTCurrentlyTesting;
			pass = true;
		}	
	}

	if ( is_mozilla ) {
		if ( is_mozilla1_7 ) {
			result_text = BTOldBrowser;
			pass = true;
		}	
	}
	
	if ( is_opera ) {
		if ( is_opera9 ) {
			result_text = BTCurrentlyTesting;
			pass = true;
		}	
	}
	
	if ( is_safari ) {
		if ( is_safari2_0 || is_safari3_0 ) {
			result_text = BTCurrentlyTesting;
			pass = true;
		}
		if ( is_safari1_3 ) {
			result_text = BTOldBrowser;
			pass = true;
		}	
	}

	drawCheck(BTName, '', pass, result_text, '');
}

var CTDescription = "The use of cookies is to allow for an increased level of security and are not being used to track your movements.";
var CTResultPass = "Your cookies are enabled.";
var CTResultFail_1 = "You do not have cookies enabled.&nbsp";
var CTResultFail_2 = "Click here for instructions";
var CTResultFail = "Fail";
var CTName = "Cookies";

var CTHelp = "Help";

function cookietest() {
	var description = '';
	var pass;
	var result_text = "";
	document.cookie = "test=cookietest";
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf("test=");
	if(ind==-1) {
		pass = false;
		result_text = CTResultFail;

		result_text +="</a>";
	}
	else {
		pass = true;
		result_text = CTResultPass;
	}
	drawCheck(CTName, description, pass, result_text, CTHelp);
}

var DTDescription = "To view our pages properly, this test ensures your computer is running the proper screen resolution and color depth.";
var DTResultPass = "You are running a sufficient screen resolution. You are also running a sufficient colour level.";
var DTResultFail_1 = "You are running a 640 X 480 screen resolution. We recommend that you run at least an 800 X 600 screen resolution.";
var DTResultFail_2 = " You are also only running at a 2-bit colour level. We recommend that you use at least a 16-bit colour level.";
var DTResultFail_3 = " You are also only running a 4-bit colour level. We recommend that you use at least a 16-bit colour level.";
var DTResultFail_4 = " You are also only running at an 8-bit colour level.  We recommend that you use at least a 16-bit colour level.";
var DTResultFail_5 = " However, you are running a sufficient colour level.";
var DTResultFail_6 = "Follow these instruction to change your display settings.";
var DTResultFail_7 = "You are running a sufficient screen resolution.";
var DTResultFail_8 = " However you are also only running a 2-bit colour level. We recommend that you use at least a 16-bit colour level.";
var DTResultFail_9 = " However, you are only running a 4-bit colour level. We recommend that you use at least a 16-bit colour level.";
var DTResultFail_10 = " However, you are only running a 4-bit colour level. We recommend that you use at least a 16-bit colour level.";
var DTResultFail_11 = "Follow these instruction to change your display settings.";


var DTName = "<DT>Display</DT>";
var DTResPass = "";
var DTPixDepPass = "";
var DTResFailed = "";
var DTPixDepFailed = "";
var DTMoreInfo = "";

function displaytest() {
	var passRes = true;
	var passPD = true;
	var result_text = "";
	if ( screen.height == 480 ) {
		passRes = false;

	}

	if ( screen.pixelDepth<16 || screen.colorDepth<16  ) {
		passPD = false;
	}
	
	
	document.write("<DT>" + DTName + "</DT>");
	
	if ( passRes ) {
		document.write("<DD><img src='/content/images/detect_tick.png' align='absmiddle' alt='" + DTPass + "' title='" + DTPass + "'>");
		document.write("<span class='pass'>" + DTPassed + "</span></DD>");
	}

	
	if(passRes == false ) {
		document.write("<DD><img src='/content/images/detect_error.png' align='absmiddle' alt='" + DTFailed + "' title='" + DTFailed + "'>");
		document.write("<span class='pass'>" + DTFailed + "</span></DD>");
	}
		
}

function detectPlugin() {
	var daPlugins = detectPlugin.arguments;
	var pluginFound = false;
	if (navigator.plugins && navigator.plugins.length > 0) {
		var pluginsArrayLength = navigator.plugins.length;
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
			var numFound = 0;
			for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
	    			(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
	    			numFound++;
				}
			}
			if(numFound == daPlugins.length) {
				pluginFound = true;
				break;
			}
		}
	}
	return pluginFound;
}

var DTPass = "Pass";
var DTPassed = "Passed";
var DTFailed = "Failed";

function drawCheck(name, description, pass, result_text, help_text) {
	document.write("<DT>" + name + "</DT>");
	if(pass) {
		document.write("<DD><img src='/content/images/detect_tick.png' align='absmiddle' alt='" + DTPass + "' title='" + DTPass + "'>");
	}
	else {
		document.write("<DD><img src='/content/images/detect_error.png' align='absmiddle' alt='" + DTFailed + "' title='" + DTFailed + "'>");
	}
	if(pass) {
		document.write("<span class='pass'>" + DTPassed + "</span></DD>");
	}
	else {
		document.write("<span class='fail'>" + DTFailed + "</span></DD>");
	}
}

// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    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('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}