function Logout() {
   document.frmLogin.eMailLogin.value = "";
   document.frmLogin.SenhaLogin.value = "";
   document.getElementById("erroLOGINSOMBRA").style.display = "block"; 
   document.getElementById("erroLOGIN").style.display = "block"; 
   document.getElementById("erroLOGIN").innerHTML = "<table cellspacing='0' style='width: 159px; height: 52px;' cellpadding='0' border='0'><tr><td align='center' valign='middle'><font color='#000000'><img align='middle' src='/images/loading2.gif' alt='' /> aguarde, efetuando logout ...<br /></font></td></tr></table>";
   location.href="/logout.asp";
}

timerID = "";

function Login() {
   clearTimeout(timerID);
   eMail = document.frmLogin.eMailLogin.value;
   Senha = document.frmLogin.SenhaLogin.value;   
   document.getElementById("erroLOGINSOMBRA").style.display = "block"; 
   document.getElementById("erroLOGIN").style.display = "block";
   document.getElementById("erroLOGIN").innerHTML = "<table cellspacing='0' style='width: 159px; height: 52px;' cellpadding='0' border='0'><tr><td align='center' valign='middle'><font color='#000000'><table style='margin-top: 9px;' cellspacing='1' cellpadding='1'><tr><td><img src='/images/loading2.gif' alt='' /></td><td align='center'>aguarde,<br />efetuando login!</td></tr></table><br /></font></td></tr></table>";   
   if ((eMail.length > 0) && (Senha.length > 0)) {   
      ajax2 = ajaxInit();
      resultado = "";
      if (ajax2) {
         ajax2.open("GET", "/login.asp?eMail=" + eMail + "&Senha=" + Senha, true);
         ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
         ajax2.onreadystatechange = function() {
            if(ajax2.readyState == 4) {
               if(ajax2.status == 200) {
                  resultado = ajax2.responseText;
				  splitResultado = resultado.split("|");
                  if (splitResultado[0] == "1") {
                     //document.getElementById("erroLOGIN").style.display = "block"; 
 			         //document.getElementById("erroLOGIN").innerHTML = "<font color='#55BA1D'>Login efetuado com sucesso!</font>";
                     //document.getElementById("camposLogin").style.display = "none";  
					 //document.getElementById("camposLogin2").innerHTML = "<div style='text-align: left; border: 0px solid; float: left; width: 330px;'><div style='border: 0px solid; width: 310px; font-size: 11px; margin-top: 8px; margin-left: 15px; text-align: left;' id='dadosLogin'>Olá, <b>" + splitResultado[1] + "</b>.</div><div style='border: 0px solid; width: 310px; font-size: 11px; margin-top: 0px; margin-left: 15px; text-align: left;' id='dadosLogin2'>Caso queira acessar a sua conta, <a href='minhaconta.asp'>clique aqui</a>.</div></div><div style='right: left; margin-top: 12px; margin-left: 0px;'><input onclick='Logout();' class='botao2' type='Button' value='SAIR' /></div>"; 					 
                     //document.getElementById("camposLogin2").style.display = "block"; 
                     location.href="/minhaconta.asp?Status=OK";
			      } else if (splitResultado[0] == "2") {
			         document.getElementById("erroLOGINSOMBRA").style.display = "block"; 
                     document.getElementById("erroLOGIN").style.display = "block"; 
 			         document.getElementById("erroLOGIN").innerHTML = "<table cellspacing='0' style='width: 159px; height: 52px;' cellpadding='0' border='0'><tr><td align='center' valign='middle'><font color='#EB1C24'>e-Mail ainda é<br />inativo no site!</font></td></tr></table>";
				  } else {	   
				     document.getElementById("erroLOGINSOMBRA").style.display = "block"; 
                     document.getElementById("erroLOGIN").style.display = "block"; 
 			         document.getElementById("erroLOGIN").innerHTML = "<table cellspacing='0' style='width: 159px; height: 52px;' cellpadding='0' border='0'><tr><td align='center' valign='middle'><font color='#EB1C24'>e-Mail e/ou Senha<br />inválidos!</font></td></tr></table>";
				  }	   
               } else {
                  document.getElementById("erroLOGINSOMBRA").style.display = "block"; 
                  document.getElementById("erroLOGIN").style.display = "block"; 
			      //timerID = setTimeout("LimpaAviso()",2000);    					 				  
			   }
			}    
         }
         ajax2.send(null);
      }  
   } else {
      document.getElementById("erroLOGINSOMBRA").style.display = "block"; 
      document.getElementById("erroLOGIN").style.display = "block"; 
      document.getElementById("erroLOGIN").innerHTML = "<table cellspacing='0' style='width: 159px; height: 52px;' cellpadding='0' border='0'><tr><td align='center' valign='middle'><font color='#EB1C24'>e-Mail e/ou Senha<br />inválidos!</font></td></tr></table>";
      //timerID = setTimeout("LimpaAviso()",2000);	  					 				  	  
   }
}

function LimpaAviso() {
   document.getElementById("erroLOGINSOMBRA").style.display = "none"; 
   document.getElementById("erroLOGIN").style.display = "none"; 
   document.getElementById("erroLOGIN").innerHTML = "";   
}
