var recentHash = "";
function pollHash() {

   if (window.location.hash=="") { window.location.hash="inicio" }
   if (window.location.hash==recentHash) {
	 return; // Nothing's changed since last polled.
   }
   recentHash = window.location.hash;

   // URL has changed, update the UI accordingly.
   load(recentHash.substring(1,recentHash.length));
}

window.onload = function() {
   pollHash();
   setInterval(pollHash, 1000);
   imageTemp();
}

// global variable for the XMLHttpRequest object
   var httpRequest;

  
   /**
    * load info ...
    */
   function load(file)
   {
          var contenedor = document.getElementById("info");
          contenedor.innerHTML = "<b style='color:#2680a9;'>Cargando...<b>";
     
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
		httpRequest.open("GET", "c_"+file+".php", true);
       	httpRequest.onreadystatechange= function () {processRequest(); } ;
       	httpRequest.send(null);
   }
  
   /**
    * Event handler for the XMLhttprequest
    * when the content is back (State 4 and status 200)
    * take the content of the request and copy it into the HTML page
    */
   function processRequest()
   {
      if (httpRequest.readyState == 4)
      {
        if(httpRequest.status == 200)
        {
          var contenedor = document.getElementById("info");
          contenedor.innerHTML = httpRequest.responseText;
        }
        else
        {
            alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
            var contenedor = document.getElementById("info");
            contenedor.innerHTML = "Error: can not get the content ("+ httpRequest.statusText +") "+recentHash;
        }
      }
      else
      {
          var contenedor = document.getElementById("info");
          contenedor.innerHTML = "<b style='color:#2680a9;'>Cargando...<b>";
      }

   }