var objHTTP=new clsHTTP();

function clsHTTP() {
	try {
		if(top.XMLHttpRequest)
			this.objHttpReq			=	new top.XMLHttpRequest();
		else
			this.objHttpReq		=	new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
//		alert("No se pudo iniciar el componente de comunicación. Navegador no soportado.");
		return null;
	}
	this.blnXML					=	true;
	this.blnAsync				=	false;
	this.strURL					=	null;
//	this.objHttpReq.objParent	=	this;
	this.get					=	clsHTTP_get;
	this.onReadyStateChange		=	clsHTTP_onReadyStateChange;
	this.onLoadComplete0		=	clsHTTP_onLoadComplete0;
	this.onLoadComplete			=	null;
	this.loadSelect				=	clsHTTP_loadSelect;
	this.resetParameters		=	clsHTTP_resetParameters;
	this.addParameter			=	clsHTTP_addParameter;
	this.resetParameters();
}
function clsHTTP_resetParameters() {
	this.strParameters		=	"";
}
function clsHTTP_addParameter(pstrName, pstrValue) {
	if(this.strParameters!="")
		this.strParameters+="&";
	this.strParameters+=pstrName+"="+escape(pstrValue);
}
function clsHTTP_get(pstrURL, pblnAsync, pblnXML) {
	if(pstrURL	!==undefined)	this.strURL		=	pstrURL;
	if(pblnAsync!==undefined)	this.blnAsync	=	pblnAsync;
	if(pblnXML	!==undefined)	this.blnXML		=	pblnXML;
	strParameters=this.strParameters;
//alert(strParameters);
	this.resetParameters();
	this.objHttpReq.open("GET",this.strURL+"?"+strParameters,this.blnAsync);
	if(this.blnAsync)
		this.objHttpReq.onreadystatechange = this.onReadyStateChange;
/*		this.objHttpReq.onreadystatechange = function () {
			if(this.objHttpReq.readyState==4 && this.objHttpReq.status == 200)
				this.onLoadComplete0();
		};	*/
/*		this.objHttpReq.onreadystatechange = function () {
			if(this.readyState==4 && this.status == 200)
				this.onLoadComplete0();
		};	*/
	this.objHttpReq.send("");
	if(!this.blnAsync)
		this.onLoadComplete0();
}
function clsHTTP_onReadyStateChange() {
//	0 - Sin inicializar, siempre será: 
//	1 - Abierto (acaba de llamar open) 
//	2 - Enviado 
//	3 - Recibiendo 
//	4 - A punto
	if(this.readyState==4 && this.status==200) {
		objHTTP.onLoadComplete0();
//		this.objParent.onLoadComplete0();
	}
}
function clsHTTP_onLoadComplete0() {
	this.objXML		=	null;
	this.strText	=	this.objHttpReq.responseText;
	if(this.blnXML && this.objHttpReq.responseXML!=null)
		this.objXML	=	this.objHttpReq.responseXML.documentElement;
	if(this.onLoadComplete!=null)
		this.onLoadComplete();
}
function clsHTTP_loadSelect(pobjSelect, pobjXML, pstrRowTag, paColTags) {
	while(pobjSelect.options.length>1)
		pobjSelect.options[pobjSelect.options.length-1]=null;
	if(pobjXML!=null)
		for(var lintRow=0; lintRow<pobjXML.getElementsByTagName(pstrRowTag).length; lintRow++) {
			lobjNode		=	pobjXML.getElementsByTagName(pstrRowTag)[lintRow];
			lobjNodeID		=	lobjNode.getElementsByTagName(paColTags[0])[0];
			lobjNodeValue	=	lobjNode.getElementsByTagName(paColTags[1])[0];
			lobjOption=new Option(lobjNodeValue.firstChild.data, lobjNodeID.firstChild.data);
			pobjSelect.options[pobjSelect.options.length]=lobjOption;
//			pobjSelect.options[lintRow]=lobjOption;
		}
}
