function getXMLHTTPRequest() {
var req;
try {
	req = new XMLHttpRequest();
} catch(err1) {
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (err2) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err3) {
				req = false;
			}
		}
	}
	return req;
}

http = getXMLHTTPRequest();
http2 = getXMLHTTPRequest();
http3 = getXMLHTTPRequest();

function Busca(x)
{
	/*x = x.replace(/\xE1/g,"_aacute");
	x = x.replace(/\xE9/g,"_eacute");
	x = x.replace(/\xED/g,"_iacute");
	x = x.replace(/\xF3/g,"_oacute");
	x = x.replace(/\xFA/g,"_uacute");
	x = x.replace(/\xF1/g,"_ntilde");
	x = x.replace(/\xFC/g,"_uuml");
	x = x.replace(/\xFC/g,"_uuml");*/
	x = x.replace(/\s/g,"__");
	return x
}
/*	function limpiar1(valor){
	  	for(i=valor+2;i<=6;i++){
	      document.getElementById("div_rep"+i).innerHTML="";
		}
	}
	function limpiar3(valor){
		if(valor==1){
	      document.getElementById("div_dis").innerHTML="";
	      document.getElementById("div_ccpp").innerHTML="";
	      document.getElementById("div_urb").innerHTML="";
	      document.getElementById("div_predio").innerHTML="";
		  }
		if(valor==2){
	      document.getElementById("div_ccpp").innerHTML="";
	      document.getElementById("div_urb").innerHTML="";
	      document.getElementById("div_predio").innerHTML="";
		  }
		  
		if(valor==3){
	      document.getElementById("div_urb").innerHTML="";
	      document.getElementById("div_predio").innerHTML="";
		  }
		  
		if(valor==4){
	      document.getElementById("div_predio").innerHTML="";
		  }
	}*/

function getHTTP(archivo,vars,divid){
	myRand = parseInt(Math.random()*999999999999999);
	var modurl = archivo +"?rand=" + myRand + vars; 
	modurl=Busca(modurl);
	// reeemplazar las vocales y ñ por que estan en codigo \xe1 a á
	mydiv = divid;
	http.onreadystatechange = useHTTP;
	http.open("GET", modurl, true);
	http.send(null);
}

function useHTTP() {
	if (http.readyState==1)
			document.getElementById(mydiv).innerHTML = '<br><center><img src="public/img/loading1.gif" height="20">Procesando...</center>';
	if (http.readyState == 4) {
		if(http.status == 200) {
			var miTexto = http.responseText;
			document.getElementById(mydiv).innerHTML = (miTexto);
		}
	 
	}
//	else {
//	document.getElementById(mydiv).innerHTML = 'Procesando...';
//	}
}

function getHTTP2(archivo2,vars2,divid2){
	myRand2 = parseInt(Math.random()*999999999999999);
	var modurl2 = archivo2 +"?rand2=" + myRand2 + vars2; 
	mydiv2 = divid2;
	http2.onreadystatechange = useHTTP2;
	http2.open("GET", modurl2, true);
	http2.send(null);
}

function useHTTP2() {
	if (http2.readyState==1)
			document.getElementById(mydiv2).innerHTML = '<br><center><img src="public/img/loading1.gif" height="20">Procesando...</center>';
	if (http2.readyState == 4) {
		if(http2.status == 200) {
			var miTexto2 = http2.responseText;
			document.getElementById(mydiv2).innerHTML = (miTexto2);
		}
	}
}



function getHTTP3(archivo3,vars3,divid3){
	myRand3 = parseInt(Math.random()*999999999999999);
	var modurl3 = archivo3 +"?rand3=" + myRand3 + vars3; 
	mydiv3 = divid3;
	http3.onreadystatechange = useHTTP3;
	http3.open("GET", modurl3, true);
	http3.send(null);
}

function useHTTP3() {
	if (http3.readyState==1)
			document.getElementById(mydiv3).innerHTML = '<br><center><img src="public/img/loading1.gif" height="20">Procesando...</center>';
	if (http3.readyState == 4) {
		if(http3.status == 200) {
			var miTexto3 = http3.responseText;
			document.getElementById(mydiv3).innerHTML = (miTexto3);
		}
	}
}