function creaAjax() {
         var objetoAjax=false;
         try {
          /*Para navegadores distintos a Internet Explorer*/
          objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
         } 
		 catch (e) {
		  try {
			   /*Para Internet Explorer*/
			   objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
		  }
		  catch (E) {
			objetoAjax = false;
		  }
         }

         if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
          objetoAjax = new XMLHttpRequest();
         }
         return objetoAjax;
}

function FAjax (url,capa,valores,metodo) {
		
	
        var ajax=creaAjax();
        var capaContenedora = document.getElementById(capa);

		/* variable para almacenar el mensaje que se muestra mietras ajax carga una página*/
		var cargando  = "<table border='0' align='center' cellpadding='0' cellspacing='0'>";
			cargando += "<tr><td>&nbsp;</td></tr>";
			cargando += "<tr><td align='center'>";
			cargando += "<img src='images/loading.gif' alt=''>";
			cargando += "</td></tr>";
			cargando += "<tr><td align='center'>";
			cargando += "<font face='verdana' size='1' color='#333333'>";
			cargando += "Cargando...";
			cargando += "</font>";
			cargando += "</td></tr>";
			cargando += "</table>";

		/*Crea y ejecuta la instancia si el metodo elegido es POST*/
		if(metodo.toUpperCase()=='POST'){
			 ajax.open ('POST', url, true);
			 ajax.onreadystatechange = function() {
				 if (ajax.readyState==1) {
					capaContenedora.innerHTML = cargando;
				 }
				 else if (ajax.readyState==4) {
						   if(ajax.status==200) {
								document.getElementById(capa).innerHTML=ajax.responseText;
						   }
						   else if(ajax.status==404) {
							capaContenedora.innerHTML = "<center>La direcci&oacute;n no existe</center>";
						   }
						   else {
							capaContenedora.innerHTML = "Error: ".ajax.status;
						   }
				}
	   		 }
	   		 ajax.setRequestHeader('Content-Type','multipart/form-data');
		     ajax.send(valores);			 
		     return;
		} 
		/*Crea y ejecuta la instancia si el metodo elegido es GET*/
		if (metodo.toUpperCase()=='GET'){
		
				 ajax.open ('GET', url, true);
				 ajax.onreadystatechange = function() {
				 if (ajax.readyState==1) {
					capaContenedora.innerHTML = cargando;
				 }
				 else if (ajax.readyState==4){
						   if(ajax.status==200){
							 document.getElementById(capa).innerHTML=ajax.responseText;
						   }
						   else if(ajax.status==404)
													 {
		
									capaContenedora.innerHTML = "<center>La direcci&oacute;n no existe</center>";
													 }
													 else
													 {
									capaContenedora.innerHTML = "Error: ".ajax.status;
													 }
											}
						  }
				 ajax.setRequestHeader('Content-Type','multipart/form-data');
				 ajax.send(null);
				 return
		}
}
/*

// My mini "Ajax" (DHTML) app
function PromptMe() {
	// some application vars
	var stateVar = "inicio";
	
	// the sole public method to manipulate this application
	this.promtForNew = function(nombre) {
		var newVal = nombre;
		unFocus.History.addHistory(newVal);
	};

	this.historyListener = function(historyHash) {
		stateVar = historyHash;
		document.title = "Web Oficial de Vagos Permanentes: " + historyHash;
	};
	// subscribe to unFocus.History
	unFocus.History.addEventListener('historyChange', this.historyListener);
	
	// Check for an initial value (deep link).
	// In this demo app, the historyListener can handle the task.
	this.historyListener(unFocus.History.getCurrent());
};
// instantiate and inialize the app. DOM has to be ready so we can get a ref to
// the HistoryState DOM element (aka the view), so we use QuickLoader to make
// sure it's ready.
var demoApp;

*/
