function AJAX() {
	this.Updater=carregarDados;

	function carregarDados(caminhoRetorno,metodo) {

		var xmlhttp = getXmlHttp();
		//Abre a url
		xmlhttp.open(metodo.toUpperCase(), caminhoRetorno,true);
		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4){

			var texto = xmlhttp.responseText; 
			//Desfaz o urlencode
			texto=texto.replace(/\+/g," ");
			texto=unescape(texto);
			
			var itens = texto.split('&');
			for (var i=0; i<itens.length; i++) {
				var pos = itens[i].indexOf('=');
			if (pos > 0) {
			var key = itens[i].substring(0,pos);
			var val = itens[i].substring(pos+1);
			if (key == "endereco") { document.signup.endereco.value = val }
			if (key == "bairro") { document.signup.bairro.value = val }
			if (key == "cidade") { document.signup.cidade.value = val }
			if (key == "estado") {
				var tamanho = document.signup.estado.options.length;
				for (a=0; a < tamanho; a++) {
					if (document.signup.estado[a].value == val) { document.signup.estado.selectedIndex = a; } }
				}
			}
			}
			}
		}
		xmlhttp.send(null);
	}
}

function getXmlHttp() {
	var xmlhttp;
	try{ xmlhttp = new XMLHttpRequest(); } catch(ee) {
	try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {
	try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(E) {
	xmlhttp = false;
	}}}
	return xmlhttp;
}



