
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}


//**************************************************************
//clase hAjax
	function sendData(readyFunction)
	{
		if (!this.isWorking && this.http) 
		{
			if(this.params.length > 0)
			{				
				
				var txt = new String();
				
				for(var a = 0; a < this.params.length; a++){
					if(a == 0){
						txt += encodeURIComponent(this.params[a].nombre)+'='+encodeURIComponent(this.params[a].valor);
					}else{
			  			txt += '&'+encodeURIComponent(this.params[a].nombre)+'='+encodeURIComponent(this.params[a].valor);
					}
				}
				
				this.http.open("POST", this.url, true);
			   	this.http.onreadystatechange = readyFunction;
			   	
				this.http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				
			    this.isWorking = true;
			    this.http.send(txt);
			    
			    this.clearVar();
			    
			    return true;
			}else{
				this.err = 'Parametros invalidos';	
			}
		}else{
			this.err = 'Por favor espere';	
		}
		
		return false;
	}
	
	
	function setVar(nombre,valor){
		mvar = new hVars(nombre,valor);
		this.params.push(mvar);	
	}
	
	
	function clearVar(){
		for(var i; i < this.params.length; i++){
			this.params.pop();
		}	
	}
	

	function hAjax(url)
	{
		this.url = url;
		this.isWorking = false;
		this.http = getHTTPObject();
		
		this.params = new Array();	
		this.err = '';
		
		this.sendData = sendData;
		this.clearVar = clearVar;
		this.setVar = setVar;
	}
//**************************************************************

function hVars(nombre,valor){
	this.nombre = nombre;
	this.valor = valor;	
}