var http_request = false;
  function EnviaPOST(url, parameters, Form) {
     http_request = false;
     if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/html');
        }
     } else if (window.ActiveXObject) {
        try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
           try {
              http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
        }
     }
     if (!http_request) {
        alert('Cannot create XMLHTTP instance');
        return false;
     }
     http_request.onreadystatechange = alertContents;
     http_request.open('POST', url, true);
     http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     http_request.setRequestHeader("Content-length", parameters.length);
     http_request.setRequestHeader("Connection", "close");
     http_request.send(parameters);
  }
  function Botao(){
      F = document.getElementById('formCad');
      F.enviar.disabled = false;
      F.enviar.value = '           Cadastrar-se >           ';
  }
  function alertContents() {
     if (http_request.readyState == 4) {
        if (http_request.status == 200) {
           result = http_request.responseText;
           if(result=='email_invalido'){
              alert('Atenção, o e-mail informado é inválido.'); Botao();
           } else if(result=='email_cadastrado'){
              alert('Atenção, o e-mail já está cadastrado no site.'); Botao();
           } else if(result=='erro'){
              alert('Erro desconhecido.');
           } else if(result=='ok'){
              location.href='?pG=X19wYWluZWw=';
           } else if(result=='ok_lista'){
              alert('Anúncio adicionado em seus favoritos.');
              location.href='?pG=X19jYXJ0';
           }
        } else {
           alert('Erro no sistema.');
        }
     }
  }

function VerificaCadastro(Form) {
     vNome = Form.nome.value;
     vEmail = Form.email.value;
     vSenha = Form.senha.value;
     vEnd = Form.endereco.value;
     vBairro = Form.bairro.value;
     vCompl = Form.compl.value;
     vCidade = Form.cidade.value;
     vUF = Form.uf.value;
     vCEP = Form.cep.value;
     vPref = Form.pref.value;
     vTel = Form.tel.value;
     var strMail =
            "nome=" +  encodeURI(vNome) +
             "&email=" + encodeURI(vEmail) +
              "&senha=" + encodeURI(vSenha) +
               "&end=" + encodeURI(vEnd) +
                "&bairro=" + encodeURI(vBairro) +
                 "&compl=" + encodeURI(vCompl) +
                  "&cidade=" + encodeURI(vCidade) +
                   "&cep=" + encodeURI(vCEP) +
                    "&tel=" + encodeURI(vTel) +
                     "&pref=" + encodeURI(vPref) +
                      "&uf=" + encodeURI(vUF);
                      EnviaPOST('__ajax/verificaCadastro.php', strMail, Form);
}

