function handleHttpResponseGarantia() {
        if(http.readyState==1){
            //document.getElementById("usuariosactivos").innerHTML = "<img src=../include/loading2.gif width=20 height=20>";
            document.getElementById("ttlDiv").innerHTML = "Searching latest offers...";
        }else if(http.readyState==4){
            if(http.status==200){
                results = http.responseText.split(",");
                document.getElementById("ttlDiv").innerHTML = results[0];
                enProceso = false;
            }else if(http.status==500){ // 404 NotFound
                //La pagina no existe
                document.getElementById("ttlDiv").innerHTML = "N/D";
            }else{
                //Mostramos el posible error
                document.getElementById("ttlDiv").innerHTML = "N/D"; 
            }
        }
}

// Latest offers and TTL
function latestOffers () {
    if (!enProceso && http) {
       var myRand = parseInt(Math.random()*999999999999999);       
       var url = "inc_latestOffers.asp?r="+myRand;
       http.open("GET", url, true);
       http.onreadystatechange = handleHttpResponseGarantia;
       enProceso = true;
       http.send(null);
    }
	timerID = setTimeout("latestOffers()", 5*60*1000);
	//timerID = setTimeout("latestOffers()", 2000);
}

function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
       try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (E) { xmlhttp = false; }
       }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest

timerID = setTimeout("latestOffers()", 5*60*1000);
//timerID = setTimeout("latestOffers()", 2000);

