function TConectorAjax(_urlBase, _urlServiciosBase)
{
	
	/* 			
	0 = sin inicializar, 1 = cargando, 2 = cargado, 3 = interactivo y 4 = completado.		
	*/
	this.READY_STATE_UNINITIALIZED=0;
	this.READY_STATE_UNLOADING=1;
	this.READY_STATE_LOADED=2;
	this.READY_STATE_INTERACTIVE=3;
	this.READY_STATE_COMPLETE=4;
	
	this.LastURL=null;
	this.urlBase=_urlBase;
	this.urlServiciosBase=_urlServiciosBase;

	
	this.req=null;

	/**
	 * 
	 */
	this.Debug=function()
	{
		alai.Debug(this.req.responseText);
	} // Debug
	
	/*******************************************************************************
	* Get an XMLHttpRequest object in a portable way.
	*******************************************************************************/
	this.newRequest=function()
	{
		var _req = false;
		// For Safari, Firefox, and other non-MS browsers
		if (window.XMLHttpRequest) 
		{
			try 
			{
				_req = new XMLHttpRequest();
			} catch (e) 
			{
				_req = false;
			}
		} 
		else if (window.ActiveXObject) 
		{
		// For Internet Explorer on Windows
			try 
			{
				_req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) 
			{
				try 
				{
					_req = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e) 
				{
					_req = false;
				}
			}
		}
		  			
		this.req=_req;
		
		return this.req;
		  		
	}; // newRequest
	
	
	/******************************************************************
	* Envía la petición de forma asíncrona
	******************************************************************/
	this.sendRequestA=function(Servicio,params,funcion, ServiciosBase)
	{		

		HttpMethod="POST";

		rnd=parseInt(Math.random()*99999999);
		
		if(!ServiciosBase)
		{
			var url=this.urlBase+'/'+Servicio+'?a='+rnd;
		}
		else
		{
			var url=this.urlServiciosBase+'/'+Servicio+'?a='+rnd;
		}
						
		var req=this.newRequest();

		if(req)
		{
			this.LasLastURL=url;


			if( funcion )
			{
				req.onreadystatechange=funcion;
			}
			else
			{
				req.onreadystatechange=onReadyState;
			}

			req.open(HttpMethod, url, true);
			
			req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
			req.ContentEncoding='ISO-8859-1';
			req.Charset='ISO-8859-1';
			
			req.send(params);

			
			return req;
		}
						
	}; // sendRequestA


	/******************************************************************
	* Envía la petición de forma asíncrona
	******************************************************************/
	this.sendRequest=function(URL,funcion)
	{
		HttpMethod="POST";

		rnd=parseInt(Math.random()*99999999);
		var url=URL+'&a='+rnd;
						
		var req=this.newRequest();
	
		if(req)
		{
			this.LasLastURL=url;

			if( funcion )
			{
				req.onreadystatechange=funcion;
			}
			else
			{
				req.onreadystatechange=onReadyState;
			}
			
			req.open(HttpMethod, url, true);
			req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
			req.ContentEncoding='ISO-8859-1';
			req.Charset='ISO-8859-1';
							
			req.send();
			
			return req;
		}
						
	}; // sendRequestA




} // Clase TConectorAjax	


