
	/**
	 * @author Miki
	 * @name XHConn
	 * @package ajax
	 * @version 1.0 [13/11/2006]
	 * @version 1.1 [10/09/2008]
	 * @version 1.2 [20/11/2008]
	 * @description: XHConn para realizar las peticiones AJAX
					 Además permite llamar a funciones con variables
					 para averiguar que tipos de datos recibimos
	 */
	

	function XHConn()
	{
		var xmlhttp, bComplete = false;
		
		try 
		{ 
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try			{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
				catch (e)	{ xmlhttp = false; }
			}
		}
		
		if (!xmlhttp) return null;
		
		// Peticiones 
		
		this.peticionAjax = function(sURL, sMethod, sVars, fnDone, variables, idAjax)
		{
			if (!xmlhttp) return false;
			
			var bComplete = false;
			sMethod = sMethod.toUpperCase();
			
			try 
			{		  
				if (sMethod == "GET")
				{
					xmlhttp.open(sMethod, sURL+"?"+sVars, true);
					sVars = "";
				}
				else
				{
					xmlhttp.open(sMethod, sURL, true);
					xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
					xmlhttp.setRequestHeader("Content-Type",
				      "application/x-www-form-urlencoded");
				}
				
				xmlhttp.onreadystatechange = function()
				{
					if ( xmlhttp.readyState == 4 && !bComplete )
					{
						bComplete = true;
					
				  		fnDone(xmlhttp, variables, idAjax);
					}
				};
				
				xmlhttp.send(sVars);
			}
			catch(z) { return false; }
			
			return true;
		};
	}
	
