//Clase xmlhttp
function XMLHTTP() {
	var axoXmlhttp=false;//ActiveXObject Xmlhttp
 	try {
		axoXmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
 		try {
 			axoXmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			axoXmlhttp = false;
 		}
  	}

	if (!axoXmlhttp && typeof XMLHttpRequest!='undefined') {
 		axoXmlhttp = new XMLHttpRequest();
	}
	
	this.xmlhttp=axoXmlhttp;
	this.get=get;
	
	function get (url, callbackfunc) {
		xmlhttp=this.xmlhttp;//Lo pasamos ha una varialbe para que la funcion de callback no malinterprete this.xmlhttp
		xmlhttp.open("GET", url,true);
		this.xmlhttp.onreadystatechange=callbackfunc
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				callbackfunc(xmlhttp.responseText);
			}
		}
		xmlhttp.send(null)
		//return response;
	}
	
	//getSincrono está sin probar
	function getSincrono (url) {
		xmlhttp=this.xmlhttp;
		xmlhttp.open("GET", url,true);
		xmlhttp.send(null)//<- Al no estar definido onreadystatechange el JS se queda aqui hasta que vuelva la respuesta del server
		
		if(xmlhttp.status == 200) {
			var xmldoc = xmlhttp.responseXML;
			var ajaxValue = xmldoc.getElementsByTagName("Root")[0].childNodes[0].nodeValue;
			if (ajaxValue == "0") {
				alert("DCL " + validatingDCL + " is invalid.");
				setTimeout("originalField.select()", 5); 
			}
		}
	}
	
	function post (url, callbackfunc, arrDatos) {
		xmlhttp=this.xmlhttp;//Lo pasamos ha una varialbe para que la funcion de callback no malinterprete this.xmlhttp
		xmlhttp.open("POST", url,true);
		this.xmlhttp.onreadystatechange=callbackfunc
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				callbackfunc(xmlhttp.responseText);
			}
		}
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send("t1="+t1+"&t2="+t2)
		//return response;
	}

}

//Codigo de prueba
//var objXmlhttp=new XMLHTTP();
//alert (objXmlhttp.xmlhttp);
//objXmlhttp.get ("./verPeticion.php",asignar);


//6 callbacks estandar, como los de xajax, a saber
//asignar (idObjeto, propiedad, valor)
//ponerDelante (idObjeto, propiedad, valor)
//ponerDetras (idObjeto, propiedad, valor)
//buscarYReemplazar (idObjeto, propiedad, aguja, pajar)
//ejecutarCodigo (script)
//alert (mensjae)

function asignar(response) {
	idObjeto="div"
	propiedad="innerHTML";
	//propiedad="style.backgroundColor";
	valor=response
	valor="#FF0000";
	//document.getElementById(idObjeto).propiedad=valor;
	objeto=document.getElementById(idObjeto)
	objeto[propiedad]=valor;
	//document.getElementById(idObjeto).style.backgroundColor="#00FF00";
}