﻿
//Descripción:  Funciones de JavaScript para la generación de la sección Datos.
var m_indicesTemas, m_botonTema, m_parametrosTema, entidades, municipios, entidadIDG, municipioIDG, temaPadreActualG, tableG, nombreUbicacion1G, nombreUbicacion2G, extensionColumnaG, desgloseGeograficoG, municipiosG, fuente, entidadesG, idiomaG, valortextoG, continuaG, imagenG, contFilasAgregadasG;

function EstablecerTituloUbicacion(valortexto) {
    var titulo = document.getElementById('iu_aTituloDatos');
    var entidades = document.getElementById('iu_selEntidades');
    var municipios = document.getElementById('iu_selMunicipios');

    if (entidades.options[entidades.selectedIndex].value == '0') {
        if (m_textos == undefined) {
            valortexto = valortextoG;
        }
        else { 
        valortexto=m_textos[17]
    }
        titulo.innerHTML = valortexto;
    }
    else {
        titulo.innerHTML = '';
        if (municipios.selectedIndex > -1) {
            if (municipios.options[municipios.selectedIndex].value != '0') {
                titulo.innerHTML += municipios.options[municipios.selectedIndex].text + ', ';
            }
        }
        titulo.innerHTML += entidades.options[entidades.selectedIndex].text;
    }
}

function ExportarTablaIndicadoresRecientes() {
    var entidades = document.getElementById('iu_selEntidades');
    var municipios = document.getElementById('iu_selMunicipios');
    var myUrl = 'DescargaDatos.ashx?e=' + entidades.options[entidades.selectedIndex].value;
    if (municipios.options.length > 0) {
        if (municipios.options[municipios.selectedIndex].value != '') {
            myUrl += '&mun=' + municipios.options[municipios.selectedIndex].value;
        }
    }
    //myUrl += '&lang=' + m_idioma;
    myUrl += '&i=' + m_idioma;
    //alre_17022011 se agrega el parametros de la fuente
    myUrl += ('&src=' + m_fuente);
    //alre_18022011 se omite esta linea para que tome los parametros
    //myUrl = 'DescargaDatos.ashx?ent=&lang=';
    window.open(myUrl, '_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, height=150, width=250 scrollbars=no');
}

function GenerarFilasOcultas(parametros) {
    //var loadingPopup = $find('B2');
    m_botonTema = document.getElementById('iu_a' + parametros);
    m_parametrosTema = parametros;

    //if (loadingPopup == null) {
    //    setTimeout('MostrarLoadingPopup2_1()', 50);
    //}
    //else {
    //    loadingPopup.show();
        setTimeout('IniciarFilasOcultas()', 150);
    //}
}

function GenerarListaEntidades(entidadID, valortexto, continua) {

    //var entidades = BISEMexicocifras.WebServiceFillAjax.EncontrarEntidades(), lista = document.getElementById('iu_selEntidades'), indiceSeleccionado = -1;
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarEntidades(callBackGenerarListaEntidades, ObtenError, entidadID,valortexto,continua);
}

function ObtenError(error) 
{
    alert(error._message);
    loadingPopup = $find('B2');
    if (loadingPopup != null) {
        loadingPopup.hide();
    }
}

function GenerarListaMunicipios(municipioID, continua) {
    //        if (municipioID == undefined) {
    //            municipioID = municipioIDG;
    //         }
    var municipios, lista = document.getElementById('iu_selEntidades'), indiceSeleccionado = -1;

    if (municipioID == undefined) {
        municipioID = 0;
     }
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarMunicipios(lista.options[lista.selectedIndex].value, callBackGenerarListaMunicipios, ObtenError, municipioID,continua);
}

function GenerarTablaIndicadoresRecientes() {
    var loadingPopup = $find('B2');

    if (loadingPopup == null) {
        setTimeout('MostrarLoadingPopup2()', 50);
    }
    else {
        loadingPopup.show();
        setTimeout('IniciarDatos()', 50);
    }
}

function IncremantarIndicesTemas(temaID) {
    var i, seIncrementanIndices = false;

    for (i = 0; i <= m_indicesTemas.length - 1; i += 3) {
        if (seIncrementanIndices) {
            m_indicesTemas[i + 1]++;
        }
        if (m_indicesTemas[i] == temaID) {
            seIncrementanIndices = true;
            m_indicesTemas[i + 2]++;
        }
    }
}

function IniciarDatos() {
    m_fch = new Date();
    m_ini = m_fch.getTime();

    if (m_fuente == null) {
        m_fuente = 0;
    }

    //Encontrar temas.
    var loadingPopup, temas;
    var entidades = document.getElementById('iu_selEntidades');
    var municipios = document.getElementById('iu_selMunicipios');
    var desgloseGeografico, nombreUbicacion1, nombreUbicacion2, extensionColumna;
    var contenedor, table;
    var i, j, k;
    //var temporal = 0;
    var temaPadreActual = 'mxyzptlk';
    var valores1, valores2, IDSIndicadores, pintarBotonMapa, pintarBotonInfo;

    //Establecer desglose geográfico.
    if (entidades.options[entidades.selectedIndex].value == '0') {
        //Nacional.
        desgloseGeografico = 1;
        if (m_textos == undefined) {
            valortexto = valortextoG;
        }
        else {
            valortexto = m_textos[17];
         }
        nombreUbicacion1 = valortexto;
        nombreUbicacion2 = '';
        extensionColumna = 2;
    }
    else {
        if (municipios.options[municipios.selectedIndex].value == '0') {
            //Estatal.
            desgloseGeografico = 2;
            nombreUbicacion1 = entidades.options[entidades.selectedIndex].text;
            nombreUbicacion2 = m_textos[17];
        }
        else {
            //Municipal.
            desgloseGeografico = 3;
            nombreUbicacion1 = municipios.options[municipios.selectedIndex].text;
            nombreUbicacion2 = entidades.options[entidades.selectedIndex].text;
        }
        extensionColumna = 3;
    }

    //Limpiar tabla de indicadores recientes.
    table = document.getElementById('iu_tableIndicadoresRecientes');
    if (table != null) {
        contenedor = table.parentElement;
        if (contenedor != undefined && contenedor != null) {
            contenedor = table.parentNode;
            contenedor.removeChild(table);
        }
    }
//    if (contenedor != undefined) {
        contenedor = document.getElementById('iu_divIndicadoresRecientes');
//    }
    table = document.createElement('table');
    table.id = 'iu_tableIndicadoresRecientes';
    table.style.borderCollapse = 'collapse';
    //table.style.border = 'solid 1px #556B2F';
    table.style.verticalAlign = "top";
    table.style.border = "0px";
    table.style.margin = "0px 0px 0px 0px"
    if (contenedor != null) {
        contenedor.appendChild(table);
    }
    tableG = table;
    extensionColumnaG = extensionColumna;
    //Definir tamaño de arreglo de índices de temas.
    var paramentidades, parammunicipio, paramidioma, paramfuente, paramtema;
    if (desgloseGeografico == 3) {
        paramtema = "0";
        paramentidades = entidades.options[entidades.selectedIndex].value;
        parammunicipio = municipios.options[municipios.selectedIndex].value;
        paramidioma = m_idioma;
        paramfuente = m_fuente;
        // temas = WebServiceFillAjax.EncontrarTemas('0', entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, m_idioma, m_fuente);
    }
    else {
        paramtema = "0";
        paramentidades = entidades.options[entidades.selectedIndex].value;
        parammunicipio = "0";
        paramidioma = m_idioma;
        paramfuente = m_fuente;
        //temas = servicioAjax.EncontrarTemas('0', entidades.options[entidades.selectedIndex].value, '0', m_idioma);
        // temas = WebServiceFillAjax.EncontrarTemas('0', entidades.options[entidades.selectedIndex].value, '0', m_idioma, m_fuente);
    }
    nombreUbicacion1G = nombreUbicacion1;
    nombreUbicacion2G = nombreUbicacion2;
    municipiosG = municipios;
    entidadesG = entidades;
    temaPadreActualG = temaPadreActual;
    desgloseGeograficoG = desgloseGeografico;
    entidadIDG = paramentidades;
    municipioIDG = parammunicipio;
    if (paramidioma == undefined) {
        paramidioma = "";
    }
     //alre_15082011 se cambia el llamado del webservices para que me regrese todos los temas con sus hijos. 
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarTemas(paramtema, paramentidades, parammunicipio, paramidioma, paramfuente, callBackIniciarDatos, ObtenError, IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
    
}

function IniciarFilasOcultas() {
    var entidades = document.getElementById('iu_selEntidades');
    var municipios = document.getElementById('iu_selMunicipios');
    var desgloseGeografico, extensionColumna, IDSIndicadores, valores1, valores2, valor2;
    var table = document.getElementById('iu_tableIndicadoresRecientes');
    var contFilasAgregadas = 0;
    var i, parametros, loadingPopup, pintarBotonMapa = false, pintarBotonInfo;

    

    //Establecer desglose geográfico.
    if (entidades.options[entidades.selectedIndex].value == '0') {
        //Nacional.
        desgloseGeografico = 1
        extensionColumna = 2;
    }
    else {
        if (municipios.options[municipios.selectedIndex].value == '0') {
            //Estatal.
            desgloseGeografico = 2;
        }
        else {
            //Municipal.
            desgloseGeografico = 3;
        }
        extensionColumna = 3;
    }
    desgloseGeograficoG = desgloseGeografico;
    tableG = table;
    extensionColumnaG = extensionColumna;
    municipiosG = municipios;
    entidadesG = entidades;
    //Encontrar valores recientes de los indicadores predeterminados.
    IDSIndicadores = 0;
    continuaIniciarFilasOcultas(IDSIndicadores, desgloseGeografico, contFilasAgregadas);
    //BISE.MexicoCifras.WebServiceFillAjax.EncontrarIndicadoresVisibles(desgloseGeografico, callBackIniciarFilasOcultas, ObtenError, contFilasAgregadas);

}
//function callBackcontinuaIndicadoresVisibles(result, desgloseGeografico) {
//    IDSIndicadores = result;
//    temaPadreActual = temaPadreActualG;
//    nombreUbicacion1 = nombreUbicacion1G;
//    nombreUbicacion2 = nombreUbicacion2G;
//    extensionColumna = extensionColumnaG;
//    desgloseGeografico = desgloseGeograficoG;
//    continuaIndicadores(IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
//}

function continuaIniciarFilasOcultas(IDSIndicadores, desgloseGeografico, contFilasAgregadas) {

    var paramentidades, parammunicipio, paramcase, paramidioma, paramfuente, paramtema, valores1, valores2, valor2;

    switch (desgloseGeografico) {
        case 1:
            paramentidades = "0";
            parammunicipio = "0";
            paramcase = "1";
            paramidioma = m_idioma;
            paramfuente = m_fuente;
            paramtema = m_parametrosTema;
            //                valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', m_parametrosTema.temaID, '', m_idioma, m_fuente);
            break;
        case 2:
            paramentidades = entidades.options[entidades.selectedIndex].value;
            parammunicipio = municipios.options[municipios.selectedIndex].value;
            paramcase = "2";
            paramidioma = m_idioma;
            paramfuente = m_fuente;
            paramtema = m_parametrosTema;
            //  valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, m_parametrosTema.temaID, '', m_idioma, m_fuente);
            // valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', m_parametrosTema.temaID, '', m_idioma, m_fuente);
            break;
        case 3:
            paramentidades = entidades.options[entidades.selectedIndex].value;
            parammunicipio = municipios.options[municipios.selectedIndex].value;
            paramcase = "3";
            paramidioma = m_idioma;
            paramfuente = m_fuente;
            paramtema = m_parametrosTema;
            // valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, m_parametrosTema.temaID, '', m_idioma, m_fuente);
            //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, '0', m_parametrosTema.temaID, '', m_idioma, m_fuente);
            break;
    }
    if (paramfuente == undefined) {
        paramfuente = 0;
    }
    if (paramidioma == undefined) {
        paramidioma = "";
     }
    idiomaG = paramidioma;
    //alre_30092011
    table = tableG;
    entidadIDG = paramentidades;
    municipioIDG = parammunicipio;
    var filaTema = document.getElementById('iu_rowTema' + paramtema);
    var indice = 0;
    if (filaTema != null) {
        indice = filaTema.rowIndex;
    }
    indice = ObtenerIndiceTema(paramtema, table);
    var posicion = 0;
    posicion = indice[1];
    posicion = posicion - 1;
    objeto = document.createElement('div');
    objeto.id = "div_" + paramtema;
    objeto.style.height = "50px";
    objeto.style.border = "1px";
    elemento = document.createElement('br');
    objeto.appendChild(elemento);
    //objeto.style.verticalAlign = "middle";
    imgMet = document.createElement('img');
    //td = table.rows[indice].insertCell(0);
    //td.appendChild(imgMet);
    imgMet.align = 'absmiddle';
    imgMet.src = 'img/procesando.gif';
    imgMet.id = "imagen_" + paramtema;
    objeto.appendChild(imgMet);
    elemento = document.createElement('span');
    if (paramidioma == null || paramidioma == undefined || paramidioma == "") {
        elemento.innerHTML = "&nbsp;Cargando información...";
    }
    else {
        elemento.innerHTML = "&nbsp;Loading information...";
     }
    objeto.appendChild(elemento);
    table.rows[posicion].cells[0].appendChild(objeto);
    //table.rows[posicion].cells[0].children[0].href = "#";
    liga = document.getElementById("imagen_" + paramtema);
    liga.src.value = "#";
    //table.rows[indice].innerHTML = imagen+ "<div id='imegen'><img src='img/simpke.gif'/> </div>";
    //table.rows[indice].insertAdjacentHTML("<div id='imegen'><img src='img/simpke.gif'/> </div>");
    contFilasAgregadasG = contFilasAgregadas;
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(paramentidades, parammunicipio, paramtema, '', paramidioma, paramfuente, callBackcontinuaIniciarFilasOcultas, ObtenError,paramtema);
}

function continuaIniciarFilasOcultas2(contFilasAgregadas, contFilasAgregadas) {
    var paramentidades, parammunicipio, paramcase, paramidioma, paramfuente, paramtema, valores1, valores2, valor2;

    switch (desgloseGeografico) {
        case 2:
            paramentidades = '0'
            parammunicipio = '0';
            paramcase = "2";
            paramidioma = m_idioma;
            paramfuente = m_fuente;
            paramtema = m_parametrosTema;
            //  valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, m_parametrosTema.temaID, '', m_idioma, m_fuente);
            // valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', m_parametrosTema.temaID, '', m_idioma, m_fuente);
            break;
        case 3:
            paramentidades = entidades.options[entidades.selectedIndex].value;
            parammunicipio = '0';
            paramcase = "3";
            paramidioma = m_idioma;
            paramfuente = m_fuente;
            paramtema = m_parametrosTema;
            // valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, m_parametrosTema.temaID, '', m_idioma, m_fuente);
            //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, '0', m_parametrosTema.temaID, '', m_idioma, m_fuente);
            break;
    }
//    entidadIDG = enti;
//    municipioIDG = parammunicipio;

    BISE.MexicoCifras.WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(paramentidades, parammunicipio, paramtema, '', paramidioma, paramfuente, callBackcontinuaIniciarFilasOcultas2, ObtenError, paramtema);
}
function callBackcontinuaIniciarFilasOcultas(result, idtema) {
    valores1 = result;
    imagen = imagenG;
    contFilasAgregadas = contFilasAgregadasG;
    if (desgloseGeograficoG != 1) {
        continuaIniciarFilasOcultas2(contFilasAgregadas, idtema);
    }
    else { sigueIniciaFilasOcultas(contFilasAgregadas, idtema); }
}
function callBackcontinuaIniciarFilasOcultas2(result, idtema) {
    valores2 = result;
    contFilasAgregadas = contFilasAgregadasG;
    sigueIniciaFilasOcultas(contFilasAgregadas,idtema);
}

//function callBackIniciarFilasOcultas(result, contFilasAgregadas) {
//    IDSIndicadores = result;
//    desgloseGeografico = desgloseGeograficoG;
//    continuaIniciarFilasOcultas(IDSIndicadores, desgloseGeografico, contFilasAgregadas);
//}

function MostrarFilasOcultas(parametros) {
    var table = document.getElementById('iu_tableIndicadoresRecientes');
    var rows = table.getElementsByTagName('tr');
    var filasOcultasCont = 0;
    var indice = ObtenerIndiceTema(parametros, table);
    var imagen = document.getElementById("div_" + parametros);
    if (imagen != null) {
        //table.rows[indicetema].cells[0].removeChild(imagen);
        imagen.parentNode.removeChild(imagen);
    }
    for (var i = indice[0] + 1; i < indice[1]; i++) {
        if (rows[i].style.display == 'none') {
            rows[i].style.display = '';
            if (rows[i].id.indexOf('iu_rowInd') != -1) {
                filasOcultasCont++;
            }
            else {
                filasOcultasCont--;
            }
        }
        else {
            rows[i].style.display = 'none';
        }
    }

    e = document.getElementById('iu_a' + parametros);

    if (m_textos == undefined) {
        texto1 = "Ver más";
        texto2 = "Ver básico";
    }
    else {
        texto1 = m_textos[1];
    texto2=m_textos[2];
}
    if (e.innerHTML == texto1) {
        if (filasOcultasCont > 0) {
        
            e.innerHTML = texto2;
        }
        else {
            e.style.display = 'none';
        }
    }
    else {
        e.innerHTML = texto1;
    }
}

function MostrarLoadingPopup2() {
    var loadingPopup = $find('B2');

    if (loadingPopup != null) {
        loadingPopup.show();
    }

    setTimeout('IniciarDatos()', 50);
}

function MostrarLoadingPopup2_1() {
    var loadingPopup = $find('B2');

    if (loadingPopup != null) {
        loadingPopup.show();
    }

    setTimeout('IniciarFilasOcultas()', 50);
}

function MostrarMapaIndicador(e, parametros) {
    var entidades = document.getElementById('iu_selEntidades'), municipios = document.getElementById('iu_selMunicipios'), miUrl, entidadID, municipioID = '0';

    if (document.location.pathname.toUpperCase().indexOf('MEXICOCIFRAS2.ASPX') < 0) {
        entidadID = entidades[entidades.selectedIndex].value;
        miUrl = 'MexicoCifras2.aspx?e=' + entidadID + '&m=' + municipioID + '&sec=M&ind=' + parametros.indicadorID + '&ent=' + entidades[entidades.selectedIndex].value + '&enn=' + entidades[entidades.selectedIndex].text + '&ani=' + parametros.anio;
        //miUrl = 'MexicoCifras.aspx?ent=' + entidadID + '&mun=' + municipioID + '&sec=M&ind=' + parametros.indicadorID + '&ent=' + entidades[entidades.selectedIndex].value + '&enn=' + entidades[entidades.selectedIndex].text + '&ani=' + parametros.anio;

        if (municipios.options.length > 0) {
            if (municipios.options[municipios.selectedIndex].value != '0') {
                miUrl += ('&mun=' + municipios.options[municipios.selectedIndex].value);
            }
        }
        if (m_idioma != '') {
            //miUrl += ('&lang=' + m_idioma);
            miUrl += ('&i=' + m_idioma);
        }
        //alre_17022011
        if (m_fuente != '') {
            miUrl += ('&src=' + m_fuente);
        }


        location.href = miUrl;
    }
    else {
        document.getElementById('iu_hidIndicadorID').value = parametros.indicadorID;
        document.getElementById('iu_tdEtiquetaIndicador').innerHTML = parametros.indicadorNombre;
        document.getElementById('iu_hidEntidadID').value = entidades.options[entidades.selectedIndex].value;
        document.getElementById('iu_tdEtiquetaEntidad').innerHTML = entidades[entidades.selectedIndex].text;
        document.getElementById('iu_aTituloMapa').innerHTML = entidades[entidades.selectedIndex].text;
        document.getElementById('iu_hidAnio').value = parametros.anio;
        IniciarAnimacionEntradaMapa(true);
    }

}
function MostrarMetadatosIndicador(indicadorID, indicadorNombre, anio, fuente) {
    var entidades = document.getElementById('iu_selEntidades'), municipios = document.getElementById('iu_selMunicipios'), param, paramanio, paramidioma;

    if (entidades.options[entidades.selectedIndex].value == '0') {
        //var indicador = EstablecerServicioAjax().EncontrarIndicador(parametros.indicadorID, entidades.options[entidades.selectedIndex].value, '0', parametros.anio, m_idioma);
        param = indicadorID;
        entidades = entidades.options[entidades.selectedIndex].value;
        municipios = "0";
        paramanio = anio;
        paramidioma = m_idioma;

        //var indicador = WebServiceFillAjax().EncontrarIndicador(parametros.indicadorID, entidades.options[entidades.selectedIndex].value, '0', parametros.anio, m_idioma);
    }
    else {
        param = indicadorID;
        entidades = entidades.options[entidades.selectedIndex].value;
        municipios = municipios.options[municipios.selectedIndex].value;
        paramanio = anio;
        if (m_idioma == undefined) {
            paramidioma = "";
        }
        else {
            paramidioma = m_idioma;
        }
        if (entidades == "") {
            entidades = "0";
        }
        if (municipios == "") {
            municipios = "0";
         }
    }
    // var indicador = WebServiceFillAjax().EncontrarIndicador(parametros.indicadorID, entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, parametros.anio, m_idioma);
    parametros = { indicadorID: indicadorID, indicadorNombre: indicadorNombre, anio: anio, fuente: fuente }

    if (paramidioma == undefined) {
        paramidioma = "";
     }
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarIndicador(param, entidades, municipios, paramanio, paramidioma, callBackMostrarMetadatosIndicador, ObtenError, parametros);
}

function continuaMostrarMetadatosIndicador(parametros) {
    iu_infoHeader.innerHTML = indicador[0];
    var panelInfo = document.getElementById('iu_panelInfoB');
    panelInfo.innerHTML = '';
    if (indicador[1].length > 0) {
        panelInfo.innerHTML = '<br /><b>' + m_textos[12] + ':</b> ' + indicador[1];
    }
    if (indicador[2].length > 0) {
        panelInfo.innerHTML += '<br /><br />' + indicador[2];
    }
    if (indicador[3].length > 0) {
        panelInfo.innerHTML += '<br /><b>' + m_textos[13] + ':</b> ' + indicador[3];
    }
    if (indicador[4].length > 0) {
        panelInfo.innerHTML += '<br /><b>' + m_textos[14] + ':</b><br />' + indicador[4];
    }
    var modalPopup = $find('B1').show();
}

function MostrarOtrosDatosGeograficos(miUrl) {
    window.open(miUrl, '_blank', 'toolbar=no, directories=no, scrollbars=yes, copyhistory=no, height=590, width=790');
}

function callBackMostrarMetadatosIndicador(result, parametros) {
    indicador = result;
    continuaMostrarMetadatosIndicador(parametros);
}

function MostrarSeccionDatos(entidadID, municipioID, fuente) {
    if (document.getElementById('iu_hidYaSeGeneroDatos').value == 'N') {
        if (entidadID == "undefine") {
            entidadID = document.getElementById('Hident').value;
            municipioID = document.getElementById('Hidmun').value;
        }
        if (document.getElementById('iu_selEntidades').options[document.getElementById('iu_selEntidades').selectedIndex].value != 0) {
            entidadID = document.getElementById('iu_selEntidades').options[document.getElementById('iu_selEntidades').selectedIndex].value;
        }
        if (document.getElementById('iu_selMunicipios').options.length > 0) {
            if (document.getElementById('iu_selMunicipios').options[document.getElementById('iu_selMunicipios').selectedIndex].value != "") {
                municipioID = document.getElementById('iu_selMunicipios').options[document.getElementById('iu_selMunicipios').selectedIndex].value;
            }
        }
        municipioIDG = municipioID;
        entidadIDG = entidadID;
        GenerarListaEntidades(entidadID);
        //            SeleccionarEntidad1(municipioID);
        //alre_05042011 se quita la siguiente asignacion para que se genere siempre la tabla
        //document.getElementById('iu_hidYaSeGeneroDatos').value = 'S';
    }
}

function MostrarSeccionDatosFija(entidadID) {
    if (document.getElementById('iu_hidYaSeGeneroDatos').value == 'N') {
        GenerarListaEntidades(entidadID);
        SeleccionarEntidadFija();
        document.getElementById('iu_hidYaSeGeneroDatos').value = 'S';
    }
}

function ObtenerEstiloFilaIndicador(indice) {
    if ((indice + 1) % 2 == 0) {
        return 'ColDataAlt';
    }
    else {
        return 'ColData';
    }
}

function ObtenerIndiceTema(temaID, table) {
    var i, indice = new Array(2);
    var filaTema = document.getElementById('iu_rowTema' + temaID);

    if (filaTema != null) {
        indice[0] = filaTema.rowIndex;
    }
    indice[1] = table.rows.length;
    if (filaTema != null) {
        for (i = filaTema.rowIndex + 1; i < table.rows.length; i++) {
            if (table.rows[i].id.indexOf('iu_rowTema') != -1) {
                indice[1] = i;
                break;
            }
        }
    }
    return indice;
}

function ObtenerSegundoValor(indicadorID, anio, valores) {
    var i, valor = 'No disponible';
//alre_27092011
    //for (i = 0; i <= valores.length - 7; i += 8) {
    //for (i = 0; i <= valores.length - 7; i += 9) {
    for (i = 0; i <= valores.length - 7; i += 10) {

        if (valores[i] == indicadorID && valores[i + 4] == anio) {
            valor = valores[i + 3];
            break;
        }
    }

    return valor;
}

//function PintarFilaIndicador(table, temaID, indicadorID, indicadorNombre, anio, valor1, valor2, desgloseGeografico, seOculta, unidadMedida, pintarBotonMapa, estiloCelda, pintarBotonInfo)
function PintarFilaIndicador(table, temaID, indicadorID, indicadorNombre, anio, valor1, valor2, desgloseGeografico, seOculta, unidadMedida, pintarBotonMapa, estiloCelda, pintarBotonInfo, fuente, pintaBotonGRafica) {
    if (valor1 != 'No disponible' || valor2 != 'No disponible') {
        var row, td, objeto, parametros, indice;

        indice = ObtenerIndiceTema(temaID, table);

        row = table.insertRow(indice[1]);
        if (seOculta) {
            row.id = 'iu_rowInd' + indicadorID;
        }
        td = row.insertCell(0);
        //alre_17022011 se agrega el parametro de la fuente.
        //parametros = { indicadorID: indicadorID, indicadorNombre: indicadorNombre, anio: anio }
        parametros = { indicadorID: indicadorID, indicadorNombre: indicadorNombre, anio: anio, fuente: fuente }
        //Agregar botón de información.
        objeto = document.createElement('a');
        imgMet = document.createElement('img');
        objeto.appendChild(imgMet);
        td.appendChild(objeto);
        imgMet.align = 'absmiddle';
        if (m_idioma == "i") {
            imgMet.alt = 'Information';
        } else {
            imgMet.alt = 'Información';
        }
        objeto.style.cursor = 'pointer';
        imgMet.src = 'img/btn_metadato.png';
        imgMet.id = 'iu_imgInfo_' + indicadorID;
        objeto.href = "javascript:MostrarMetadatosIndicador('" + indicadorID + "','" + indicadorNombre + "','" + anio + "','" + fuente + "');";
        //YAHOO.util.Event.addListener(objeto, 'click', MostrarMetadatosIndicador, parametros);
        if (!pintarBotonInfo) {
            objeto.style.visibility = 'hidden';
        }


        //Agregar botón mapa.5
        objeto = document.createElement('a');
        imgMet = document.createElement('img');
        objeto.appendChild(imgMet);
        td.appendChild(objeto);
        imgMet.align = 'absmiddle';
        if (m_idioma == "i") {
            imgMet.alt = 'Map';
        } else {
            imgMet.alt = 'Mapa';
        }
        objeto.style.cursor = 'pointer';
        imgMet.src = 'img/btn_mapa.png';
        imgMet.id = 'iu_imgMapa_' + indicadorID;
        objeto.href = "javascript:CargaDatos('" + entidadIDG + "','" + municipioIDG + "','" + indicadorID + "','" + anio + "','" + fuente + "','M','" + idiomaG + "');";
        if (!pintarBotonMapa) {
            objeto.style.visibility = 'hidden';
        }
        //alre_31092011 agregar boton serie historica
        objeto = document.createElement('a');
        imgMet = document.createElement('img');
        objeto.appendChild(imgMet);
        td.appendChild(objeto);
        imgMet.align = 'absmiddle';
        if (m_idioma == "i") {
            imgMet.alt = 'Historical series';
        }
        else {
            imgMet.alt = 'Serie histórica';
        }
        objeto.style.cursor = 'pointer';
        imgMet.src = 'img/btn_grafica.gif';
        imgMet.id = 'iu_imgSer_' + indicadorID;
        objeto.href = "javascript:GraficaSerie('" + indicadorID + "','" + indicadorNombre + "','" + idiomaG + "');";
        if (!pintaBotonGRafica) {
            objeto.style.visibility = 'hidden';
        }
        //YAHOO.util.Event.addListener(objeto, 'click', MostrarMapaIndicador, parametros);

        //Agregar nombre de indicador.
        objeto = document.createElement('span');
        if (unidadMedida == '') {
            objeto.innerHTML = '&nbsp;&nbsp;' + indicadorNombre + ', ' + anio;
        }
        else {
            objeto.innerHTML = '&nbsp;&nbsp;' + indicadorNombre + ' (' + unidadMedida + '), ' + anio;
        }
        td.appendChild(objeto);
        if (desgloseGeografico == 1) {
            td.className = estiloCelda + '11';
        }
        else {
            td.className = estiloCelda + '1';
        }

        //Agregar primer valor.
        td = row.insertCell(1);
        td.innerHTML = valor1;
        td.className = estiloCelda + '2';

        if (valor2 != null) {
            //Agregar segundo valor.
            td = row.insertCell(2);
            td.innerHTML = valor2;
            td.className = estiloCelda + '3';
        }

    }
}

function PintarFilaTema(table, extensionColumna, temaID, nombreTema,pinta) {
    var row, td, anchor, parametros, objeto;

    row = table.insertRow(-1);
    row.id = 'iu_rowTema' + temaID;
    td = row.insertCell(0);
    td.className = 'ColHeader';
    td.colSpan = extensionColumna;
    td.innerHTML = nombreTema + '&nbsp;&nbsp;&nbsp;';
    if (m_fuente == 0) {
        if (pinta) {
            anchor = document.createElement('a');
            anchor.className = 'Anchor';
            anchor.id = 'iu_a' + temaID;
            anchor.innerHTML = m_textos[1];
            anchor.href = "javascript:GenerarFilasOcultas('" + temaID + "');";
            //            parametros = { temaID: temaID }
            //            YAHOO.util.Event.addListener(anchor, 'click', GenerarFilasOcultas, parametros);
            td.appendChild(anchor);
        }
    }
}

function PintarFilaTemaPadre(table, nombreTemaPadre, nombreUbicacion1, nombreUbicacion2) {
    var row, td;

    row = table.insertRow(-1);
    td = row.insertCell(0);
    td.className = 'ColHeaderEsp';
    td.innerHTML = nombreTemaPadre + '&nbsp;';
    td = row.insertCell(1); 
    td.className = 'ColHeaderEsp2';
    td.innerHTML = nombreUbicacion1;
    if (nombreUbicacion2 != '') {
        td = row.insertCell(2);
        td.className = 'ColHeaderEsp2';
        td.innerHTML = nombreUbicacion2;
    }
}
//alre_16082011 se crea esta funsion para que agregue el tema superiror.
function PintarFilaTemaSuperior(table, extensionColumna, temaID, nombreTema,pintatextos) 
{
    row = table.insertRow(-1);
    row.id = 'iu_rowTema' + temaID;
    td = row.insertCell(0);
    td.className = 'ColHeaderSup';
    td.colSpan = extensionColumna;
    td.innerHTML = nombreTema + '&nbsp;&nbsp;&nbsp;';
    if (m_fuente == 0) {
        anchor = document.createElement('a');
        anchor.className = 'Anchor';
        anchor.id = 'iu_a' + temaID;
        if (pintatextos == "true") {
            anchor.innerHTML = m_textos[1];
            anchor.href = "javascript:GenerarFilasOcultas('" + temaID + "');";
        }
//        //            parametros = { temaID: temaID }
        //            YAHOO.util.Event.addListener(anchor, 'click', GenerarFilasOcultas, parametros);
        td.appendChild(anchor);
    }
 }

function PintarTemaGeografia(table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidadID, municipioID) {
    //var servicioAjax = WebServiceFillAjax(), row, td, valores1, valores2;
    var row, td, paramentidades, parammunicipio, paramcase, valores1, valores2;
    switch (desgloseGeografico) {
        case 1:
            paramentidades = "0";
            parammunicipio = "0";
            paramcase = "1";
            //valores1 = WebServiceFillAjax.EncontrarInformacionGeografica('0', '0');
            break;
        case 2:
            paramcase = "2";
            paramentidades = entidadID;
            parammunicipio = "0";
            // valores1 = WebServiceFillAjax.EncontrarInformacionGeografica(entidadID, '0');
            //valores2 = WebServiceFillAjax.EncontrarInformacionGeografica('0', '0');
            break;
        case 3:
            paramcase = "3";
            paramentidades = entidadID;
            parammunicipio = municipioID;

            // valores1 = WebServiceFillAjax.EncontrarInformacionGeografica(entidadID, municipioID);
            //valores2 = WebServiceFillAjax.EncontrarInformacionGeografica(entidadID, '0');
            break;
    }
    entidadIDG = entidadID;
    municipioIDG = municipioID;
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarInformacionGeografica(paramentidades, parammunicipio, callBackPintarTemaGeografia, ObtenError, table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2);
}

function SeleccionarEntidad1(municipioID, continua) {
    GenerarListaMunicipios(municipioID,continua);
    //        EstablecerTituloUbicacion();
    //        var entidades = document.getElementById('iu_selEntidades');
    //        CargarImagenRepresentativa(document.getElementById('iu_imgImagenUbicacion2'), entidades.options[entidades.selectedIndex].value, '');
    //        GenerarTablaIndicadoresRecientes();
    //alert('Cargaron Indicadores Recientes');
}

function SeleccionarEntidadFija() {
    GenerarListaMunicipios(municipioID);
    EstablecerTituloUbicacion();
    var entidades = document.getElementById('iu_selEntidades');
    CargarImagenRepresentativa(document.getElementById('iu_imgImagenUbicacion2'), entidades.options[entidades.selectedIndex].value, '');
}

function SeleccionarMunicipio() {
    EstablecerTituloUbicacion();
    var entidades = document.getElementById('iu_selEntidades');
    var municipios = document.getElementById('iu_selMunicipios');
    document.getElementById('iu_hidMunicipioID').value = municipios.options[municipios.selectedIndex].value;
    CargarImagenRepresentativa(document.getElementById('iu_imgImagenUbicacion2'), entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value);
    GenerarTablaIndicadoresRecientes();
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function VerCodigo() {
    var a = document.getElementById('iu_divIndicadoresRecientes').innerHTML;
}

function xPintarFilaTema(table, extensionColumna, temaID, nombreTema) {
    var row, td;

    row = table.insertRow(-1);
    row.id = 'iu_rowTema' + temaID;
    td = row.insertCell(0);
    td.className = 'ColHeader';
    td.colSpan = extensionColumna;
    td.innerHTML = nombreTema + '&nbsp;&nbsp;&nbsp;<a id="iu_a' + temaID + '" class="Anchor" onclick="GenerarFilasOcultas(this, { temaID: \'' + temaID + '\'});">Ver más</a>';
}

function xPintarFilaIndicador(table, temaID, indicadorID, indicadorNombre, anio, valor1, valor2, desgloseGeografico, seOculta, unidadMedida, pintarBotonMapa, estiloCelda, pintarBotonInfo) {
    if (valor1 != 'No disponible' || valor2 != 'No disponible') {
        var row, td, objeto, parametros, indice;

        indice = ObtenerIndiceTema(temaID, table);

        row = table.insertRow(indice[1]);
        if (seOculta) {
            row.style.display = 'none';
        }
        td = row.insertCell(0);
        parametros = { indicadorID: indicadorID, indicadorNombre: indicadorNombre, anio: anio
        }
        //Agregar botón de información.
        if (pintarBotonInfo) {
            td.innerHTML = '<img style="cursor: pointer" id="iu_imgInfo_' + indicadorID + '" alt="Información" align="absMiddle" onclick="MostrarMetadatosIndicador({ indicadorID: \'' + indicadorID + '\', indicadorNombre: \'' + indicadorNombre + '\', anio: \'' + anio + '\' });" src="img/ico_Info2.gif">';
        }
        else {
            td.innerHTML = '<img style="cursor: pointer; visibility: hidden;" id="iu_imgInfo_' + indicadorID + '" alt="Información" align="absMiddle" src="img/ico_Info2.gif">';
        }
        //Agregar botón mapa.
        if (pintarBotonMapa) {
            td.innerHTML += '<img style="cursor: pointer" id="iu_imgMapa_' + indicadorID + '" alt="Mapa" align="absMiddle" onclick="MostrarMapaIndicador(this, { indicadorID: \'' + indicadorID + '\', indicadorNombre: \'' + indicadorNombre + '\', anio: \'' + anio + '\' });" src="img/ico_Mapa2.gif">';
        }
        else {
            td.innerHTML += '<img style="cursor: pointer visibility: hidden;" id="iu_imgMapa_' + indicadorID + '" alt="Mapa" align="absMiddle" src="img/ico_Mapa2.gif">';
        }
        //Agregar nombre de indicador.
        if (unidadMedida == '') {
            td.innerHTML += '<span>&nbsp;&nbsp;' + indicadorNombre + ', ' + anio + '</span>';
        }
        else {
            td.innerHTML += '<span>&nbsp;&nbsp;' + indicadorNombre + ' (' + unidadMedida + '), ' + anio + '</span>';
        }
        if (desgloseGeografico == 1) {
            td.className = estiloCelda + '11';
        }
        else {
            td.className = estiloCelda + '1';
        }
        //Agregar primer valor.
        td = row.insertCell(1);
        td.innerHTML = valor1;
        td.className = estiloCelda + '2';

        if (valor2 != null) {
            //Agregar segundo valor.
            td = row.insertCell(2);
            td.innerHTML = valor2;
            td.className = estiloCelda + '3';
        }

        IncremantarIndicesTemas(temaID);
    }
}

function PintarTemaGeografiaValores2(desgloseGeografico, entidadID, municipioID, table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2) {
    var paramentidades, parammunicipio, paramcase;
    switch (desgloseGeografico) {
        case 2:
            paramcase = "2";
            paramentidades = "0";
            parammunicipio = "0";
            // valores1 = WebServiceFillAjax.EncontrarInformacionGeografica(entidadID, '0');
            //valores2 = WebServiceFillAjax.EncontrarInformacionGeografica('0', '0');
            break;
        case 3:
            paramcase = "3";
            paramentidades = entidadID;
            parammunicipio = '0';

            // valores1 = WebServiceFillAjax.EncontrarInformacionGeografica(entidadID, municipioID);
            //valores2 = WebServiceFillAjax.EncontrarInformacionGeografica(entidadID, '0');
            break;
    }
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarInformacionGeografica(paramentidades, parammunicipio, callBackPintarTemaGeografiaValores2, ObtenError, table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidadID, municipioID);
}

function callBackPintarTemaGeografiaValores2(result, table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidadID, municipioID) {
    valores2 = result;
    continuaPintarTemaGeografia(table, desgloseGeograficoG, nombreUbicacion1G, nombreUbicacion2G, entidadIDG, municipioIDG);
}

function continuaPintarTemaGeografia(table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidadID, municipioID) {
    table = tableG;

    if (valores1.error == null) {

        //Agregar fila de tema padre Geografía.
        row = table.insertRow(table.tBodies[0].rows.length);
        row.id = 'iu_rowTemaGeografia';
        td = row.insertCell(0);
        td.className = 'ColPieEsp';
        //td.innerHTML = m_textos[3];
        td = row.insertCell(1);
        td.className = 'ColPieEsp2';
        td.innerHTML = nombreUbicacion1;
        if (desgloseGeografico != 1) {
            td = row.insertCell(2);
            td.className = 'ColPieEsp2';
            td.innerHTML = nombreUbicacion2;
        }
        //Agregar fila cabecera municipal.
        if (valores1[2] != '') {
            row = table.insertRow(table.tBodies[0].rows.length);
            td = row.insertCell(0);
            td.innerHTML = '&nbsp;&nbsp;' + m_textos[4];
            td.className = 'ColDataAlt11';

            td = row.insertCell(1);
            td.innerHTML = valores1[2];
            td.className = 'ColDataAlt2';
            td.style.textAlign = 'center';

            if (desgloseGeografico != 1) {
                td = row.insertCell(2);
                td.className = 'ColDataAlt3';
            }
        }
        //Agregar fila latitud.

        row = table.insertRow(table.tBodies[0].rows.length);
        td = row.insertCell(0);
        td.innerHTML = '&nbsp;&nbsp;' + m_textos[5];
        td.className = 'ColData11';
        td = row.insertCell(1);
        if (valores1[3] == '') {
            td.innerHTML = m_textos[11];
        }
        else {
            td.innerHTML = valores1[3] + '° ' + valores1[4] + '\'';
            if (valores1[8] != '') {
                td.innerHTML += ' - ' + valores1[8] + '° ' + valores1[9] + '\'';
            }
            td.innerHTML += ' N';
        }
        td.className = 'ColData2';
        td.style.textAlign = 'center';

        if (desgloseGeografico != 1) {
            td = row.insertCell(2);
            if (valores2[3] == '') {
                td.innerHTML = m_textos[11];
            }
            else {
                td.innerHTML = valores2[3] + '° ' + valores2[4] + '\'';
                if (valores2[8] != '') {
                    td.innerHTML += ' - ' + valores2[8] + '° ' + valores2[9] + '\'';
                }
                td.innerHTML += ' N';
            }
            td.className = 'ColData3';
            td.style.textAlign = 'center';
        }
        //Agregar fila longitud.


        row = table.insertRow(table.tBodies[0].rows.length);
        td = row.insertCell(0);
        td.innerHTML = '&nbsp;&nbsp;' + m_textos[6];
        td.className = 'ColDataAlt11';

        td = row.insertCell(1);
        if (valores1[5] == '') {
            td.innerHTML = m_textos[11];
        }
        else {
            td.innerHTML = valores1[5] + '° ' + valores1[6] + '\'';
            if (valores1[10] != '') {
                td.innerHTML += ' - ' + valores1[10] + '° ' + valores1[11] + '\'';
            }
            td.innerHTML += m_textos[7];
        }
        td.className = 'ColDataAlt2';
        td.style.textAlign = 'center';

        if (desgloseGeografico != 1) {
            td = row.insertCell(2);
            if (valores2[5] == '') {
                td.innerHTML = m_textos[11];
            }
            else {
                td.innerHTML = valores2[5] + '° ' + valores2[6] + '\'';
                if (valores2[10] != '') {
                    td.innerHTML += ' - ' + valores2[10] + '° ' + valores2[11] + '\'';
                }
                td.innerHTML += m_textos[7];
            }
            td.className = 'ColDataAlt3';
            td.style.textAlign = 'center';
        }
        //Agregar fila altitud.
        if (valores1[7] != '') {
            row = table.insertRow(table.tBodies[0].rows.length);
            td = row.insertCell(0);
            td.innerHTML = '&nbsp;&nbsp;' + m_textos[8];
            td.className = 'ColData11';

            td = row.insertCell(1);
            td.innerHTML = valores1[7] + ' msnm';
            td.className = 'ColData2';
            td.style.textAlign = 'center';

            if (desgloseGeografico != 1) {
                td = row.insertCell(2);
                if (valores2[7] != '') {
                    td.innerHTML = valores2[7] + ' msnm';
                }
                td.className = 'ColData3';
                td.style.textAlign = 'center';
            }
        }
        tableG = table;
        if (desgloseGeografico == 3) {
            BISE.MexicoCifras.WebServiceFillAjax.EncontrarUrlOtrosDatosGeograficos(entidadID, municipioID, callBackcontinuaPintarTemaGeografia, ObtenError);
        }
    }
    else {
        LanzarExcepcionServicioAjax(valores1.error.Message);
    }
    tableG = table;
    //var isIE = /*@cc_on!@*/false;

    var navegador = navigator.appName
    //        if (navegador == "Microsoft Internet Explorer")
    //            direccion = ("explorer.htm");
    //        else
    //            direccion = ("netscape.htm")
    //        window.location = direccion;


    if (navegador == "Microsoft Internet Explorer") {
        if (document.getElementById('iu_divIndicadoresRecientes') != null) {
            var contGeo = document.getElementById('iu_divIndicadoresRecientes').innerHTML;
            document.getElementById('iu_divIndicadoresRecientes').innerHTML = contGeo.substring(0, contGeo.indexOf("<TR id=iu_rowTemaGeografia")) + "</table>";
            if (document.getElementById('iu_divIndicadoresRecientes2') != null) {
                document.getElementById('iu_divIndicadoresRecientes2').innerHTML = "<table id='iu_geofgrafia'  style='border-collapse:collapse; border: 0px';verticalAlign=top;>" + contGeo.substring(contGeo.indexOf("<TR id=iu_rowTemaGeografia"));
            }
        }
    }
    else {
        var contGeo = document.getElementById('iu_divIndicadoresRecientes').innerHTML;
        document.getElementById('iu_divIndicadoresRecientes').innerHTML = contGeo.substring(0, contGeo.indexOf("<tr id=\"iu_rowTemaGeografia\"")) + "</table>";
        document.getElementById('iu_divIndicadoresRecientes2').innerHTML = "<table id='iu_geofgrafia' style='border-collapse:collapse; border: 0px'>" + contGeo.substring(contGeo.indexOf("<tr id=\"iu_rowTemaGeografia\""));
    }

}

function callBackcontinuaPintarTemaGeografia(result) {
    miUrl = result;
    tabla = tableG;
    if (tabla.innerHTML=="") {
        tabla = document.getElementById('iu_divIndicadoresRecientes2');
        tableG = tabla;
     }
    siguecontinuaPintarTemasGeografia(tabla);
}

function callBackEncontrarDatosGeograficos(result) {
    valores1 = result;          
    continuacionEncontrarUrlOtrosDatosGeograficos();
}

function siguecontinuaPintarTemasGeografia(table) {
    table = tableG;
    if (miUrl != null & miUrl != '') {
        //row = table.insertRow(table.tBodies[0].rows.length);
        row = document.getElementById("iu_geofgrafia").insertRow(table.children[0].rows.length);
        td = row.insertCell(0);
        td.innerHTML = '&nbsp;&nbsp;' + m_textos[9];
        td.className = 'ColDataAlt11';
        td = row.insertCell(1);
        td.className = 'ColDataAlt11';
        td = row.insertCell(1);
        td.innerHTML = '<center><a class=\'Anchor\' onclick=\'MostrarOtrosDatosGeograficos("' + miUrl + '");return false;\'>' + m_textos[10] + '</a> &nbsp;(PDF)</center>';
        td.className = 'ColDataAlt11';
    }

}

function GenerarListaLocalidades(localidadID) {
    //   var Localidades, lista = document.getElementById('iu_selLocalidad'), indiceSeleccionado = -1, WebServiceFillAjax = WebServiceFillAjax();
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarLocalidades(lista.options[lista.selectedIndex].value, callBackGenerarListaLocalidades, localidadID, ObtenError);
}

function ContinuaGeneraListaEntidades(entidadID, valortexto, continua) {
    lista = document.getElementById('iu_selEntidades'), indiceSeleccionado = -1;

    lista.options.length = 0;

    
    if (entidades.error == null) {
        if (entidades.length > 0) {
            if (m_textos == undefined) {
                texto = valortexto;
            }
            else{
                 texto = m_textos[17];
             }
             valortextoG = texto;
             AgregarOpcionALista(lista, '0', texto);
            for (i = 0; i <= entidades.length - 2; i += 2) {
                if (document.getElementById('iu_hidYaSeGeneroDatos').value == 'N' && document.getElementById('iu_hidE').value != '') {
                    if (document.getElementById('iu_hidE').value == entidades[i]) {
                        indiceSeleccionado = (i / 2) + 1;
                    }
                }
                else {
                    if (entidadID == entidades[i]) {
                        indiceSeleccionado = (i / 2) + 1;
                    }
                }

                AgregarOpcionALista(lista, entidades[i], entidades[i + 1]);
            }
            if (indiceSeleccionado == -1) {
                lista.selectedIndex = 0;
            }
            else {
                lista.selectedIndex = indiceSeleccionado;
            }
        }
    }
    else {
        LanzarExcepcionWebServiceFillAjax(entidades.error.Message);
    }
    municipioID = municipioIDG
    SeleccionarEntidad1(municipioID,continua);
}

function callBackPintarTemaGeografia(result, table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidadID, municipioID) {
    valores1 = result;
    desgloseGeografico = desgloseGeograficoG;
    table = tableG;
    nombreUbicacion1 = nombreUbicacion1G;
    nombreUbicacion2 = nombreUbicacion2G;
    entidadID = entidadIDG;
    municipioID = municipioIDG;
    if (desgloseGeografico != 1) {
        PintarTemaGeografiaValores2(desgloseGeograficoG, entidadID, municipioID, tableG, desgloseGeograficoG, nombreUbicacion1G, nombreUbicacion2G);
    }
    else {
        continuaPintarTemaGeografia(table, desgloseGeograficoG, nombreUbicacion1G, nombreUbicacion2G, entidadIDG, municipioIDG);
    }
}

function callBackIniciarDatos(result, IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico) {
    temas = result;
    //continuaIniciarDatos();
    temaPadreActual = temaPadreActualG;
    nombreUbicacion1 = nombreUbicacion1G;
    nombreUbicacion2 = nombreUbicacion2G;
    extensionColumna = extensionColumnaG;
    desgloseGeografico = desgloseGeograficoG;
    continuaEncontrarIndicadoresVisibles(IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
}

function callBackGenerarListaEntidades(result, entidadID,valortexto,continua) {
    entidades = result;
    ContinuaGeneraListaEntidades(entidadID,valortexto,continua);

}
function callBackGenerarListaMunicipios(result, municipioID,continua) {
    municipios = result;
    indiceSeleccionado = 0;
    ContinuaGenerarListaMunicipios(municipios,continua);
}

function callBackGenerarListaLocalidades(result, localidadID) {
    localidaes = result;
    ContinuaGeneraListaLocalidades(localidadID);
}

//    function callBackIniciarFilasOcultas(result,paramentidades,parammunicipio,paramcase,paramidioma,paramfuente,paramtema)
//    {
//        IDSIndicadores = result;
//        desgloseGeografico = desgloseGeograficoG;
//        continuaIniciarFilasOcultas(IDSIndicadores, desgloseGeografico);
//    }


function sigueIniciaFilasOcultas(contFilasAgregadas, idtema) {
    contFilasAgregadas = contFilasAgregadasG;
    desgloseGeografico = desgloseGeograficoG;
    table = tableG;

    if (m_fuente == undefined) {
        m_fuente = 0;
    }

    if (valores1.error == null) {
        //Agregar a tabla de indicadores recientes los indicadores.
        if (valores1.length >= 8) {
            var i, j = 0, indice

            indice = ObtenerIndiceTema(m_parametrosTema, table);

            for (i = indice[0] + 1; i < indice[1]; i++) {
                table.rows[i].style.display = 'none';
            }
            //alre_27092011
            //for (i = 0; i <= valores1.length - 7; i += 8) {
            //for (i = 0; i <= valores1.length - 7; i += 9) {
            for (i = 0; i <= valores1.length - 7; i += 10) {
                if (desgloseGeografico == 1) {
                    if ((valores1[i + 6] * 1) > desgloseGeografico) {
                        pintarBotonMapa = true;
                    }
                    else {
                        pintarBotonMapa = false
                    }
                    valor2 = null;
                }
                else {
                    if ((valores1[i + 6] * 1) > 2) {
                        pintarBotonMapa = true;
                    }
                    else {
                        pintarBotonMapa = false
                    }
                    valor2 = ObtenerSegundoValor(valores1[i], valores1[i + 4], valores2);
                }
                if (valores1[i + 5] == '' && valores1[i + 7] == '') {
                    pintarBotonInfo = false;
                }
                else {
                    pintarBotonInfo = true;
                }
                if (parseInt(valores1[i + 9]) > 1) {
                    pintarBotonGrafica = true;
                }
                else {
                    pintarBotonGrafica = false;
                 }


                //alre_30092011 replaceAdjacentText() = replaceAdjacentText(where, newText)
                indicetema=indice[0];
                //var imagen = document.getElementById("imagen_" + m_parametrosTema);
               
                
                //Agregado por HGL
                if (m_fuente == 0) {
                    //alre_17022011
                    PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], valor2, desgloseGeografico, true, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo, m_fuente, pintarBotonGrafica);
                }
                else {
                    if (m_fuente == valores1[i + 7]) {
                        PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], valor2, desgloseGeografico, true, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo, m_fuente, pintarBotonGrafica);
                    }
                }

                //if (IDSIndicadores.indexOf('[' + valores1[i] + ']') < 0) {
                    contFilasAgregadas++;
                //}

                j++;
            }
            //alert("pintaindicador");
            var imagen = document.getElementById("div_" + idtema);
            if (imagen != null) {
                //table.rows[indicetema].cells[0].removeChild(imagen);
                imagen.parentNode.removeChild(imagen);
            }
            if (contFilasAgregadas > 0 && m_fuente == 0) {
                var td;
                m_botonTema = document.getElementById('iu_a' + m_parametrosTema);
                //td = m_botonTema.parentElement;
                if (m_botonTema != undefined) {
                    td = m_botonTema.parentNode;
                    td.removeChild(m_botonTema);
                }
                else {
                    td = m_botonTema.parentNode;
                    td.removeChild(m_botonTema);
                 }
                
                m_botonTema = document.createElement('a');
                m_botonTema.className = 'Anchor';
                m_botonTema.id = 'iu_a' + m_parametrosTema;
                if (m_textos == undefined) {
                    texto2 = "Ver básicos";
                }
                else {
                    texto2 = m_textos[2];
                 }
                m_botonTema.innerHTML = texto2;
                parametros = { temaID: m_parametrosTema.temaID }
                //YAHOO.util.Event.addListener(m_botonTema, 'click', MostrarFilasOcultas, parametros);
                m_botonTema.href = "javascript:MostrarFilasOcultas('" + m_parametrosTema + "');";
                //MostrarFilasOcultas(m_parametrosTema);
                td.appendChild(m_botonTema);
            }
            else {

                if (m_fuente == 0)
                    m_botonTema.style.display = 'none';
            }
        }
        else {
            var imagen = document.getElementById("div_" + idtema);
            if (imagen != null) {
                //table.rows[indicetema].cells[0].removeChild(imagen);
                imagen.parentNode.removeChild(imagen);
            }
            if (m_fuente == 0)
                m_botonTema.style.display = 'none';
        }

        if (m_fuente == 0) {
            loadingPopup = $find('B2');
            if (loadingPopup != null) {
                loadingPopup.hide();
            }
        }
    }
    else {
        LanzarExcepcionWebServiceFillAjax(valores1.error.Message);
    }

}

function ContinuaGenerarListaMunicipios(municipios) {
    if (municipios.error == null) {
        lista = document.getElementById('iu_selMunicipios');
        lista.options.length = 0;
        //alre_20072011 se agrega una validación para cuando no se obtengan valores
        if (municipios != null) {
            if (municipios.length > 0) {
                document.getElementById('iu_tdMunicipio').style.visibility = 'visible';
                AgregarOpcionALista(lista, '0', m_textos[18]);
                for (i = 0; i <= municipios.length - 2; i += 2) {
                    if (document.getElementById('iu_hidYaSeGeneroDatos').value == 'N' && document.getElementById('iu_hidM').value != '') {
                        if (document.getElementById('iu_hidM').value == municipios[i]) {
                            indiceSeleccionado = (i / 2) + 1;
                        }
                    }
                    //alre_24032011
                    else {
                        if (municipioID == municipios[i]) {
                            indiceSeleccionado = (i / 2) + 1;
                        }
                    }
                    AgregarOpcionALista(lista, municipios[i], municipios[i + 1]);
                }
                if (indiceSeleccionado == -1) {
                    lista.selectedIndex = 0;
                    document.getElementById('iu_hidMunicipioID').value = '0';
                }
                else {
                    lista.selectedIndex = indiceSeleccionado;
                    document.getElementById('iu_hidMunicipioID').value = lista.options[lista.selectedIndex].value;
                }
            }
            else {
                document.getElementById('iu_tdMunicipio').style.visibility = 'hidden';
            }
        }
        else {
            document.getElementById('iu_tdMunicipio').style.visibility = 'hidden';
        }
    }
    else {
        LanzarExcepcionWebServiceFillAjax(municipios.error.Message);
    }
    EstablecerTituloUbicacion();
    var entidades = document.getElementById('iu_selEntidades');
    CargarImagenRepresentativa(document.getElementById('iu_imgImagenUbicacion2'), entidades.options[entidades.selectedIndex].value, '');
    continua = continuaG;
    if (continua == undefined && continua == null) {
        GenerarTablaIndicadoresRecientes();
    }
}

function continuaGenerarListaLocalidades() {
    if (Localidades.error == null) {
        lista = document.getElementById('iu_selLocalidad');
        lista.options.length = 0;
        if (Localidades.value.length > 0) {
            AgregarOpcionALista(lista, '0', m_textos[18]);
            for (i = 0; i <= Localidades.value.length - 2; i += 2) {
                if (document.getElementById('iu_hidYaSeGeneroDatos').value == 'N' && document.getElementById('iu_hidM').value != '') {
                    if (document.getElementById('iu_hidL').value == Localidades.value[i]) {
                        indiceSeleccionado = (i / 2) + 1;
                    }
                }
                //alre_24032011
                else {
                    if (localidadID == Localidades.value[i]) {
                        indiceSeleccionado = (i / 2) + 1;

                    }
                }
                AgregarOpcionALista(lista, Localidades.value[i], Localidades.value[i + 1]);
            }
            if (indiceSeleccionado == -1) {
                lista.selectedIndex = 0;
                document.getElementById('iu_hidLocalidadID').value = '0';
            }
            else {
                lista.selectedIndex = indiceSeleccionado;
                document.getElementById('iu_hidLocalidadID').value = lista.options[lista.selectedIndex].value;
            }
        }
        else {
            document.getElementById('iu_hidLocalidadID').style.visibility = 'hidden';
        }
    }
    else {
        LanzarExcepcionWebServiceFillAjax(municipios.error.Message);
    }
}

function continuaIndicadores(IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico) {
//    IDSIndicadores = IDSIndicadores.replace(/\]/g, ',').replace(/\[/g, '');
    //    IDSIndicadores = IDSIndicadores.substring(0, IDSIndicadores.length - 1);
    IDSIndicadores = 0;
    var paramentidades, parammunicipio, paramcase, paramidioma, paramfuente, paramtema, paramIDSIndicadores
    municipios = municipiosG;
    entidades = entidadesG;
    switch (desgloseGeografico) {
        case 1:
            //alre_17022011 se agrega el parametro de la fuente para realizar este filtro.
            //valores1 = servicioAjax.EncontrarValoresRecientesPorUbicacion('0', '0', '0', IDSIndicadores, m_idioma);
            if (m_fuente != "0" && m_fuente != "") {
                paramentidades = "0";
                parammunicipio = "0";
                paramcase = "1";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramtema = "0";
                paramIDSIndicadores = '';

                //  valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', '0', '', m_idioma, m_fuente);
            }
            else {
                paramentidades = "0";
                parammunicipio = "0";
                paramcase = "1";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramtema = "0";
                paramIDSIndicadores = IDSIndicadores;


                //  valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', '0', IDSIndicadores, m_idioma, m_fuente);

            }
            break;
        case 2:
            if (m_fuente != "0" && m_fuente != "") {

                paramentidades = entidades.options[entidades.selectedIndex].value;
                parammunicipio = municipios.options[municipios.selectedIndex].value;
                paramcase = "2";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = '';

                // valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', '', m_idioma, m_fuente)
                //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', '0', '', m_idioma, m_fuente);
            }
            else {
                paramentidades = entidades.options[entidades.selectedIndex].value;
                parammunicipio = municipios.options[municipios.selectedIndex].value;
                paramcase = "2";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = IDSIndicadores;


                // valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', IDSIndicadores, m_idioma, m_fuente);
                //valores2 = sWebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', '0', IDSIndicadores, m_idioma, m_fuente);
            }

            break;
        case 3:
            if (m_fuente != "0" && m_fuente != "") {
                paramentidades = entidades.options[entidades.selectedIndex].value;
                parammunicipio = municipios.options[municipios.selectedIndex].value;
                paramcase = "3";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = '';
                //valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', '', m_idioma, m_fuente);
                //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, '0', '0', '', m_idioma, m_fuente);
            }
            else {
                paramentidades = entidades.options[entidades.selectedIndex].value;
                parammunicipio = municipios.options[municipios.selectedIndex].value;
                paramcase = "3";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = IDSIndicadores;
                //valores1 = sWebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', IDSIndicadores, m_idioma, m_fuente);
                //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, '0', '0', IDSIndicadores, m_idioma, m_fuente);

            }
            break;

    }
    desgloseGeograficoG = desgloseGeografico;
    temaPadreActualG = temaPadreActual;
    entidadIDG = paramentidades;
    nombreUbicacion1G = nombreUbicacion1;
    nombreUbicacion2G = nombreUbicacion2;
    extensionColumnaG = extensionColumna;
    desgloseGeograficoG = desgloseGeografico;
    if (paramidioma == undefined) {
        paramidioma = "";
     }
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(paramentidades, parammunicipio, paramtema, paramIDSIndicadores, paramidioma, paramfuente, callBackcontinuaIndicadores, ObtenError, IDSIndicadores);
}


function siguecontinuaIndicadores(temaPadreActual, table, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico) {
    table = tableG;
    nombreUbicacion1 = nombreUbicacion1G;
    nombreUbicacion2 = nombreUbicacion2G;
    extensionColumna = extensionColumnaG;
    desgloseGeografico = desgloseGeograficoG;
    entidades = entidadesG;
    var pinta = true;
    //Chequeo para pintar las filas de Temas
    if (temas.error == null) {
        m_indicesTemas = new Array(temas.length / 2 + temas.length / 4 + 3);
        j = 0;
        //Agregar a tabla de indicadores recientes los temas.
        for (i = 0; i <= temas.length - 4; i += 4) {
            if (temaPadreActual != temas[i + 3]) {
                if (temas[i + 3] == '') {
                    PintarFilaTemaPadre(table, m_textos[0], nombreUbicacion1, nombreUbicacion2);
                }
                else {
                    PintarFilaTemaPadre(table, temas[i + 3], nombreUbicacion1, nombreUbicacion2);
                }
                temaPadreActual = temas[i + 3];
            }
            //Agregado por HGL para comprobar que si existe una fuente, se pinten sólo los temas correspondientes           
            if (valores1.error == null) {
                if (parseInt(temas[i + 5].toString()) < 3 && parseInt(temas[i + 5].toString()) == parseInt(temas[i + 6].toString()) && temas[i + 2].toString() != "") {
                    pinta = false;
                }
                else {
                    pinta = true;
                 }
                if (m_fuente == 0) {
                    if (temas[i + 5] != "0") {
                        PintarFilaTema(table, extensionColumna, temas[i], temas[i + 1],pinta);
                    }
                }
                else {
                    //for (k = 0; k <= valores1.length - 7; k += 8) {
                    for (k = 0; k <= valores1.length - 7; k += 10) {
                        if (m_fuente == valores1[k + 7]) {

                            if (valores1[k + 2] == temas.value[i]) {
                                if (temas[i + 5] != "0") {
                                    PintarFilaTema(table, extensionColumna, temas.value[i], temas.value[i + 1],pinta);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            m_indicesTemas[j] = temas[i];
            m_indicesTemas[j + 1] = table.rows.length - 1;
            m_indicesTemas[j + 2] = 0;
            j += 3;
        }
        m_indicesTemas[j] = '';
        m_indicesTemas[j + 1] = table.rows.length;
        m_indicesTemas[j + 2] = 0;

        var yaEntro = false;
        //Chequeo para pintar las filas de Indicadores
        if (valores1.error == null) {

            //Agregar a tabla de indicadores recientes los indicadores.
            if (valores1.length >= 8) {
                temaPadreActual = -1;
                //for (i = 0; i <= valores1.length - 7; i += 8) {
                for (i = 0; i <= valores1.length - 7; i += 10) {
                    if (temaPadreActual != valores1[i + 2]) {
                        temaPadreActual = valores1[i + 2];
                        j = 0;
                    }
                    if (valores1[i + 5] == '' && valores1[i + 7] == '') {
                        pintarBotonInfo = false;
                    }
                    else {
                        pintarBotonInfo = true;
                    }
                    if (parseInt(valores1[i + 9]) > 1) {
                        pintarBotonGrafica = true;
                    }
                    else {
                        pintarBotonGrafica = false;
                    }
                    if (desgloseGeografico == 1) {
                        if ((valores1[i + 6] * 1) > desgloseGeografico) {
                            pintarBotonMapa = true;
                        }
                        else {
                            pintarBotonMapa = false
                        }
                        //Agregado por HGL para pintar sólo los indicadores (todos, incluyendo ocultos)
                        // que corresponden a una fuente específica, si esta existe
                        //if(m_fuente == 0) {
                        //PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], null, desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo);
                        //alre_17022011
                        PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], null, desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo, m_fuente, pintarBotonGrafica);
                        //}
                        //else {
                        //if(m_fuente == valores1[i + 7]) {                                
                        //     m_parametrosTema = {temaID : (valores1[i + 2])};                                
                        //     if (!yaEntro) {
                        //         IniciarFilasOcultas();
                        //         yaEntro = true
                        //     }
                        // }

                    }
                    else {
                        if ((valores1[i + 6] * 1) > 2) {
                            pintarBotonMapa = true;
                        }
                        else {
                            pintarBotonMapa = false
                        }
                        //alre_17022011
                        PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], ObtenerSegundoValor(valores1[i], valores1[i + 4], valores2), desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo, m_fuente);
                        //PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], ObtenerSegundoValor(valores1[i], valores1[i + 4], valores1), desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo);
                        //Agregado por HGL para pintar sólo los indicadores (todos, incluyendo ocultos)
                        // que corresponden a una fuente específica, si esta existe
                        //if(m_fuente == 0) {
                        //PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], ObtenerSegundoValor(valores1[i], valores1[i + 4], valores1), desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo);
                        //}
                        //else {
                        //    if(m_fuente == valores1[i + 7]) {                                
                        //        m_parametrosTema = {temaID : (valores1[i + 2])};                                
                        //        IniciarFilasOcultas();
                        //    }                                                                                       
                        //}
                    }
                    j++;
                }

                //Agregar a tabla de indicadores recientes tema de Geografía.
                //                if(m_fuente == 0) {
                if (municipios != "") {
                    if (municipios.options.length > 0) {
                        PintarTemaGeografia(table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidades[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value);
                    }
                    else {
                        PintarTemaGeografia(table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidades[entidades.selectedIndex].value, '0');
                    }
                }
                //                }                                
            }

            loadingPopup = $find('B2');
            if (loadingPopup != null) {
                loadingPopup.hide();
            }

            m_fch = new Date();
            m_fin = m_fch.getTime();
            document.getElementById('iu_spanTiempo').innerHTML = (m_fin - m_ini) + ' ms';
        }
        else 
        {
            LanzarExcepcionWebServiceFillAjax(valores1.error.Message);
        }
    }
    else 
    {
        LanzarExcepcionWebServiceFillAjax(temas.error.Message);
    }
}

function pintatabla(temaPadreActual, table, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico) 
{
    table = tableG;
    nombreUbicacion1 = nombreUbicacion1G;
    nombreUbicacion2 = nombreUbicacion2G;
    extensionColumna = extensionColumnaG;
    desgloseGeografico = desgloseGeograficoG;
    entidades = entidadesG;
    var pinta = true;
    //Chequeo para pintar las filas de Temas
    if (temas.error == null) {
    //alre_17082011
        //m_indicesTemas = new Array(temas.length / 2 + temas.length / 4 + 3);
        //m_indicesTemas = new Array(temas.length / 2 + temas.length / 6 + 3);
        m_indicesTemas = new Array(temas.length / 2 + temas.length / 7 + 3);
        j = 0;
        //Agregar a tabla de indicadores recientes los temas.
        var superior = 0,padre='';
        //for (i = 0; i <= temas.length - 4; i += 4) {
        //for (i = 0; i <= temas.length - 6; i += 6) {
        for (i = 0; i <= temas.length - 7; i += 7) {
//            if (temaPadreActual != temas[i + 3]) {
                if (temas[i + 3] == '') 
                {
                    if (i == 0) {
//                        if (temas[i + 5] != "0") {
                            PintarFilaTemaPadre(table, "", nombreUbicacion1, nombreUbicacion2);
//                        }
                    }
                    
                }
//                else {
//                    PintarFilaTemaPadre(table, temas[i + 3], nombreUbicacion1, nombreUbicacion2);
//                }
//                temaPadreActual = temas[i + 3];
//                
//            }
            //Agregado por HGL para comprobar que si existe una fuente, se pinten sólo los temas correspondientes           
                if (valores1.error == null) {
                    if (parseInt(temas[i + 5].toString()) <= 3 && parseInt(temas[i + 5].toString()) == parseInt(temas[i + 6].toString()) && temas[i + 2].toString() != "") {
                        pinta = false;
                    }
                    else {
                        pinta = true;
                     }
                if (m_fuente == 0) {
                    if (temas[i + 3] == '') {
                        //if (temas[i + 4] == "1" && temas[i + 5] !="0") {
                        if (temas[i + 4] == "1") {
//                            if (temas[i + 5] == "0") {
                                PintarFilaTemaSuperior(table, extensionColumna, temas[i], temas[i + 1], "false");
//                            }
//                            else {
//                                PintarFilaTemaSuperior(table, extensionColumna, temas[i], temas[i + 1], "true");
//                             }
                        }
                        else {
                            PintarFilaTemaSuperior(table, extensionColumna, superior, temas[i + 1],"false");
                        }
                        superior += 1;
                    } 
                    else {
                        if (temas[i + 5] != "0") 
                            {
                            
                                PintarFilaTema(table, extensionColumna, temas[i], temas[i + 1],pinta);
                            }
                    }
                }
                else {
                //alre_27092011
                    //for (k = 0; k <= valores1.length - 7; k += 8) {
                    //for (k = 0; k <= valores1.length - 7; k += 9) {
                    for (k = 0; k <= valores1.length - 7; k += 10) {
                        if (m_fuente == valores1[k + 7]) {
                            if (valores1[k + 2] == temas[i]) {
                                if (padre == '' || padre != temas[i].toString().substring(0, 2)) {
                                    padre = temas[i].toString().substring(0, 2);
                                    PintarFilaTemaSuperior(table, extensionColumna, temas[i+2], temas[i + 3], "false");
                                    superior += 1;
                                }
                                if (temas[i + 5] != "0") {
                                    PintarFilaTema(table, extensionColumna, temas[i], temas[i + 1],pinta);
                                }
                                break;
                            }
                        
                        }
                    }
                }
            }
            m_indicesTemas[j] = temas[i];
            m_indicesTemas[j + 1] = table.rows.length - 1;
            m_indicesTemas[j + 2] = 0;
            j += 3;
        }
        m_indicesTemas[j] = '';
        m_indicesTemas[j + 1] = table.rows.length;
        m_indicesTemas[j + 2] = 0;

        var yaEntro = false;
        //Chequeo para pintar las filas de Indicadores
        if (valores1.error == null) {

            //Agregar a tabla de indicadores recientes los indicadores.
            if (valores1.length >= 8) {
                temaPadreActual = -1;
                //alre_27092011
                //for (i = 0; i <= valores1.length - 7; i += 8) {
                //for (i = 0; i <= valores1.length - 7; i += 9) {
                for (i = 0; i <= valores1.length - 7; i += 10) {
                    if (temaPadreActual != valores1[i + 2]) {
                        temaPadreActual = valores1[i + 2];
                        j = 0;
                    }
                    if (valores1[i + 5] == '' && valores1[i + 7] == '') {
                        pintarBotonInfo = false;
                    }
                    else {
                        pintarBotonInfo = true;
                    }
                    if (parseInt(valores1[i + 9]) > 1) {
                        pintarBotonGrafica = true;
                    }
                    else {
                        pintarBotonGrafica = false;
                    }
                    if (desgloseGeografico == 1) {
                        if ((valores1[i + 6] * 1) > desgloseGeografico) {
                            pintarBotonMapa = true;
                        }
                        else {
                            pintarBotonMapa = false
                        }
                        //Agregado por HGL para pintar sólo los indicadores (todos, incluyendo ocultos)
                        // que corresponden a una fuente específica, si esta existe
                        //if(m_fuente == 0) {
                        //PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], null, desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo);
                        //alre_17022011
                        PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], null, desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo, m_fuente, pintarBotonGrafica);
                        //}
                        //else {
                        //if(m_fuente == valores1[i + 7]) {                                
                        //     m_parametrosTema = {temaID : (valores1[i + 2])};                                
                        //     if (!yaEntro) {
                        //         IniciarFilasOcultas();
                        //         yaEntro = true
                        //     }
                        // }

                    }
                    else {
                        if ((valores1[i + 6] * 1) > 2) {
                            pintarBotonMapa = true;
                        }
                        else {
                            pintarBotonMapa = false
                        }
                        //alre_17022011
                        PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], ObtenerSegundoValor(valores1[i], valores1[i + 4], valores2), desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo, m_fuente, pintarBotonGrafica);
                        //PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], ObtenerSegundoValor(valores1[i], valores1[i + 4], valores1), desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo);
                        //Agregado por HGL para pintar sólo los indicadores (todos, incluyendo ocultos)
                        // que corresponden a una fuente específica, si esta existe
                        //if(m_fuente == 0) {
                        //PintarFilaIndicador(table, valores1[i + 2], valores1[i], valores1[i + 1], valores1[i + 4], valores1[i + 3], ObtenerSegundoValor(valores1[i], valores1[i + 4], valores1), desgloseGeografico, false, valores1[i + 5], pintarBotonMapa, ObtenerEstiloFilaIndicador(j), pintarBotonInfo);
                        //}
                        //else {
                        //    if(m_fuente == valores1[i + 7]) {                                
                        //        m_parametrosTema = {temaID : (valores1[i + 2])};                                
                        //        IniciarFilasOcultas();
                        //    }                                                                                       
                        //}
                    }
                    j++;
                }

                //Agregar a tabla de indicadores recientes tema de Geografía.
                //                if(m_fuente == 0) {
                if (municipios != "") {
                    if (municipios.options.length > 0) {
                        PintarTemaGeografia(table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidades[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value);
                    }
                    else {
                        PintarTemaGeografia(table, desgloseGeografico, nombreUbicacion1, nombreUbicacion2, entidades[entidades.selectedIndex].value, '0');
                    }
                }
                //                }                                
            }

            loadingPopup = $find('B2');
            if (loadingPopup != null) {
                loadingPopup.hide();
            }

            m_fch = new Date();
            m_fin = m_fch.getTime();
            document.getElementById('iu_spanTiempo').innerHTML = (m_fin - m_ini) + ' ms';
        }
        else {
            LanzarExcepcionWebServiceFillAjax(valores1.error.Message);
        }
    }
    else {
        LanzarExcepcionWebServiceFillAjax(temas.error.Message);
    }
 }


function callBackcontinuaIndicadores(result, IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico) {
    valores1 = result;
    desgloseGeografico = desgloseGeograficoG;
    temaPadreActual = temaPadreActualG;
    nombreUbicacion1 = nombreUbicacion1G;
    nombreUbicacion2 = nombreUbicacion2G;
    extensionColumna = extensionColumnaG;
    desgloseGeografico = desgloseGeograficoG;
    if (desgloseGeografico != "1") {
        IniciarDatos2(desgloseGeografico, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico, IDSIndicadores);
    }
    else {
    //alre_16082011 se cambia el llamado para pintar la nueva tabla
        //siguecontinuaIndicadores(temaPadreActual, tableG, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
        pintatabla(temaPadreActual, tableG, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
    }
}

function IniciarDatos2(desgloseGeografico, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico, IDSIndicadores) {
//    IDSIndicadores = IDSIndicadores.replace(/\]/g, ',').replace(/\[/g, '');
    //    IDSIndicadores = IDSIndicadores.substring(0, IDSIndicadores.length - 1);
    IDSIndicadores = 0;
    var paramentidades, parammunicipio, paramcase, paramidioma, paramfuente, paramtema, paramIDSIndicadores
    municipios = municipiosG;
    entidades = entidadesG;
    switch (desgloseGeografico) {
        case 2:
            if (m_fuente != "0" && m_fuente != "") {

                paramentidades = '0';
                parammunicipio = '0';
                paramcase = "2";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = '';

                // valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', '', m_idioma, m_fuente)
                //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', '0', '', m_idioma, m_fuente);
            }
            else {
                paramentidades = '0';
                parammunicipio = '0';
                paramcase = "2";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = IDSIndicadores;


                // valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', IDSIndicadores, m_idioma, m_fuente);
                //valores2 = sWebServiceFillAjax.EncontrarValoresRecientesPorUbicacion('0', '0', '0', IDSIndicadores, m_idioma, m_fuente);
            }

            break;
        case 3:
            if (m_fuente != "0" && m_fuente != "") {
                paramentidades = entidades.options[entidades.selectedIndex].value;
                parammunicipio = '0';
                paramcase = "3";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = '';
                //valores1 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', '', m_idioma, m_fuente);
                //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, '0', '0', '', m_idioma, m_fuente);
            }
            else {
                paramentidades = entidades.options[entidades.selectedIndex].value;
                parammunicipio = '0';
                paramcase = "3";
                paramtema = "0";
                paramidioma = m_idioma;
                paramfuente = m_fuente;
                paramIDSIndicadores = IDSIndicadores;
                //valores1 = sWebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, municipios.options[municipios.selectedIndex].value, '0', IDSIndicadores, m_idioma, m_fuente);
                //valores2 = WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidades.options[entidades.selectedIndex].value, '0', '0', IDSIndicadores, m_idioma, m_fuente);

            }
            break;
    }
    desgloseGeograficoG = desgloseGeografico;
    BISE.MexicoCifras.WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(paramentidades, parammunicipio, paramtema, paramIDSIndicadores, paramidioma, paramfuente, callBackcontinuaIndicadores2, ObtenError, IDSIndicadores);
}

function callBackcontinuaIndicadores2(result, IDSIndicadores) {
    valores2 = result;
    temaPadreActual = temaPadreActualG;
    nombreUbicacion1 = nombreUbicacion1G;
    nombreUbicacion2 = nombreUbicacion2G;
    extensionColumna = extensionColumnaG;
    desgloseGeografico = desgloseGeograficoG;
    //alre_1082011
    //siguecontinuaIndicadores(temaPadreActual, tableG, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
    pintatabla(temaPadreActual, tableG, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
}

function continuaEncontrarIndicadoresVisibles(IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico) {
    //Definición del arreglo de Indicadores
    //BISE.MexicoCifras.WebServiceFillAjax.EncontrarIndicadoresVisibles(desgloseGeografico, callBackcontinuaIndicadoresVisibles, ObtenError, IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
    IDSIndicadores = 0;
    continuaIndicadores(IDSIndicadores, temaPadreActual, nombreUbicacion1, nombreUbicacion2, extensionColumna, desgloseGeografico);
}

function callBackEncontrarValoresRecientesPorUbicacion(result) {
    valores1 = result;
    sigueEncuentraIndicadores();
}

function demandIndicador(entidad, municipio, tema, idioma, fuente) {
    m_parametrosTema = tema;
    IniciarFilasOcultas();
 //BISE.MexicoCifras.WebServiceFillAjax.EncontrarValoresRecientesPorUbicacion(entidad,municipio,tema,"",idioma,fuente,callBackdemanIndicador,ObtenError);
}

function callBackdemanIndicador(result)
{
    IniciarFilasOcultas();
}

function activaEntidades(entidadID, valortexto, idioma, continua) {
    continua = "no";
    continuaG = continua;
    document.getElementById('iu_tdBotonDatos').style.display = 'none';
    Textos(idioma, continua)
    MostrarSeccion("iu_divSeccionDatos");
    GenerarListaEntidades(entidadID, valortexto,continua);
 }

function IdentifiedActiveTab(sender, args) {
}

function serieHistorica(indicadorID, indicadorNombre, anio, fuente) {

}
