
var xmlHttp;
var xmlHttp2;
function login(user,senha2)
{ 
   var url="login.php?login=1&user="+user+"&senha2="+senha2;
   xmlHttp=GetXmlHttpObject(window.stateChanged)
   xmlHttp.open("GET", url , true)
   xmlHttp.setRequestHeader("Cache-Control", "no-cache");
   xmlHttp.setRequestHeader("Pragma", "no-cache");
   xmlHttp.send(null)
} 

function recu_senha(rec_senha)
{ 
   if(rec_senha!="")
   {
      var url="login.php?rec_senha="+rec_senha;
      xmlHttp2=GetXmlHttpObject(window.stateChanged2)
      xmlHttp2.open("GET", url , true)
      xmlHttp2.setRequestHeader("Cache-Control", "no-cache");
      xmlHttp2.setRequestHeader("Pragma", "no-cache");
      xmlHttp2.send(null);
   }else
   {
      document.getElementById("display").innerHTML="Digite seu Nome e tente novamente.";
   }
} 

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
} 

function stateChanged() 
{ 
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
	  if(xmlHttp.responseText=="ok")
	  {
         document.getElementById("display").innerHTML="Acesso Autorizado. Acessando o sistema...";
         document.location.href='index.php';
      }else if(xmlHttp.responseText=="no")
	  {
		 document.getElementById("display").innerHTML="Acesso não autorizado. Tente novamente";
         document.form_login.senha2.value="";
         document.form_login.senha2.focus();
	  }else
	  {
		 document.getElementById("display").innerHTML="Sistema em Manutenção. Tente novamente mais tarde";
	  } 
   }else
   {
      document.getElementById("display").innerHTML="Verificando Usuário e Senha...";
   }
}

function stateChanged2() 
{ 

   if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
   { 
	  if(xmlHttp2.responseText=="ok")
	  {
         document.getElementById("display").innerHTML="A senha foi enviada para o seu e-mail";
         document.form_login.senha2.value="";
         document.form_login.senha2.focus();
      }else if(xmlHttp2.responseText=="no")
	  {
		 document.getElementById("display").innerHTML="Usuário não encontrado. Tente novamente" ;
         document.form_login.senha2.value="";
         document.form_login.user.value="";
         document.form_login.user.focus();
	  }else
	  {
		 document.getElementById("display").innerHTML="Sistema em Manutenção. Tente novamente mais tarde" ;
         document.form_login.senha2.value="";
         document.form_login.user.value="";
         document.form_login.user.focus();
	  }
   }else
   {
      document.getElementById("display").innerHTML="Verificando...";
   }
} 
