// JavaScript Document

function f1getObjectHttp(){
		var f1xmlObjTemp = null;
		
      if(window.XMLHttpRequest){
          f1xmlObjTemp = new XMLHttpRequest();
      } else if(window.ActiveXObject){
          f1xmlObjTemp = new ActiveXObject("Microsoft.XMLHTTP");
      } 
        return (f1xmlObjTemp);		
	}

	
	
function f1ajaxReadRemote(pUrl,pExecExterno){
      
	  var f1mlObj = f1getObjectHttp();
	  
       if(f1mlObj !=null ){
		   
      f1mlObj.onreadystatechange = function(){
        if(f1mlObj.readyState == 4){
         eval(pExecExterno); // la procesa otra funcion dinamica
        }
      }
	  
	  // random obliga a hacer la consulta del pUrl
      f1mlObj.open ('GET', pUrl+"&randvar="+Math.random()*47, true);
      f1mlObj.send ('');
	   }
    }

function f1ajaxSendPost(pUrl,pFormValues,pDivCurrent,pDivMain){
      
	  var f1mlObj = f1getObjectHttp();
	  
	   
			
      if (f1mlObj) {
		  if (f1mlObj.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            f1mlObj.overrideMimeType('text/html');
         }

        f1mlObj.onreadystatechange =  function(){
			
           if (f1mlObj.readyState == 4) {
        	if (f1mlObj.status == 200) {
			 	  if(f1mlObj.responseText.length>0){
				   document.getElementById (pDivCurrent).innerHTML =f1mlObj.responseText;
				  } else{document.getElementById (pDivCurrent).innerHTML = "Error: "+"<br>"+f1ajaxCerrar(pDivCurrent,pDivMain);
			  }
	        }else if(f1mlObj.status==404){
           document.getElementById (pDivCurrent).innerHTML ="La direccion no existe" + "<br>"+f1ajaxCerrar(pDivCurrent,pDivMain);
          }else{
           document.getElementById (pDivCurrent).innerHTML = "Error: "+f1mlObj.status+"<br>"+f1ajaxCerrar(pDivCurrent,pDivMain);
          } 
		
	  	  } else {
          document.getElementById (pDivCurrent).innerHTML ="<br>"+f1ajaxCargador(pDivCurrent,pDivMain);
		 }
			
			
			 

			
          }
	  

          f1mlObj.open('POST', pUrl, true);
          f1mlObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          f1mlObj.setRequestHeader("Content-length", pFormValues.length);
          f1mlObj.setRequestHeader("Connection", "close");
          f1mlObj.send(pFormValues);


    }

    }

	
	
 function f1ajaxReadSimple(pUrl,pDiv,pDivMain){
      
	  var f1mlObj = f1getObjectHttp();
	  
       if(f1mlObj !=null ){
		   
      f1mlObj.onreadystatechange = function(){
        if(f1mlObj.readyState == 4){
  		  if (f1mlObj.status == 200) {
			  if(f1mlObj.responseText.length>0){
               document.getElementById (pDiv).innerHTML =f1mlObj.responseText;}
			  else{document.getElementById (pDiv).innerHTML = "Error: "+"<br>"+f1ajaxCerrar(pDiv,pDivMain);
			  } 
             
	      }else if(f1mlObj.status==404){
           document.getElementById (pDiv).innerHTML ="La direccion no existe" + "<br>"+f1ajaxCerrar(pDiv,pDivMain);
          }else{
           document.getElementById (pDiv).innerHTML = "Error: "+f1mlObj.status+"<br>"+f1ajaxCerrar(pDiv,pDivMain);
          } 
		
	  	  } else {
          document.getElementById (pDiv).innerHTML ="<br>"+f1ajaxCargador(pDiv,pDivMain);
		 }
		
		
		
      }
	  // random obliga a hacer la consulta del pUrl
      f1mlObj.open ('GET', pUrl+"&randvar="+Math.random()*47, true);
      f1mlObj.send ('');
	   }
    }

function f1ajaxCargador(pDivCurrent,pDivMain){
	var Regreso="";
	 Regreso="Cargando..";
	
   return Regreso;
}

function f1ajaxCerrar(pDiv,pDivMain){
	var Regreso="";
	  Regreso="Error";
 return Regreso;
}

