 function launch(){
	if (isJava5IE() || isJava6IE() || isJava5FF() || isJava6FF()){
	    //Iniciar directamente si JAVA 5+ esta instalado
		window.location="http://www.personalsoft.com.ve/calculadora/calculadora.jnlp";
	}else if(isWindowsIE()){
		//Autoinstalar y luego iniciar el prototipo
		launchJNLPJavaAutoInstall();
	}else{
	    //redirecciona a la pagina GetJava e inicia el prototipo
		launchJNLPGetJava();
	}
 }
 function isJava5IE(){
	try{
		//Detectar Java 5 
		var obj=new ActiveXObject("JavaWebStart.isInstalled.1.5.0.0");
		if (obj!=null){
			return 1;
		}
	} catch (exception) {
		return 0;
	}
 }
 function isJava6IE(){
	try{
		//Detectar Java 5 
		var obj=new ActiveXObject("JavaWebStart.isInstalled.1.6.0.0");
		if (obj!=null){
			return 1;
		}
	} catch (exception) {
		return 0;
	}
 }
function isJava5FF(){
	for (var i=0; i < navigator.mimeTypes.length; ++i){
		s=navigator.mimeTypes[i].type;
		//detectar
		if(s=="application/x-java-applet;version=1.5"){
			return 1;
		}
	}
	return 0;
}
function isJava6FF(){
	for (var i=0; i < navigator.mimeTypes.length; ++i){
		s=navigator.mimeTypes[i].type;
		//detectar
		if(s=="application/x-java-applet;version=1.6"){
			return 1;
		}
	}
	return 0;
}
function isWindowsIE(){
   s=navigator.appName;
   if (s=="Microsoft Internet Explorer"){
      return 1;
   }
   return 0;
}
function launchJNLPJavaAutoInstall(){
   //auto instala la version mas reciente de java, luego inicia el prototipo
   document.write("<OBJECT classid=clsid:5852F5ED-8BF4-11D4-a245-0080C6F74284 codebase=http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#version=5,0,0,99 height=0 width=0>");
   document.write("<PARAM name=app value=http://www.personalsoft.com.ve/calculadora/calculadora.jnlp>");
   document.write("</OBJECT>");
}
function launchJNLPGetJava(){
  window.open("http://java.com/getjava","newWindow");
  launchTID=setInterval('launchApp("http://www.personalsoft.com.ve/calculadora/calculadora.jnlp")',100);
}
function launchApp(app){
	x=navigator.mimetypes['application/x-java-applet;version1.5'];
	if(x){
		window.location=app;
		clearInterval(launchTID);
	}
}
