function TTajax()
{
  var getObjeto = function()
  {
  	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;
  }
  
  var queryString = function(destino, variables, aux)
  {
	var query = "destino="+destino;
	if(variables){
		for(i=0 ; i<variables.length; i++){
			query += "&"+variables[i]+"="+encodeURIComponent(document.getElementById(variables[i]).value); 
		}	
	}
	return query+aux;
  }
  
  var pintaXML = function(oDocumento)
  {
  	if(!oDocumento) return false;
  	var nodos = oDocumento.getElementsByTagName("nodo");
	for(var i=0; i<nodos.length; i++) {
  		var nodo = nodos[i];
  		switch(nodo.getElementsByTagName("accion")[0].firstChild.nodeValue){
  			case "script":
  				var script = document.createElement('script');
				script.setAttribute('type','text/javascript');
				script.text = nodo.getElementsByTagName("content")[0].firstChild.nodeValue;
				document.getElementsByTagName('head').item(0).appendChild(script);
  			break;
  			case "iframe":
  				var v_capa = nodo.getElementsByTagName("id")[0].firstChild.nodeValue.split('#');
  				var marco = document.getElementById(v_capa[0]).contentWindow;
				marco.document.getElementById(v_capa[1]).innerHTML = nodo.getElementsByTagName("content")[0].firstChild.nodeValue;
  			break;
  			case "value":
  				var valor = nodo.getElementsByTagName("id")[0].firstChild.nodeValue;
  				document.getElementById(valor).value = nodo.getElementsByTagName("content")[0].firstChild.nodeValue;
  			break;
  			default:
  				var capa = nodo.getElementsByTagName("id")[0].firstChild.nodeValue;
  				document.getElementById(capa).innerHTML = nodo.getElementsByTagName("content")[0].firstChild.nodeValue;
  			break;
  		}
	}
  	return true;
  }
  
  this.Carga = function(metodo, destino, variables, aux, server, msg, error)
  {
  	var servidor 	= getObjeto();
  	
	switch(metodo)
	{
		case 'get': 	servidor.open("GET",server+"?"+queryString(destino,variables,aux), true);	
						break;
		case 'post':
		case 'xml':		servidor.open('POST',server,true); 
						servidor.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
						break;	
	}
	
	document.getElementById(destino).innerHTML=msg;
   	servidor.onreadystatechange = function()
   	{
  		if (servidor.readyState == 4)
  		{
			if(servidor.status == 200)
			{
				switch(metodo)
				{
					case 'get':	
					case 'post':	document.getElementById(destino).innerHTML = servidor.responseText;	
									break;
					case 'xml':
									var oDocumento = servidor.responseXML;
									if(!pintaXML(oDocumento)) document.getElementById(destino).innerHTML = error;
									break;
				}
			}
			else document.getElementById(destino).innerHTML = error;
  		}
	};
	var cad = (metodo=='get') ? null : queryString(destino,variables,aux);
   	servidor.send(cad); 
   	return;	
  }
  
  this.CargaEspecial = function(mfuncion, aux, server)
  {
  	var cad 		= aux;
  	var servidor 	= getObjeto();

  	servidor.open('POST', server, true); 
	servidor.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	servidor.onreadystatechange = function()
	{
  		if (servidor.readyState == 4)
  		{
			if(servidor.status == 200)
			{
				eval(mfuncion+'(' + servidor.responseText + ')');
			}
  		}
	};
   	servidor.send(cad); 
   	return;	
  }
  
}