function nuevoAjax(xmlhttp){

   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 CargaAjax(pagina,destino,tipo){
   var ajax;
   var contenedor;
   
  var contenedor = document.getElementById(destino);
   ajax = nuevoAjax(ajax);
   ajax.open("GET", pagina, true);
   ajax.onreadystatechange=function() {
      
	  if(ajax.readyState == 1) { 				 		
				
				if(tipo == 1) {  //Reporte
				
				contenedor.innerHTML = ' <center><br /> <img src="../img/loading.gif" border="0" alt="..." /></center>';
				}
				
			
	  }
	  
	  
	  if (ajax.readyState==4) {
     
	 				contenedor.innerHTML = ajax.responseText;
			
      /*
	  			    	var scs=ajax.responseText.extractScript();    //capturamos los scripts
						contenedor.innerHTML=ajax.responseText;
						scs.evalScript();       //ahora si, comenzamos a interpretar todo  
	 */}
   }
   ajax.send(null);
 return ajax.readyState;
}
