function processaCep(nCep) {
	try {
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex) {
			try {
				ajax = new XMLHttpRequest();
			}
			catch (exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}

	if(ajax) {
		ajax.open("POST", "processaXmlCep.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			if(ajax.readyState == 4 ) {
				if(ajax.responseXML) {
					processXML(ajax.responseXML);
				}
			}
		}

		var params = "nCep=" + nCep;
		ajax.send(params);
	}
}

function processXML(obj){
	var dataArray = obj.getElementsByTagName("webservicecep");

	if(dataArray.length > 0) {
		for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];
			var sUf = item.getElementsByTagName("uf")[0].firstChild.nodeValue;
			var sCidade = item.getElementsByTagName("cidade")[0].firstChild.nodeValue;
			var sBairro = item.getElementsByTagName("bairro")[0].firstChild.nodeValue;
			var sTipoLogradouro = item.getElementsByTagName("tipo_logradouro")[0].firstChild.nodeValue;
			var sLogradouro = item.getElementsByTagName("logradouro")[0].firstChild.nodeValue;
		}
	}

	document.formCadastro.fEnd.value = sTipoLogradouro + " " + sLogradouro;
	document.formCadastro.fCidade.value = sCidade;
	document.formCadastro.fBairro.value = sBairro;
	document.formCadastro.fEstado.value = sUf;
}