// JavaScript Document
   var t = [];
   var HttpHead = [];

   function get_temp(div_id,id,user,date)
    {
     if(date=='')
      {
       date = 'actual';
      }
      if(document.getElementById(div_id).innerHTML=='')
       {
     HttpHead[div_id] = ajaxFunction();
     HttpHead[div_id].open("GET", "/meredi_proxy/gettemp/"+user+"/"+id+"/"+date+".php",true);
     t[div_id] = setTimeout("check_abort_temp('"+div_id+"')", 2000);          
     HttpHead[div_id].onreadystatechange=function() {ajaxResponse_temp(id,user,div_id,date); };
     HttpHead[div_id].send(null);
      }         
    }

   function check_abort_temp(div_id)
    {
     HttpHead[div_id].abort();
     document.getElementById(div_id).innerHTML='N/A&deg;C';
     clearTimeout(t[div_id]);
    }    
    
    
//----------------------------- funkce pro ajax
   function ajaxFunction()
    {
     var xmlHttp;
     try
      {
       //Firefox, Opera 8.0+, Safari
       xmlHttp=new XMLHttpRequest();
      }
     catch(e)
      {
       // MSIE
       try
        {
	 xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
       catch(e)
        {
	 try
	  {
	   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 catch(e)
	  {
	  alert("not ajax");
	   //NOT AJAX
	  }
	}
      }
     return xmlHttp;
    }

   function ajaxResponse_temp(id,user,div_id,date)
    {
     try
      {
       if(HttpHead[div_id].readyState==4)
        {
         if(HttpHead[div_id].status==200)
          {
           document.getElementById(div_id).innerHTML=HttpHead[div_id].responseText+'&deg;C';
 
        clearTimeout(t[div_id]);
 
          }
         else
          {
           document.getElementById(div_id).innerHTML='N/A&deg;C';          
 
        clearTimeout(t[div_id]);
 
          }
        }
       else
        {
        document.getElementById(div_id).innerHTML='N/A&deg;C';
 
        clearTimeout(t[div_id]);
 
        }
      }
     catch(e)
      {
       //  alert("spadlo");
      }
    }

