function checkJava(page) {
	var windowsIE = (checkPlatform("msie") && checkPlatform("win"));
	if (windowsIE) {
		writeWindowsData(page);
		//This function will close IE6 window and IE7 tab without confirmation after 5 sec of launching.
		setTimeout("closeIEWindow();", 10000);
	} else {
		writeMozillaData(page);
		//This function will close mozilla or firefox after 5 sec of launching.
		//This function works only for prior Firefox 2.x release.
		setTimeout("closeFireFoxWindow();", 10000);
	}
}

function checkPlatform(string)
{
	var detect = navigator.userAgent.toLowerCase();
	place = detect.indexOf(string) + 1;
	thestring = string; 
	return place;
}

function writeWindowsData(page) {
	document.write("<OBJECT codeBase=http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab classid=clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284 height=0 width=0>");
	document.write("<PARAM name=app VALUE=" + page + ">");
	document.write("<PARAM NAME=back VALUE=false>");
	document.write("</OBJECT>");
}

function writeMozillaData(page) {
	versionCheck = webstartVersionCheck("1.5");
	if (!versionCheck) {
		var pluginPage = "http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com";
		document.write("The version of Java plugin needed to run the application is not installed. The page from where the plugin can be downloaded will be opened in a new window. If not, please click here: <a href=" + pluginPage + ">Download correct Java version.</a>");
		window.open(pluginPage, "needdownload");
	} else {
		window.location = page;
	}
}

function webstartVersionCheck(versionString) {
	// Mozilla may not recognize new plugins without this refresh
	navigator.plugins.refresh(true);
	// First, determine if Web Start is available
	if (navigator.mimeTypes['application/x-java-jnlp-file']) {
		// Next, check for appropriate version family
		for (var i = 0; i < navigator.mimeTypes.length; ++i) {
			pluginType = navigator.mimeTypes[i].type;
			if (pluginType == "application/x-java-applet;version=" + versionString) {
				return true;
			}
		}
	}
	return false;
}

function closeIEWindow() {
	window.opener='X';
	window.open('','_parent','');
	window.close();
}

function closeFireFoxWindow() {
	window.open('','_parent','');
	window.close();
}

