// *****************************************************************************
// *****************************************************************************
// Funciones de Ajax

function crearInstancia()
{
    XMLHttp = false;
    
    if(window.XMLHttpRequest)
    {
        return new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        var versiones = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0",
                         "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0",
                         "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
        for (var i=0; i<versiones.lengt; i++)
        {
            try
            {
                XMLHttp = new ActivexObject(versiones[i]);
                if (XMLHttp)
                {
                    return XMLHttp;
                    break;
                }
            }
            catch(e){};
        }
    }
}

function sendServer(url, datos, contenedor)
{
    XMLHttp = crearInstancia();
    if(XMLHttp)
    {
        XMLHttp.onreadystatechange = function() {printDatos(contenedor);};
        XMLHttp.open("POST", url, true)
        XMLHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XMLHttp.send(datos);
    }
}

function printDatos(contenedor)
{
    if(XMLHttp.readyState == 4)
    {
        if(XMLHttp.status == 200)
        {
            document.getElementById(contenedor).innerHTML = XMLHttp.responseText;
        }
        else
        {
            document.getElementById(contenedor).innerHTML = "Fallo...." + XMLHttp.statusText;
        }
    }
    else
    {
        document.getElementById(contenedor).innerHTML = "Cargando informaci&oacute;n...";
    }
}


//******************************************************************************
//******************************************************************************

// Funciones de control de página web.
function getListJur()
{
    var dato = "tipo=juris";
    sendServer("./so/udiplist.php", dato, "juris");
}

// Funciones de control de página web.
function getListUdip(jurid)
{
    var dato = "jurid="+jurid+"&tipo=udip";
    sendServer("./so/udiplist.php", dato, "udip");
}

function getSujeto(sujid)
{
    var dato = "idsujeto="+sujid+"&tipo=dir";
    sendServer("./so/udiplist.php", dato, "udip");
}


//******************************************************************************
//******************************************************************************
function getListEvid()
{
    var dato = "dato=evidencia";
    sendServer("./socializa/evidctl.php", dato, "evidencia");
}

function getAllEvid(periodo)
{
    var dato = "dato=periodo&periodo="+periodo;
    sendServer("./socializa/evidctl.php", dato, "evidencia");
    
}


//******************************************************************************
//******************************************************************************
function getListCom()
{
    var dato = "dato=comunicado";
    sendServer("./prensa/comunicado.php", dato, "comunicado");
}

function getCom(id_com)
{
    var dato = "dato=nota&id_com="+id_com;
    sendServer("./prensa/comunicado.php", dato, "comunicado");
}

function getAllCom(periodo)
{
    var dato = "dato=periodo&periodo="+periodo;
    sendServer("./prensa/comunicado.php", dato, "comunicado");    
}


//******************************************************************************
//******************************************************************************
function getListSes(periodo)
{
    if(arguments.length == 0)
    {
        var hoy = new Date();
        periodo = hoy.getFullYear();
    }

    var dato = "dato=sesion&periodo=" + periodo;
    
    sendServer("./sesiones/sesctl.php", dato, "sesiones");
    document.getElementById("pdf").innerHTML = "";
}

function getSes(id_ses)
{
    var dato = "dato=ses&id_ses="+id_ses;
    sendServer("./sesiones/sesctl.php", dato, "pdf");
    document.getElementById("sesiones").innerHTML = "";
}
