
var browser, os, isNewWindows, isWindows, isVista, isWindows95, isMac
var browserName = ""
getOs()

// get the Operating System into the variable os
function getOs() {
	// N.B. the following variable has to be global, it's used by other methods
	browser = navigator.userAgent.toLowerCase()
	var appVersion = navigator.appVersion.toLowerCase()

	isWindows = false;
	isWindows95 = false;
	if (!check("linux") && !check("x11") && !check("mac")) {
		if (check("win")) {
			isWindows = true
			// Sometimes browser string includes stuff like 
			// "windows; win 98"; find that 2nd occurence
			if (os == "windows") {
				start = browser.indexOf("win", osStart + 1)
				if (start != -1) {
					end = browser.indexOf(";", start)
					if (end == -1) 
						end = browser.indexOf(")", start)
					os = browser.substring(start, end)
				}
			}
			checkWindowsOs()
		}
	}
	if (os == "mac")
		isMac = true
	// partial browser detection from:
	//   http://www.clearlanguageatwork.com/.shared/app.jsl
	if (browser.indexOf("opera") >= 0)
	{
		browserName = "Opera";
	}
	else if (browser.indexOf("konqueror") >= 0)
	{
		browserName = "Konqueror";
	}
	else if (os == "mac" && browser.indexOf("safari") >= 0)
	{
		browserName = "Safari";
	}
	else if (appVersion.indexOf("msie") >= 0)
	{
		browserName = "IE";
	}
	// don't care about others, really only want to detect IE without 
	// accidentally catching others that also include "msie" somewhere!
}

// return whether the browser string contains a given substring that identifies
// an Operating System, and set the os variable and osStart variable if so
function check(str) {
	osStart = browser.indexOf(str)
	if (osStart >= 0) {
		var end = browser.indexOf(";", osStart)
		if (end == -1) 
			end = browser.indexOf(")", osStart)
		os = browser.substring(osStart, end)
		return true
	}
	return false
}

// set the variable isNewWindows (true only for Unicode versions of 
// Windows: 2000, XP or 2003 or higher), and isWindows95
function checkWindowsOs() {
	isVista = false;
	if (os.indexOf("nt 6") != -1) {
		isNewWindows = true
		isVista = true
	}
	else if (os.indexOf("nt 5") != -1) {
		isNewWindows = true
	}
	else if (os.indexOf("9") != -1 || os.indexOf("me") != -1 ||
			 os == "winnt" || os == "windows nt") {
		// must be old Windows
		if (os.indexOf("95") != -1) {
			isWindows95 = true
		}
	}
	else {
		// assume unknown newer version of Windows
		isNewWindows = true
	}
}

function showWarning()
{
	if (!isWindows)
	{
		if (!confirm("You seem to be downloading this on a non-Windows " +
					 "operating system.\n" +
					 "This program can only be installed " +
					 "on Windows versions XP, Vista, 2000, 2003 or Windows 7.\n\n" +
					 "Do you really want to continue downloading it?"))
			return false;
	}
	else if (!isNewWindows)
	{
		if (!confirm("This program can only be installed on Windows " +
					 "versions XP, Vista, 2000, 2003 or Windows 7.\n" +
					 "You seem to be downloading it on an older version " +
					 "of Windows.\n\n" +
					 "Do you really want to continue downloading it?"))
			return false;
	}
	doTracking();

	return true;
}

