var xmlHttp

function mostrar()
{ 
  xmlHttp=PegarXmlHttpObject();
  if (xmlHttp==null)
  {
   alert ("Seu browser não tem suporte para AJAX!");
   return;
  } 
  var url="mostrarPonto.php";
  url=url+"?sid="+Math.random();
  xmlHttp.onreadystatechange=mudancaStatus;
  xmlHttp.open("GET",url,true);
  //xmlhttp.setrequestheader "ContentType","text/xml";
  xmlHttp.send(null);
}

function mudancaStatus() 
{ 
 //if (xmlHttp.readyState==4)
 document.getElementById("txtStatus").innerHTML = "Aguarde, buscando último ponto marcado...";
 //document.getElementById("txtStatus").value  = "Aguarde, buscando último ponto marcado...";
 if(JaPronto(xmlHttp))
 { 
   var response = xmlHttp.responseText;
   //temp1 = response.replace("ï»¿","",response);
   temp1    = response;
   //alert(temp1);
   eval(temp1);
   if(Funcionario.length > 0)
   {
    document.getElementById("digitado").value    = "";
    document.getElementById("numero").innerHTML  = "<font size='2' face='verdana' color='blue'>"+Funcionario[0].cartao+"</font>";
    document.getElementById("nome").innerHTML    = "<font size='2' face='verdana' color='blue'>"+Funcionario[0].nome+"</font>";
    document.getElementById("data").innerHTML    = "<font size='2' face='verdana' color='blue'>"+Funcionario[0].data+"</font>";
    document.getElementById("hora").innerHTML    = "<font size='2' face='verdana' color='blue'>"+Funcionario[0].hora+"</font>";
    document.getElementById("tipo").innerHTML    = "<font size='2' face='verdana' color='blue'>"+DescricaoTipo(Funcionario[0].tipo)+"</font>";
   }
   document.getElementById("txtStatus").innerHTML ="";
   document.getElementById("digitado").focus();
 }
}

function PegarXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function JaPronto(obj)
{
  if(obj.readyState == 4)
  {
    if(obj.status == 200)
    {
      return true;
    }
    else
    {
      alert("Problem retrieving XML data");
    }
  }
}

function DescricaoTipo(tipo)
{
 if(tipo=='E')
 {
   return "Entrada";
 }
 else
 {
   return "Saída";
 }
}