
	function createRequestObject() 
	{
	    try {
	        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	        try {
	            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (E) {
	            xmlhttp = false;
	        }
	    }
	    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	        xmlhttp = new XMLHttpRequest();
	    }
	    return xmlhttp;
	}
	
	function sendRequest() 
	{
		_http = this.http;
		_capa = this.capa;
		
		// efecto actualizando
		document.getElementById(_capa).innerHTML = this.processing_message;
	
			
	   // Open PHP script for requests
	   _http.open('post', this.accion, true);
	   _http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   _http.onreadystatechange = function() {
	   		
			if( _http.readyState == 4 )
			{ 
				if( _http.status == 200 )
				{
					// Text returned FROM the PHP script
					var response = _http.responseText;
					
					if(response) 
					{
						// UPDATE ajaxTest content
						document.getElementById(_capa).innerHTML = response;
					}
				}
				else
				{
					document.getElementById(_capa).innerHTML = "Error: "._http.status;
				}
			}
		}
	
	   _http.send(this.variables);
	
	}
	
	// clase ajax
	function CAjax(accion, variables, capa, processing_message)
	{
	// atributos
	
		this.http = createRequestObject();
		this.accion = accion;
		this.variables = variables;
		this.capa = capa;
		this.processing_message = processing_message;
	
	
	// metodos
	
		this.procesa = sendRequest;
	}
	
	
	// crea un objeto ajax y lo ejecuta
	
	function goAjax(accion, variables, capa, processing_message)
	{	
		oAjax = new CAjax(accion, variables, capa, processing_message);
		oAjax.procesa();
	}
