var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

var agt=navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);

if (ie && win) {	pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
if (ns || !win) {
		nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
}

function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

function browsertest(img) {
	var pass;
	if (BrowserDetect.browser == 'Firefox') {
		if (BrowserDetect.version < 2) {
			pass = false;
		}
	}
		else if (BrowserDetect.browser == 'Explorer') {
			if (BrowserDetect.version < 6) {
				pass = false;
			}
		}
			else if (BrowserDetect.browser == 'Opera') {
				if (BrowserDetect.version < 9) {
					pass = false;
				}
			}
				else if (BrowserDetect.browser == 'Safari') {
					if (BrowserDetect.version < 500) {
						pass = false;
					}
				}
					else {
						pass = false;
					}
	
	if (pass === false) {
		document.getElementById('browsertest').src = '/images/fail.gif';
	}
		else {
			document.getElementById('browsertest').src = '/images/pass.gif';
		}
}

function ostest() {
	if ((BrowserDetect.OS == 'Windows') || (BrowserDetect.OS == 'Mac')) {
		document.getElementById('ostest').src = '/images/pass.gif';
	}
		else {
			document.getElementById('ostest').src = '/images/fail.gif';
		}
}

function restest() {
	if (parseInt(window.screen.width) < 1024) {
		document.getElementById('restest').src = '/images/fail.gif';
	}
		else {
			document.getElementById('restest').src = '/images/pass.gif';
		}
}

function jstest() {
	document.getElementById('jstest').src = '/images/pass.gif';
}

function javatest(d) {
	if (navigator.javaEnabled()) {
		if (d == 't') {
			document.write('Enabled');
		}
		
			else {
				document.getElementById('javatest').src = '/images/pass.gif';
			}
	}
		else {
			if (d == 't') {
				document.write('Disabled');
			}
			
				else {
					document.getElementById('javatest').src = '/images/fail.gif';
				}
		}
}
		currCookies = (document.cookie.length > 0);

function cookietest(d) {
	document.cookie = 'testcookie';
	if (document.cookie.length > 0) {
		if (d == 't') {
			document.write('Enabled');
		}
		
			else {
				document.getElementById('cookietest').src = '/images/pass.gif';
			}
	}
		else {
			if (d == 't') {
				document.write('Disabled');
			}
			
				else {
					document.getElementById('cookietest').src = '/images/fail.gif';
				}
		}
}

function wmptest(d) {
	if (pluginlist.indexOf("Windows Media Player") != -1) {
		if (d == 't') {
			document.write('Installed');
		}
		
			else {
				document.getElementById('wmptest').src = '/images/pass.gif';
			}
	}
		else {
			if (d == 't') {
				document.write('Not Installed');
			}
			
				else {
					document.getElementById('wmptest').src = '/images/fail.gif';
				}
		}
}

function aartest(d) {
	if (pluginlist.indexOf("Acrobat Reader") != -1) {
		if (d == 't') {
			document.write('Installed');
		}
		
			else {
				document.getElementById('aartest').src = '/images/pass.gif';
			}
	}
		else {
			if (d == 't') {
				document.write('Not Installed');
			}
			
				else {
					document.getElementById('aartest').src = '/images/fail.gif';
				}
		}
}