function nuevoAjax(){
	var xmlhttp=false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function enviaCodigo(){

  var contenedor;
  var calle;
  var numero;
  var comuna;

	contenedor = document.getElementById('resultado');
	calle= document.getElementById('calle').value;
	numero= document.getElementById('num').value;
	comuna= document.getElementById('comuna').value;

	ajax=nuevoAjax();
	contenedor.innerHTML = '<p style="text-align:center;"><img src="/av-modules/registro/proceso2.gif"/></p>'; 
	ajax.open("POST", "av-modules/microservicios/busca_zipcode/envia_codigo.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			if(ajax.responseText == 'registro') {
				abrirRegistro();
				contenedor.innerHTML = 'Para poder seguir usando los servicios aver&iacute;gualo debes registrarte. <a href="javascript:abrirRegistro();">haz click aqu&iacute;</a><br />';
			}else{
				contenedor.innerHTML = ajax.responseText;
			}
       	}
	}

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("calle="+calle+"&numero="+numero+"&comuna="+comuna)
}

