
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 showStandardWarning()
{
	/* Don't to this anymore, it's just one more obstacle for the user,
	 * and sometimes users that Save can't find the file after that!
	alert("If your web browser prompts you to Run or Save this file, " +
		  "I recommend you to select Save, and save it to a folder on your " +
		  "hard drive that you can find again later.\n\n" + 
		  "That way, if you need to run the installation a 2nd time " +
		  "(which can happen in various circumstances), you won't have " +
		  "to download the program a 2nd time.")
	*/

	/* Don't do the following anymore, because I am code signing:
	alert("In addition, on some versions of Windows, you may " +
		  "get a message before you start the install saying that the " +
		  "publisher could not be verified, as it is an Unknown Publisher.\n\n" +
		  "This occurs because I have not bought a moderately expensive " +
		  "digital certificate that could be used to identify the publisher " +
		  "of DONATION. Please do not be concerned. You can go ahead and " +
		  "select the option to Run the program anyways.")
	*/

	return true
}
