function XMLHTTP() {
	var axoXmlhttp=false;//ActiveXObjectXmlhttp
 	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;

	//XMLHTTP.prototype.get=get;
	XMLHTTP.prototype.get=getSincrono;
	function get (url,callbackfunc,elemento) {
		//Seria interesante pensar en una cola de peticiones, para que no se pisoteen y poder hacerlas todas con un solo objeto xmlhttp
		xmlhttp=this.xmlhttp;//Lo pasamos ha una variable para que la funcion de callback no malinterprete this.xmlhttp
		xmlhttp.open("GET", url,true);
		this.xmlhttp.onreadystatechange=callbackfunc
		xmlhttp.onreadystatechange=function() {
			//readyState pasa por todos los valores 1,2,3(Varias veces) y 4 cuando termina.
			if (xmlhttp.readyState==4) {
				callbackfunc(xmlhttp.responseText,elemento);
			}
		}
		xmlhttp.send(null)
		//return response;
	}
	
	XMLHTTP.prototype.getSincrono=getSincrono;
	function getSincrono (url,callbackfunc,elemento) {
		//setTimeout("getSincronoRetardado("+url+","+callbackfunc+","+elemento+")",100);
		//getSincronoRetardado(url,callbackfunc,elemento);
		//alert('hola ' + callbackfunc + ' ' + elemento);
		xmlhttp=this.xmlhttp;
		xmlhttp.open("GET", url,false);
		xmlhttp.send(null);
		
		if(xmlhttp.status == 200) {
			callbackfunc(xmlhttp.responseText,elemento);
		}
	}
	
	/*
	XMLHTTP.prototype.getSincronoRetardado=getSincronoRetardado;
	function getSincronoRetardado(url,callbackfunc,elemento){
		xmlhttp=this.xmlhttp;
		xmlhttp.open("GET", url,false);
		xmlhttp.send(null);
		
		if(xmlhttp.status == 200) {
			callbackfunc(xmlhttp.responseText,elemento);
		}
		
	}
	*/
	
	XMLHTTP.prototype.post=postSincrono;
	function post (url, callbackfunc, elemento, postData) {
		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, elemento);
			}
		}
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", postData.length);
		xmlhttp.send(postData);
		//return response;
	}
	XMLHTTP.prototype.postSincrono=postSincrono;
	function postSincrono (url, callbackfunc, elemento, postData) {
		xmlhttp=this.xmlhttp;
		xmlhttp.open("POST", url,false);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", postData.length);
		xmlhttp.send(postData);
		
		if(xmlhttp.status == 200) {
			callbackfunc(xmlhttp.responseText,elemento);
		}
	}

}

//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,elemento,propiedad) {
//	idObjeto=elemento
//	propiedad=propiedad;
//	//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";
//}
