var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,thestring;

if (checkIt('safari')) {
	browser = "SF";
	version = parseFloat(detect.substring(place + thestring.length, place + thestring.length + 2))/10;
}
else if (checkIt('msie')) {
	browser = "IE";
	version = parseFloat(detect.substring(place + thestring.length, place + thestring.length + 3));
}
else browser = "An unknown browser";

if (!OS)
{
	if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Win"
	else OS = "An unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function redirectTo() {
  if (OS=="Mac") {
    if (browser=="SF") {
      top.document.location.href = "mac_saf.html";
    }
    else if (browser=="IE") {
      top.document.location.href = "mac_ie.html";
    }
    else {
      top.document.location.href = "error.html";
    }
  }
  else if (OS=="Win") {
    if (browser=="IE") {
      top.document.location.href = "win_ie.html";
    }
    else {
      top.document.location.href = "error.html";
    }
  }
  else {
    top.document.location.href = "error.html";
  }
}
function JREVersion (x) {
  var re = /(\d\.\d(\.\d))/
  var match = re.exec(x);
  if (!match)
    return null
  else {
    return match[1];
  }
}

var jreversion = 0;
if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-java-applet'];
	if (x && x.enabledPlugin)
	{
		if (x.enabledPlugin.description) jreversion = JREVersion(x.enabledPlugin.description);
	}
}
else if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Java Plug-in"];
	if (x)
	{
		if (x.description) jreversion = JREVersion(x.description);
	}
}
else
{
	var shell;
	try {
		shell = new ActiveXObject("WScript.Shell");
		if (shell != null) {
			try {
				jreversion = shell.regRead("HKEY_LOCAL_MACHINE\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");
			} catch(e) {
			// handle exceptions raised by 'shell.regRead(...)' here
			// so that the outer try-catch block would receive only
			// exceptions raised by 'shell = new ActiveXObject(...)'
			}
		}
	} catch(e) {
	// Creating ActiveX controls thru script is disabled 
	// in InternetExplorer security options
	activeXDisabled = true;
	}
}
