// JavaScript Document

var xmlHttp
function ajax_login_front()
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var login = document.getElementById('login').value;
var senha = document.getElementById('senha').value;

var page="verifica_login.php"
page=page+"?senha="+senha+"&login="+login
page=page+"&sid="+Math.random()
xmlHttp.onreadystatechange=mostra_status
xmlHttp.open("GET",page,true)
xmlHttp.send("")

}

function checkLogin()
{
 if (xmlHttp.responseText == "logado")
  {
  alert('Seja Bem vindo');
  window.location='clientes/principal.php';
 } 
  else if(xmlHttp.responseText == "logado2")
  {
  alert('Seja Bem vindo');
  window.location='../clientes/principal.php';
 }
 else if(xmlHttp.responseText == "nao ativo")
  {
  alert('Cadastro Não Ativo');
 }
 else
 {
 alert('Dados Invalidos');
 }
 }

function mostra_status() 

{ 
if(xmlHttp.readyState == 1) { // Quando estiver carregando, exibe uma camada: Carregando...
document.getElementById('inf').style.visibility="visible";
}
if(xmlHttp.readyState == 4||xmlHttp.readyState=="Complete")
{ 
document.getElementById('inf').style.visibility="hidden";
checkLogin();
}

}
function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 