
var Retrieve_seleccion_xmlHttp=null;
var Retrieve_interaccion_xmlHttp=null;

// Documento JavaScript
// Esta función cargará las paginas

var isSent = false;

function GetXmlHttpObject(handler)
{
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    //alert (objXMLHttp);
    return objXMLHttp
}

function llamarasincrono (url, id_contenedor)
{
	
		 Retrieve_seleccion_htmlData(id_contenedor,url, function(){
	      if (Retrieve_seleccion_xmlHttp.readyState==4 || Retrieve_seleccion_xmlHttp.readyState=="complete")
      		{
      		document.getElementById(id_contenedor).innerHTML= Retrieve_seleccion_xmlHttp.responseText;		
			 }			
    		});	
}

function llamarasincronoConFade (url, id_contenedor)
{
	
		 Retrieve_seleccion_htmlData(id_contenedor,url, function(){
	      if (Retrieve_seleccion_xmlHttp.readyState==4 || Retrieve_seleccion_xmlHttp.readyState=="complete")
      		{
      		document.getElementById(id_contenedor).innerHTML= Retrieve_seleccion_xmlHttp.responseText;		
	 	    	$('#portfolio').innerfade({ speed: 'slow', timeout: 7000, type: 'sequence', containerheight: '303px' }); 
			 }			
    		});	
}

function llamarasincronof (url, id_contenedor, funcionterminacion)
{
		 Retrieve_seleccion_htmlData(id_contenedor,url, function(){
	      if (Retrieve_seleccion_xmlHttp.readyState==4 || Retrieve_seleccion_xmlHttp.readyState=="complete")
			 document.getElementById(id_contenedor).innerHTML= Retrieve_seleccion_xmlHttp.responseText;
			 funcionterminacion();
	// 	     stopLoadingTimer();
			 });	
}

function llamarasincrono2 (url, id_contenedor, url2, id_contenedor2)
{
		// startLoadingTimer();
		 Retrieve_seleccion_htmlData("tempdiv", url2, function(){
	      if (Retrieve_seleccion_xmlHttp.readyState==4 || Retrieve_seleccion_xmlHttp.readyState=="complete")
	      {		     
			 document.getElementById("tempdiv").innerHTML= Retrieve_seleccion_xmlHttp.responseText;			
	 	    llamarasincronof(url, id_contenedor, function(){
		 	    document.getElementById(id_contenedor2).innerHTML = document.getElementById("tempdiv").innerHTML;
		 	    	$('#portfolio').innerfade({ speed: 'slow', timeout: 7000, type: 'sequence', containerheight: '303px' }); 
		 	    });    
 	     }
    	});	
}

function Retrieve_seleccion_stateChanged(destino)
{
    if (Retrieve_seleccion_xmlHttp.readyState==4 || Retrieve_seleccion_xmlHttp.readyState=="complete")    
		 document.getElementById(destino).innerHTML= Retrieve_seleccion_xmlHttp.responseText;
}

// Will populate data based on input
function Retrieve_seleccion_htmlData(destino,url, funcion)
{
   	//alert(qStr);
    if (url.length==0)
    {
        document.getElementById(destino).innerHTML=""; 
        return;
    }

    if(Retrieve_seleccion_xmlHttp!=null) Retrieve_seleccion_xmlHttp.abort();

    Retrieve_seleccion_xmlHttp=GetXmlHttpObject()
    if (Retrieve_seleccion_xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    if(url.indexOf('?')==-1)
    {
	    url=url+"?sid="+Math.random();	 
    }
    else
    {
	    url=url+"&sid="+Math.random();	 	    
    }
   
    Retrieve_seleccion_xmlHttp.onreadystatechange=funcion
    
    Retrieve_seleccion_xmlHttp.open("GET",url,true) ;
    Retrieve_seleccion_xmlHttp.send(null);
}


function getRemoteValue(url)
{
    if(Retrieve_seleccion_xmlHttp!=null) Retrieve_seleccion_xmlHttp.abort();

    Retrieve_seleccion_xmlHttp=GetXmlHttpObject()
    if (Retrieve_seleccion_xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    if(url.indexOf('?')==-1)
    {
	    url=url+"?sid="+Math.random();	 
    }
    else
    {
	    url=url+"&sid="+Math.random();	 	    
    }
   
    Retrieve_seleccion_xmlHttp.open("GET",url,false) ;
    Retrieve_seleccion_xmlHttp.send(null);
   return Retrieve_seleccion_xmlHttp.responseText;

}

