function postRequest(strURL){
var xmlHttp;
if(window.XMLHttpRequest){ // For Mozilla, Safari, ...
var xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){ // For Internet Explorer
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST', strURL, true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4){
updatepage(xmlHttp.responseText);
}
}
xmlHttp.send(strURL);
}

function updatepage(str){
var cnpj = window.document.f1.cnpj.value;
var senha = window.document.f1.senha.value;
if(cnpj==""){
alert("CNPJ em branco!");
}
else if(senha==""){
alert("Senha em branco!");
}
else
{
if(str=="yes"){
var cnpj = window.document.f1.cnpj.value;
var senha = window.document.f1.senha.value;
//alert("Welcome User: " + username );
window.open('http://200.229.195.53/valeexpress/login.html?cnpj='+ cnpj + '&senha=' + senha,'_blank');
//window.open('http://174.120.14.245/valeexpress/login.html?cnpj='+ cnpj + '&senha=' + senha,'_blank');
document.getElementById('senha').value = '';

}else{
alert("CNPJ ou Senha incorreto!");
document.getElementById('senha').value = '';
}
}
}
function call_login(){
var cnpj = window.document.f1.cnpj.value;
var senha = window.document.f1.senha.value;
var url = "post.php?cnpj=" + cnpj + "&senha=" + senha ;
postRequest(url);
}
function IsNumber(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}
