var id;
var req;

function loadXMLDoc(url){
	
req = null;

if (window.XMLHttpRequest) {
 req = new XMLHttpRequest();
 req.onreadystatechange = processReqChange;
 req.open("GET", url, true); 
 req.send(null);

} else if (window.ActiveXObject) {
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP.4.0");
	} catch(e) {
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP.3.0");
	} catch(e) {
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
	try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		req = false;
	}
	}
	}
}
if (req) {
 req.onreadystatechange = processReqChange;
 req.open("GET", url, true);
 req.send();
} 

}
}


function processReqChange(){

if (req.readyState == 4) {
if (req.status == 200) {
   try {
   	document.getElementById(id).innerHTML = req.responseText;
   } catch(e) {
    document.getElementById(id).value = req.responseText;
   }
   try {
	document.getElementById(id).value = req.responseText;
   } catch(e) {
    document.getElementById(id).innerHTML = req.responseText;
   }	
	
} else {
   alert("Houve um problema ao obter os dados:\n" + req.statusText);
}
}
}

function whois(dominio,idCampo){
	id=idCampo;
	document.getElementById(id).innerHTML = "<br><strong>Aguarde, verificando disponibilidade...</strong>";
	loadXMLDoc("whois.php?dom="+dominio+"&rand="+Math.random ( ));
}

function whois_para_registro(dominio,idCampo){
	id=idCampo;
	document.getElementById(id).innerHTML = "<br><strong>Aguarde, verificando disponibilidade...</strong>";
	loadXMLDoc("whois.php?dom="+dominio+"&optRegistro=true&rand="+Math.random ( ));
}

function checkCEP(estado,cep,idCampo){
	id=idCampo;
	loadXMLDoc("cepcheck.php?estado="+estado+"&cep="+cep+"&rand="+Math.random ( ));
}

function checkDDD(estado,ddd,idCampo){
	id=idCampo;
	loadXMLDoc("dddcheck.php?estado="+estado+"&ddd="+ddd+"&rand="+Math.random ( ));
}

