// JavaScript Document
function getXMLHTTPRequest() {
	var req;
	try {
		// mayoria de navegadores
		req = new XMLHttpRequest();
	} catch(err1) {
		try {
			// versiones antiguas de microsft
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (err2) {
			try {
				// version de microsoft
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err3) {
				req = false;
			}
		}
	}
	return req;
}
http = getXMLHTTPRequest(); // crear la instancia del objeto httpRequest
http2 = getXMLHTTPRequest(); // crear la instancia del objeto httpRequest
httpNN = getXMLHTTPRequest(); // crear la instancia del objeto httpRequest

jsdiv = "";
js2div = "";

function procesar(pagina,mivars,midiv){
	var myRand = parseInt(Math.random()*999999999999999);
	var myurl = "procesos/"+pagina+".php";
	var modurl = myurl + "?"+mivars+"&varios=" + myRand;
	http.open("GET", modurl, true);
	jsdiv = midiv;
	http.onreadystatechange = useHTTPResponse; // va a llamar a la funcion hasta que termine
	http.send(null);
}

function useHTTPResponse() { // monitoriza el estado de la peticion
	if (http.readyState == 4) {
		if(http.status == 200) {
			var archivo = http.responseText;
			if( jsdiv!="conta" ){
			document.getElementById(jsdiv).innerHTML = archivo;
			}
		}

	} else {
		if( jsdiv!="conta" ){
		document.getElementById(jsdiv).innerHTML = '<img src="cargando.gif" border="0" />';
		}
	}
}

function procesar2(pagina,mivars,midiv){
	var myRand = parseInt(Math.random()*999999999999999);
	var myurl = "procesos/"+pagina+".php";
	var modurl = myurl + "?"+mivars+"&varios=" + myRand;
	http2.open("GET", modurl, true);
	js2div = midiv;
	http2.onreadystatechange = useHTTP2Response; // va a llamar a la funcion hasta que termine
	http2.send(null);
}

function useHTTP2Response() { // monitoriza el estado de la peticion
	if (http2.readyState == 4) {
		if(http2.status == 200) {
			var archivo = http2.responseText;
			if( js2div!="conta" ){
			document.getElementById(js2div).innerHTML = archivo;
			}
		}

	} else {
		if( js2div!="conta" ){
		document.getElementById(js2div).innerHTML = '<img src="cargando.gif" border="0" />';
		}
	}
}
//-------------------------------------------
function procesarNN(pagina,mivars){
	var myRand = parseInt(Math.random()*999999999999999);
	var myurl = "procesos/"+pagina+".php";
	var modurl = myurl + "?"+mivars+"&varios=" + myRand;
	httpNN.open("GET", modurl, true);
	httpNN.onreadystatechange = useHTTPnnResponse; // va a llamar a la funcion hasta que termine
	httpNN.send(null);
}

function useHTTPnnResponse() { // monitoriza el estado de la peticion
	if (httpNN.readyState == 4) {
		if(httpNN.status == 200) {
			alert(httpNN.responseText);
		}

	}
}