function loadApplet_timeoutCheck() {
  if (typeof(debug)=="function") debug("ontimeout");
  var isActive=-1;
  try{
  if (!document.getElementById(this.jar_id)) isActive=-1;
  else
  if (document.getElementById(this.jar_id).isActive()) isActive=1;
  else isActive=0;
  } catch (e) {
  }
  /*try {
  document.getElementById("info").innerHTML+=" "+isActive;
  document.getElementById("info").innerHTML+=" pete "+(document.getElementById("pete")?" no existe":"existe");
  document.getElementById("info").innerHTML+=" pete "+document.getElementById("HashManager").showStatus();
  } catch(e) {
  }*/
  if (isActive!=1) {
    // Hasta que no solventemos el bug de Firefox viejo, timeout ilimitado
    //this.time++;
    if (this.time<this.timeout) 
      setTimeout("window['"+this.instance+"'].timeoutCheck()",100);
    else this.onerror();
  } else {
    this.onload();
  }
}


function loadApplet_run() {
  setTimeout("window['"+this.instance+"'].timeoutCheck()",100);
  this.time=0;
  var code="<" +"!--[if !IE]>--"+">"+
                '<object id="'+this.jar_id+'" classid="java:'+this.cls+'" type="application/x-java-applet" archive="'+this.jar+'" style="width: 0px; height: 0px; float:left;">'+
                '<param name="mayscript" value="true" />'+
            '<'+'!--<![endif]--'+'>'+
            '<object id="'+this.jar_id+'" classid="'+this.classid+'" codebase="'+this.codebase+'" style="width: 1px; height: 1px; float:left;">'+
                '<param name="code" value="'+this.cls+'" />'+
                '<param name="archive" value="'+this.jar+'" />'+
                '<param name="mayscript" value="true" />'+
            //'<div id="javanocargo" style="display:none"><a href="http://java.sun.com/update/1.6.0/jinstall-6u14-windows-i586.cab">Enlace a descarga del plugin de Java necesario.(Producto de Sun Microsystems)</a></div>'+
            '</object>'+
            '<'+'!--[if !IE]>--'+'>'+

            '</object>'+

            '<'+'!--<![endif]--'+'>';
  jQuery(this.container).append(code);
}

function loadApplet_onload() {
  //alert("El applet cargó.");
}

function loadApplet_onerror() {
  alert("Problema en carga de applet");
}

var loadApplet_countInstance=0;
function loadApplet(id,jar,cls,container) {
  this.run=loadApplet_run;
  this.instance="loadApplet_"+(window.loadApplet_countInstance++);
  window[this.instance]=this;
  this.timeoutCheck=loadApplet_timeoutCheck;
  this.jar_id=id;
  this.jar=jar;
  this.cls=cls;
  this.codebase="http://java.sun.com/update/1.6.0/jinstall-6u14-windows-i586.cab";
  this.classid="clsid:CAFEEFAC-0014-0001-0000-ABCDEFFEDCBA";
  this.time=0;
  this.timeout=30;
  this.onload=loadApplet_onload;
  this.onerror=loadApplet_onerror;
  if ((container===undefined)||(!document.getElementByID(container))) {
    this.container=document.body; 
  } else this.container=document.getElementByID(container);
}

