// Define variável global
var xmlhttp;

function __enviaContato(varFormc) {

// Define variáveis
var varnome;  
var varemail;  

// Atribui valores as variáveis
varnome  = escape(varFormc.nome.value);
varemail = escape(varFormc.email.value); 

    // Instancia o objeto, dependendo do navagador
    if (window.XMLHttpRequest) {
 xmlhttp = new XMLHttpRequest();  
    } else if (window.ActiveXObject) {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  
    } else {
 alert("Seu navegador n&atilde;o suporta XMLHttpRequest.");
 return;
    }

   xmlhttp.open("POST", "cad.php", true);    

   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
   xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
   xmlhttp.setRequestHeader("Pragma", "no-cache");
   
    xmlhttp.onreadystatechange = processReqChange;

   xmlhttp.send("nome=" + varnome + "&email=" + varemail );
}


function processReqChange() {

    document.getElementById('resposta').innerHTML = "OK";
   if (xmlhttp.readyState == 4) {    
 if (xmlhttp.status == 200) {
     if(xmlhttp.responseText == 1) {
      document.getElementById("resposta").innerHTML = "Cadastro Realizado Com Sucesso!";
      document.forms[0].reset();
   window.location.href = "javascript:carregaAjax('destino','ok.php')";    // Redireciona para uma pagina....
     } else
   document.getElementById("resposta").innerHTML = xmlhttp.responseText;
     
       } else {
           alert("Problemas ao carregar o arquivo.");
       }
   }

}