try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function formataCep(){
	cep = document.frmCont.txtCEP.value.replace("-","");
	query(cep);
}

function query(cep){;
	document.getElementById("imgLoad").style.display = "block";
    cload = document.getElementById("txtResp");

	var url = 'js/cep.php?cep='+cep;
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange=function() {
	    if (xmlhttp.readyState==4){
		    cload.style.display = 'block';
			cload.value = xmlhttp.responseText;
			preenche();
	    }
	}
	 xmlhttp.send(null)
}