﻿function MuestraEjemplar(IdElemento,url,parametro)
{
    var R = new NewHttpReq();
    var E=document.getElementById("zona");
    var M=document.getElementById("menu");
    var bPanel=false;
	E.innerHTML='<img src="images/cargando.gif" border="0" /> Cargando..';	
    if (IdElemento=="panel")
    {   bPanel=true;
        str="";}
    else
    {	if (IdElemento!="13")
	        str="P="+parametro;
	    else
	        str="F="+parametro;	}
	        
	R.open("POST",url, true);       
    R.setRequestHeader('Content-Type','application/x-www-form-urlencoded');//necesario para el metodo POST
    R.setRequestHeader("Charset", "ISO-8859-1");               
    R.send(str); //Para el metodo POST
    
    R.onreadystatechange = function()
    {
        // Si R esta completado
        if (R.readyState != 4) return; // Si hay algún error
    
        // Si es "OK"
        //if (R.status == 200)
        //{
        // ...Procesando, pintamos en el div...
        var div;
        div=R.responseXML.xml;
        if(div==null || div=="")
            div=R.responseText;	

        E.innerHTML=div;        

        if (bPanel)
        {            
            var oInput=document.getElementsByTagName("input")            
            for (var i=0;i<oInput.length;i++)
            {
                if (oInput[i].type=="hidden" && oInput[i].id.substring(0,9)=="accionPEX")
                {
                    var sDato=oInput[i].value;
                    var oDato=sDato.substring(0,sDato.indexOf("t"));
                    var oTipo=sDato.substring(sDato.indexOf("t")+1,sDato.length);
                    var oDiv=document.getElementById("panelPEX"+oDato);
                    
                    oDiv.innerHTML='<img src="images/cargando.gif" border="0" /> Cargando..';
                    sDato="D="+sDato;
                                       
                    var oHttp = new NewHttpReq();
                    oHttp.open("POST","panel.asp",false);       
                    oHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                    oHttp.setRequestHeader("Charset", "ISO-8859-1");
                                     
                    oHttp.onreadystatechange =  function()
                    {                  
                        ProcesoPanel(oHttp,oDiv,oTipo);
                    }
                    oHttp.send(sDato);                                        
                }
            }
        }
        if (M.offsetHeight<E.offsetHeight)
            M.style.height=E.offsetHeight + 'px';
    }
}
function ProcesoPanel(oHttp, oDiv, oTipo)
    {
        if (oHttp.readyState == 4)                            
        {
            var div;            
            div=oHttp.responseXML.xml;
            if(div==null || div=="")
               div=oHttp.responseText;

            switch (oTipo)
            {
            case "1":
            case "2":
            case "4":
                oDiv.innerHTML=div;
            break;
            case "3":
                var xmlDoc=oHttp.responseXML;                
                if (xmlDoc.getElementsByTagName("noticias")!=null)
                {
                    var root = xmlDoc.getElementsByTagName("noticias").item(0);
                    if  (root!=null)
                    {   
                        for (var iNode = 0; iNode < root.childNodes.length; iNode++)                
                        {                     
                            var node = root.childNodes.item(iNode);                                                            
                            Article[i] = new Array (node.getElementsByTagName('titulo').item(0).text, node.getElementsByTagName('enlace').item(0).text, "");i++
                        }                
                        oDiv.innerHTML='<div name="boundry" id="boundry" style="position:relative; width:100%;"></div>';
                        loadScroller();
                    }
                    else
                        oDiv.innerHTML='';
                 }
                 else
                    oDiv.innerHTML='';
            break;
            case "5":
            break;
            default:
                oDiv.innerHTML=div;
            }            
        }
    }
function Ver(sEle)
	{		
		 window.open("VerEjemplar.asp?P="+sEle);
	}