﻿// Copyright 2009 Richard W. Adams

var LATEST_IE		= 8;
var LATEST_FIREFOX	= 3;

var agent = navigator.userAgent;

//----------------------------------------------------
function checkSystem() {
	if (screen.width < 800) {
		document.write("<p class='notice'>Your screen resolution is currently " + screen.width + "x" + screen.height + "&#151;we recommend you set it to 800x600 or higher.</p>");
	}
	checkBrowser();
}
//----------------------------------------------------
function checkBrowser() {
	if (agent.indexOf("MSIE") != -1) {
		checkMSIE();
	} else if (agent.indexOf("Firefox") != -1) {
		checkFirefox();
	}
}
//----------------------------------------------------
function checkFirefox() {
	var match = agent.match("Firefox/[\\d\\.]+");
	if (match !== null) {
		var version = match[0].split("/")[1];
		var majorVersion = version.split(".")[0];
		if (majorVersion < LATEST_FIREFOX) {
			recommend("Firefox", version, LATEST_FIREFOX)
		}
	}        
}
//----------------------------------------------------
function checkMSIE() {

	var match = agent.match("MSIE [\\d\\.]+");
	if (match !== null) {
		var version = match[0].split(" ")[1];
		var majorVersion = version.split(".")[0];
		if (majorVersion < LATEST_IE) {
			recommend("Internet Explorer", version, LATEST_IE)
		}
	}        
}
//----------------------------------------------------
function recommend(browser, currentVersion, latestVersion) {
	write("<p class='notice'>You seem to be using " + browser + " version " + currentVersion + ". For the best experience with this site, we recommend you upgrade to version " + latestVersion + " or later.</p>");
}
