/*************************************************************************
  Fonte: O&ESistemas Ltda.
  Descricao: - chama o programa "loginUsuario.php";
             - retorna verificacoes com alert na tela;
 *************************************************************************/
function getHTTPObject() {
  var xmlhttp;
  /*@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();
function Send( ) {
  var form = document.getElementById('FormAbertura');
  var Usuario = document.getElementById('Usuario');
  var Senha = document.getElementById('Senha');
  var form_string = "&Usuario=" + Usuario.value + "&Senha=" + Senha.value;
  http.open("POST", "loginUsuario.php", true);
  http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  http.onreadystatechange = handleHttpResponse;
  http.send(form_string);
}
function handleHttpResponse() {
  var UsuarioAbertura = document.getElementById('Usuario');
  var SenhaAbertura = document.getElementById('Senha');
  if(http.readyState!=4){ return; }
    else{
      if(http.status == 200) {
        var resul = http.responseText;
        if (resul == 1){
          UsuarioAbertura.value="";
          SenhaAbertura.value="";
          alert("Usuário ou senha incorretos !" + '\n' +"Tente novamente !");
          document.FormAbertura.Usuario.focus();
        }
        else{
          alert(""+UsuarioAbertura.value.toUpperCase()+" Bem vindo ao ControlaObra !");
          parent.frames[1].document.forms[0].elements[0].value="S";
          UsuarioAbertura.value="";
          SenhaAbertura.value="";
          MudaPagina('4','compras.php','S');
        }
      }
    }
}
function acessoUsuario() {
  alert("Link usado somente por usuários, não cadastrados ou não logados !");
}

