/*--=============================================================================================================
Ag. Dotes - Otimizando seus dons - http://www.dotes.com.br - +55(62)3514.1227 | url: http://www.tudoin.com.br  
Criado por : Luiz Jr. Fernandes | email: contato@dotes.com.br / luizbox@msn.com
=============================================================================================================-*/
//Abre uma janela centralizada na tela, com base em seu tamanho
function Abrir(sUrl, iWidth, iHeight){
	var newWin = window.open( sUrl, 'popup', 'scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, copyhistory=no, height='+iHeight+', width='+iWidth+', top='+(screen.height - iHeight)/2+', left='+(screen.width - iWidth)/2);
}
var url = "../functions/valida_logon.php?user="; // The server-side script

var isWorking = false;


function handleHttpResponse(){  

 if (http.readyState == 4) {    
  results = http.responseText.split("|"); 
  if (results[0] == 0){
  	  document.getElementById("resp").innerHTML = "Erro de autenticação!"
	}
	  if (results[0] == 1){
	  document.getElementById("resp").innerHTML = "Redirecionando...";
  	  document.location = "../"+results[1];   
	}
	
			}
	}		

function valida_logon() {
  if (!isWorking && http) {
  var user= document.forms[0].bl_user.value;
  var pass= document.forms[0].bl_pass.value;
  http.open("GET", url + escape(user) + "&pass=" + escape(pass), true);
  http.onreadystatechange = handleHttpResponse;
 // isWorking = true;
  http.send(null);
  document.getElementById("resp").innerHTML = "Aguarde...";
 }
}

function getHTTPObject() {
  var xmlhttp;
 // XMLHTTP.setRequestHeader ("encoding", "ISO-8859-1");
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
	
      xmlhttp = new XMLHttpRequest();
	  
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
