// Archivo JScript
var ABSLocalizacion = {
	pathGestor:"absmapaciudad/ws/gestor_busqueda.ashx",  // ubicacion gestor peticiones   
	Doc_XML :null    , // doc xml respuesta peticion AJAX  
	Req_XML : null,
	Total_Encontrados: 0,
	Total_Repetido: 0,
	Pos_Actual: 1,
	Max_Resultados: 7,
	Texto_Buscado: "",
	Texto_Buscado_2: "", //este texto se usa si se busca un cruce con una segunda calle
	MatchingBajo: false, //acierto bajo en la búsqueda (albert)
	TablaElemento:"" //tabla del elemento consultado (albert)
}


/************************************************************************/
/*Funciones que dependen del programa con el que se instale el control  */
/*Funciones que dependen del programa con el que se instale el control  */
/*Funciones que dependen del programa con el que se instale el control  */
/************************************************************************/

//MBR_Mapa_Min_X
ABSLocalizacion.MBR_Mapa_Min_X = function()
{
    return 751800;

}

//MBR_Mapa_Min_Y
ABSLocalizacion.MBR_Mapa_Min_Y = function()
{
    return 4430600;
}

//urlImgItem
ABSLocalizacion.urlImgItem = function()
{
    return ABSMapaCiudad.urlImgItem;
}

//urlImgFicha
ABSLocalizacion.urlImgFicha = function()
{
    return ABSMapaCiudad.urlImgFicha;
}

//urlImgZoom
ABSLocalizacion.urlImgZoom = function()
{
    return ABSMapaCiudad.urlImgZoom;
}

//urlImgCartel
ABSLocalizacion.urlImgCartel = function()
{
    return ABSMapaCiudad.urlImgCartel;
}

//mostrar_cartel
ABSLocalizacion.mostrar_cartel = function()
{
    return ABSMapaCiudad.mostrar_cartel;
}


//urlImgGoogle
ABSLocalizacion.urlImgGoogle = function()
{
    return ABSMapaCiudad.urlImgGoogle;
}

//mostrar_google
ABSLocalizacion.mostrar_google = function()
{
    return ABSMapaCiudad.mostrar_google;
}



//etqFitxa
ABSLocalizacion.etqFitxa = function()
{
    return ABSMapaCiudadLiteral.etqFitxa;
}

//etqFitxaLong
ABSLocalizacion.etqFitxaLong = function()
{
    return ABSMapaCiudadLiteral.etqFitxaLong;
}

//etqCentrar
ABSLocalizacion.etqCentrar = function()
{
    return ABSMapaCiudadLiteral.etqCentrar;
}


//etqGoogle
ABSLocalizacion.etqGoogle = function()
{
    return ABSMapaCiudadLiteral.etqGoogle;
    
}
//etqCentrarCompleta
ABSLocalizacion.etqCentrarCompleta = function()
{
    return ABSMapaCiudadLiteral.etqCentrarCompleta;
}

//etqCartel
ABSLocalizacion.etqCartel = function()
{
    return ABSMapaCiudadLiteral.etqCartel;
}

//CursorSeleccion
ABSLocalizacion.CursorSeleccion = function ()
{
    ABSMapaCiudad.CursorSeleccion();
}

//CursorDefault
ABSLocalizacion.CursorDefault = function ()
{
    ABSMapaCiudad.CursorDefault();
}

//Url_Imagen_Primera
ABSLocalizacion.Url_Imagen_Primera = function ()
{
  return ABSMapaCiudad.pathAbsatlas + "temas/" + ABSMapaCiudad.tema +"/img/primero.gif";
}

//Url_Imagen_Anterior
ABSLocalizacion.Url_Imagen_Anterior = function ()
{
  return ABSMapaCiudad.pathAbsatlas + "temas/" + ABSMapaCiudad.tema +"/img/anterior.gif";
}

//Url_Imagen_Siguiente
ABSLocalizacion.Url_Imagen_Siguiente = function ()
{
  return ABSMapaCiudad.pathAbsatlas + "temas/" + ABSMapaCiudad.tema +"/img/siguiente.gif";
}

//Url_Imagen_Ultima
ABSLocalizacion.Url_Imagen_Ultima = function ()
{
  return ABSMapaCiudad.pathAbsatlas + "temas/" + ABSMapaCiudad.tema +"/img/ultimo.gif";
}

  
//MostrarCarteles
ABSLocalizacion.MostrarCartel= function(minX, minY, maxX, maxY, 
        igm, _capa, _x, _y, _texto, _tituloCapa)
{
    ABSMapaCiudad.MostrarCartel(minX,minY,maxX,maxY, 
        igm,_capa,_x, _y, _texto, _tituloCapa)
}

//CentrarElemento
ABSLocalizacion.CentrarElemento_Y_Etiquetar= function( minX, minY, maxX, maxY,
     igms, capaId, resaltar, Capa, Centro_X, Centro_Y,  Texto_Cartel, Titulo_Cartel)
{
    

    
    ABSMapaCiudad.MostrarCartelInforme( minX, minY, maxX, maxY, 
    igms, Capa, Centro_X, Centro_Y, Texto_Cartel, Titulo_Cartel);
    
    
    ABSMapaCiudad.CentrarElemento (minX, minY, maxX, maxY,
     igms, capaId, resaltar);
   
    
}


//CentrarElemento
ABSLocalizacion.ZommCercadorGrafic= function( minX, minY, maxX, maxY,
     igms, capaId, resaltar, Capa, Centro_X, Centro_Y,  Texto_Cartel, Titulo_Cartel)
{
   

    ABSMapaCiudad.MostrarCartelInforme( minX, minY, maxX, maxY, 
    igms, Capa, Centro_X, Centro_Y, Texto_Cartel, Titulo_Cartel);  
}


//MostrarInforme                                        */
ABSLocalizacion.MostrarInforme = function (MinX, MinY, MaxX, MaxY,Lista_IGMs, CapaId, Mapa)
{
     
    ABSMapaCiudad.MostrarInforme(MinX, MinY, MaxX, MaxY,Lista_IGMs, CapaId, Mapa);
   
}

//Abrir en Google Erath
ABSLocalizacion.ConectarGoogleEarth = function ( igms, capaid )
{ 
    ABSMapaCiudad.ConectarGoogleEarth( igms, capaid);
}
     


/************************************************************************/
/*ABSLocalizacion.Buscar_On_Enter                                       */
/*                                                                      */
/* Tipo_Busqueda puede ser : 'GENERAL', 'POIS' o 'POSTAL' segun el      */
/* TextBox desde el que he hecho la llamada                             */
/************************************************************************/
ABSLocalizacion.Buscar_On_Enter= function(event, Tipo_Busqueda)
{
    var keycode;
    if (event.which) keycode = (event.which);
    else if (event) keycode = (event.keyCode);
    if (keycode==13) ABSLocalizacion.Buscar_Primero_Desde_TB(Tipo_Busqueda);
}


/************************************************************************/
/*ABSLocalizacion.Buscar_Primero_Desde_TB                               */
/*                                                                      */
/* Tipo_Busqueda puede ser : 'GENERAL', 'POIS' o 'POSTAL' segun el      */
/* TextBox desde el que he hecho la llamada                             */
/************************************************************************/
ABSLocalizacion.Buscar_Primero_Desde_TB= function(Tipo_Busqueda)
{
    this.Texto_Buscado="";
    ABSLocalizacion.Buscar_Primero(Tipo_Busqueda);
}
                
/************************************************************************/
/*ABSLocalizacion.Buscar                                                */
/*                                                                      */
/* Tipo_Busqueda puede ser : 'GENERAL', 'POIS' o 'POSTAL' segun el      */
/* TextBox desde el que he hecho la llamada                             */
/************************************************************************/
ABSLocalizacion.Buscar= function(Tipo_Busqueda)
{
   
    if(Tipo_Busqueda == "GRAFICO"){
    
       if (this.Texto_Buscado_2== "")
        {
            alert(ABSLocalizacion_Literal.TEXTO_TB_BUSQUEDA_VACIO);
            return;
        }
        if (this.Texto_Buscado_2.length < 2)
        {
            alert(ABSLocalizacion_Literal.TEXTO_TB_BUSQUEDA_MUY_CORTO);
            return;
        }
    
    }
    else if(Tipo_Busqueda == "GRAFICO_TOT"){
      //Tipo_Busqueda = "GRAFICO";
    }
    else{ 
    
        if (this.Texto_Buscado=="")
        {
            alert(ABSLocalizacion_Literal.TEXTO_TB_BUSQUEDA_VACIO);
            return;
        }
        if (this.Texto_Buscado.length<2)
        {
            alert(ABSLocalizacion_Literal.TEXTO_TB_BUSQUEDA_MUY_CORTO);
            return;
        }
     }
 
 
    // Referencia a ABS MAPAS
	var absmapas = ObtenerABSMapas();
	if ( !absmapas ) 
	{
	    alert (ABSLocalizacion_Literal.ERROR_CARGA_PAGINA);
	    return;
	}		
    
	// Comprobar mapa cargado
	var mapa = absmapas.mapa;
	if ( !mapa ) 
	{
	    alert (ABSLocalizacion_Literal.ERROR_PETICION_NO_PROCESADA);
	    return;
	}		
     
    // Crear petición
    //El Tipo_Busqueda se pone como comando, porque ase sabemos si buscamos
    //de forma general GENERAL, buscamos POIS o buscamos calles POSTAL
     var peticion = absmapas.CrearPeticion
	( 		
			Tipo_Busqueda, // Comando
		    ABSMapaCiudad.pathAbsatlas + ABSLocalizacion.pathGestor
	);  
    
    //Ponemos el parametro del texto a buscar
    peticion.parametros["TEXTO_A_BUSCAR"] = encodeURIComponent(this.Texto_Buscado);    
    peticion.parametros["TEXTO_A_BUSCAR_2"] = encodeURIComponent(this.Texto_Buscado_2);
    peticion.parametros["BUSQUEDA_POS_ACTUAL"] = this.Pos_Actual;    
    peticion.parametros["BUSQUEDA_MAX_RESULTADOS"] = ABSLocalizacion.Max_Resultados;    


 
    // Obtener XML con peticion al Handler gestor_peticion 
    var Url_Peticion = peticion.Url();
    
    
     //this.Doc_XML = absmapas.HttpGetXml( peticion.Url());

    if (window.XMLHttpRequest)
    {
        this.Req_XML = new XMLHttpRequest();
        this.Req_XML.onreadystatechange = ABSLocalizacion.Buscar_Recepcion_XML(this);
        this.Req_XML.open("GET", Url_Peticion, true);
        this.Req_XML.send(null);        
    } 
    else if (window.ActiveXObject)
    {
        this.Req_XML = new ActiveXObject("Microsoft.XMLHTTP");
        this.Req_XML.onreadystatechange = ABSLocalizacion.Buscar_Recepcion_XML(this);
        this.Req_XML.open("GET", Url_Peticion, true);
        this.Req_XML.send(null);   
    }
    else
    {
        alert (ABSLocalizacion_Literal.TEXTO_BUSQUEDA_NO_LANZADA);
    }
    

        var DIV_Resultado= document.getElementById("WebPanelInfo_divInfoContent");   
        ABSMapaCiudad.MostrarPanelInformacion(); 
        //DIV_Resultado.innerHTML=ABSLocalizacion_Literal.TEXTO_CARGANDO_BUSQUEDA;

        
        DIV_Resultado.innerHTML= "<br /><br /><div align='center'>" + 
         ABSLocalizacion_Literal.TEXTO_CARGANDO_BUSQUEDA + 
        "<br /><br /><img alt='carga' src='" +
	      ABSMapaCiudad.urlImgCargar + 
	       "'/>" ;
        
    return;
}

/************************************************************************/
/*ABSLocalizacion.VaciarTextBox                                         */
/************************************************************************/
ABSLocalizacion.VaciarTextBox = function(idElem)
{

  var textBox= document.getElementById(idElem);   
  if(textBox){

     
     if(textBox.className =='clsTBBusquedaDefault')
        textBox.value='';    
     textBox.className='clsTBBusqueda'; 
    }
  return;
}


/************************************************************************/
/*ABSLocalizacion.Buscar_Recepcion_XML                                  */
/************************************************************************/
ABSLocalizacion.Buscar_Recepcion_XML= function(Objeto)
{
    var _this = Objeto;
    function Buscar_Recepcion_XML_Func()
    {
        if (ABSLocalizacion.Req_XML.readyState == 4)
        {
            if (window.XMLHttpRequest)
            {
		        ABSLocalizacion.Doc_XML = new DocXmlMoz(ABSLocalizacion.Req_XML.responseXML, ABSLocalizacion.Req_XML.responseText);
            } 
            else if (window.ActiveXObject)
            {
                ABSLocalizacion.Doc_XML = new DocXmlMs(ABSLocalizacion.Req_XML.responseXML, ABSLocalizacion.Req_XML.responseText);
            }
    			
            if ( !ABSLocalizacion.Doc_XML )
            {
                alert (ABSLocalizacion_Literal.ERROR_PETICION_NO_PROCESADA_REINTENTAR);
	        } 
            
            var texto_HTML = _this.Crear_Pag_Result();
            var DIV_Resultado= document.getElementById("WebPanelInfo_divInfoContent");     
            DIV_Resultado.innerHTML=texto_HTML;
        }
    }
    return Buscar_Recepcion_XML_Func;
}


/************************************************************************/
/*ABSLocalizacion.Crear_Pag_Result                                      */
/************************************************************************/
ABSLocalizacion.Crear_Pag_Result = function ()
{
    var Cad_HTML="";
    this.MatchingBajo =false; 
    this.TablaElem=null;
    
	this.Total_Encontrados = parseInt(this.Doc_XML.TextoNodo(this.Doc_XML.root, "Total_Encontrados"));
	this.Pos_Actual = parseInt(this.Doc_XML.TextoNodo(this.Doc_XML.root, "Pos_Actual"));
    
    //En el XML devuelto nos viene el tipo de busqueda que hemos heche (GNERAL, POIs, ...)
    //para poder configurar los botones de manera adecuada
    var Tipo_Busqueda = this.Doc_XML.TextoNodo(this.Doc_XML.root, "Tipo_Busqueda");
    var Nodo_Registros = this.Doc_XML.SeleccionarNodo(this.Doc_XML.root, "Registros");
    var Lista_Registros = this.Doc_XML.SeleccionarNodos(Nodo_Registros,"Registro");    
    
    this.Total_Repetido = parseInt(this.Doc_XML.TextoNodo(this.Doc_XML.root, "Total_Repetidos"));
   
    if (this.Total_Encontrados>0)
    {   
        Cad_HTML += "<table>";
        Cad_HTML += "<tr>";
	     Cad_HTML += "<td  class=\"clsTextoResultado\" nowrap >";
	    Cad_HTML += ABSLocalizacion_Literal.TEXTO_BUSCADO + ": <span  style=\"font-weight:normal;font-style:italic;\">" + this.Texto_Buscado + "</span><br/>";
        Cad_HTML += ABSLocalizacion_Literal.TEXTO_TOTAL_RESULTADOS + this.Total_Encontrados + "&nbsp; <span style=\"font-weight:normal;font-style:italic;\">" + ABSLocalizacion_Literal.TEXTO_AUX_TOTAL_REGISTROS+"</span>";
	     Cad_HTML += "</td>";
        Cad_HTML += "</tr>";		 
        Cad_HTML += "</table>";

        Cad_HTML += "<hr/>";		
        
        Cad_HTML += ABSLocalizacion.Crear_Pag_Result_Tabla_Result (Tipo_Busqueda);
        Cad_HTML += "<hr/>";		

        Cad_HTML += "<table>";
        Cad_HTML += "<tr>";
	     Cad_HTML += "<td class=\"clsTextoContador\">";
        Cad_HTML += ABSLocalizacion_Literal.TEXTO_RESULTADOS_DEL + 
                    this.Pos_Actual + ABSLocalizacion_Literal.TEXTO_RESULTADOS_AL + 
                   (((this.Pos_Actual + ABSLocalizacion.Max_Resultados + this.Total_Repetido  ) > parseInt(this.Total_Encontrados))?this.Total_Encontrados:(this.Pos_Actual + ABSLocalizacion.Max_Resultados + this.Total_Repetido - 1)) ;
	     Cad_HTML += "</td>";
        Cad_HTML += "</tr>";		
        Cad_HTML += "</table>";

        Cad_HTML += ABSLocalizacion.Agregar_Botonera(Tipo_Busqueda);
    }else
    {
       Cad_HTML += "<table>";

        Cad_HTML += "<tr>";
	    Cad_HTML += "<td  class=\"clsTextoResultado\" nowrap >";
	    Cad_HTML += ABSLocalizacion_Literal.TEXTO_BUSCADO + ": <span  style=\"font-weight:normal;font-style:italic;\">" + this.Texto_Buscado + "</span><br/>";
        Cad_HTML += ABSLocalizacion_Literal.TEXTO_TOTAL_RESULTADOS + this.Total_Encontrados+"&nbsp;<span  style=\"font-weight:normal;font-style:italic;\">" +ABSLocalizacion_Literal.TEXTO_AUX_TOTAL_REGISTROS +"</span>";
	    Cad_HTML += "</td>";
        Cad_HTML += "</tr>";		

        Cad_HTML += "<tr>";
	    Cad_HTML += "<td class=\"clsTextoResultado\">";

        if(Tipo_Busqueda == "GENERAL")
        {
            Cad_HTML += ABSLocalizacion_Literal.TEXTO_SIN_RESULTADOS_GENERAL;
        }
        else if(Tipo_Busqueda == "POIS")
        {
            Cad_HTML += ABSLocalizacion_Literal.TEXTO_SIN_RESULTADOS_POIS;
        }
        else if (Tipo_Busqueda == "POSTAL")
        {
            Cad_HTML += ABSLocalizacion_Literal.TEXTO_SIN_RESULTADOS_POSTAL;
        }
        else if (Tipo_Busqueda == "GRAFICO" || Tipo_Busqueda == "GRAFICO_TOT" ){
          Cad_HTML += ABSLocalizacion_Literal.TEXTO_SIN_RESULTADOS_GRAFICO;
          var txtError = this.Doc_XML.TextoNodo(this.Doc_XML.root, "ERROR");
          if(txtError != null && txtError != ""){
              Cad_HTML += "<br><span class=\"clsTBBusquedaDefault\">" + txtError + "</span><br><br>";
          }
          else{
              Cad_HTML += ABSLocalizacion_Literal.TEXTO_SIN_RESULTADOS_GRAFICO2;
          }
        }
        else
        {
            Cad_HTML += ABSLocalizacion_Literal.TEXTO_SIN_RESULTADOS_GENERAL;
        } 
	    Cad_HTML += "</td>";
        Cad_HTML += "</tr>";		

        Cad_HTML += "</table>";
    }
    


    return Cad_HTML;
}


ABSLocalizacion.CreaFuncionMarcar = function(arrIgm , Nodo_Registro , MBR_MaxX, MBR_MaxY , MBR_MinX , MBR_MinY, mostrarInforme)
{
    var Cad_HTML="";

    var Centro_X = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_X").replace(',','.'));
    var Centro_Y = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_Y").replace(',','.'));
    var Tabla_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Tabla_Elemento");
    var Clave_UBIGEO = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_UBIGEO");
    var Clave_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_Elemento");
    var Descripcion_Elemento = unescape(this.Doc_XML.TextoNodo(Nodo_Registro, "Descripcion_Elemento"));
   
    var AA_IGMs = arrIgm
    
    if (Tabla_Elemento=="LOCG_CRUCES")
    {
        Descripcion_Elemento = ABSLocalizacion_Literal.TEXTO_CRUCE + Descripcion_Elemento;
    }
    
    if (MBR_MinX==0) MBR_MinX =ABSLocalizacion.MBR_Mapa_Min_X() - 100;
    if (MBR_MaxX==0) MBR_MaxX =ABSLocalizacion.MBR_Mapa_Min_X() + 100;
    if (Centro_X==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        { Centro_X =MBR_MinX;}
        else
        {  Centro_X =ABSLocalizacion.MBR_Mapa_Min_X();}
    }

    if (MBR_MinY==0) MBR_MinY =ABSLocalizacion.MBR_Mapa_Min_Y() - 100;
    if (MBR_MaxY==0) MBR_MaxY =ABSLocalizacion.MBR_Mapa_Min_Y() + 100;
    if (Centro_Y==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        { Centro_Y =MBR_MinY; }
        else
        {  Centro_Y =ABSLocalizacion.MBR_Mapa_Min_Y();}
    }
    
    var cercadorGrafic =  document.getElementById("WebPanelBusquedaGrafica_LBBusquedaGrafica1");
    var mapLit         = cercadorGrafic.options[cercadorGrafic.selectedIndex].value
    
    
     if(mostrarInforme){
     
        if(ABSLocalizacion.isArray(AA_IGMs) && AA_IGMs.length > 1){
        
        
          Cad_HTML += "ABSMapaCiudad.MostrarInformeCercadorGrafic(" +
                         MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                         ", new Array(" + AA_IGMs +") ,'" + Tabla_Elemento + 
                         "'); ";
        
        }
        
        else{
 
          
          Cad_HTML += "ABSMapaCiudad.MostrarInformeCercadorGrafic(" +
                         MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                         ", '" + AA_IGMs +"','" + Tabla_Elemento + 
                         "'); ";
                     
        }             
                     
                     

    }
    else{
    
            if(ABSLocalizacion.isArray(AA_IGMs) && AA_IGMs.length > 1){

                Cad_HTML += "ABSMapaCiudad.CentrarElementoCercadorGrafic(" +
                             MBR_MinX + ", " + MBR_MinY + ", " + MBR_MaxX + ", " + MBR_MaxY + 
                              ", new Array(" + AA_IGMs + ") ,'" + Tabla_Elemento + "', 1, '" + 
                              Tabla_Elemento + "', " + Centro_X + ", " + Centro_Y + ", '" + 
                              Descripcion_Elemento + 
                              "' , '" + mapLit + "'); ";
             }
             else{
                Cad_HTML += "ABSMapaCiudad.CentrarElementoCercadorGrafic(" +
                             MBR_MinX + ", " + MBR_MinY + ", " + MBR_MaxX + ", " + MBR_MaxY + 
                              ", '" + AA_IGMs + "' ,'" + Tabla_Elemento + "', 1, '" + 
                              Tabla_Elemento + "', " + Centro_X + ", " + Centro_Y + ", '" + 
                              Descripcion_Elemento + 
                              "' , '" + mapLit + "'); ";
             }       
    }                 

    return Cad_HTML;
}


/************************************************************************/
/*ABSLocalizacion.Crear_Pag_Result_Tabla_Result                         */
/************************************************************************/
ABSLocalizacion.Crear_Pag_Result_Tabla_Result = function(Tipo_Busqueda) {
    var Cad_HTML = "";
    var Nodo_Registros = this.Doc_XML.SeleccionarNodo(this.Doc_XML.root, "Registros");
    var Lista_Registros = this.Doc_XML.SeleccionarNodos(Nodo_Registros, "Registro");


    Cad_HTML += "<table>";

    if (Lista_Registros.length > 0) {
        var Color_Celda_Gris = 0;

        var funcioCent = "";
        var arrIgm = new Array();
        var Descripcion_Elemento = "";
        var idxArrIgm = 0
        var MBR_MaxX = 0;
        var MBR_MaxY = 0;
        var MBR_MinX = 0;
        var MBR_MinY = 0;

        
        for (var i = 0; i < Lista_Registros.length; i++) {

            var Nodo_Registro = Lista_Registros[i];

            if (Tipo_Busqueda == "GRAFICO" || Tipo_Busqueda == "GRAFICO_TOT") {

                if (Descripcion_Elemento != unescape(this.Doc_XML.TextoNodo(Nodo_Registro, "Descripcion_Elemento"))) {
                    if (i != 0) {

                        var index = Cad_HTML.lastIndexOf("onclick@F=")
                        Cad_HTML = Cad_HTML.substring(0, index) + "onclick=\"" + ABSLocalizacion.CreaFuncionMarcar(arrIgm, Nodo_Registro, MBR_MaxX, MBR_MaxY, MBR_MinX, MBR_MinY, true) + "\" " + Cad_HTML.substring(index + "onclick@F=".length + 1)
                        index = Cad_HTML.lastIndexOf("onclick@Z=")
                        Cad_HTML = Cad_HTML.substring(0, index) + funcioCent + ABSLocalizacion.CreaFuncionMarcar(arrIgm, Nodo_Registro, MBR_MaxX, MBR_MaxY, MBR_MinX, MBR_MinY, false) + "\" " + Cad_HTML.substring(index + "onclick@Z=".length + 1)
                        index = Cad_HTML.lastIndexOf("@REP")
                        if (idxArrIgm > 1) {
                            Cad_HTML = Cad_HTML.substring(0, index) + " <br\><span class=\"clsTBBusquedaDefault\"> [" + idxArrIgm + "&nbsp;" + ABSLocalizacion_Literal.TEXTO_AUX_TOTAL_REGISTROS + "]</span> " + Cad_HTML.substring(index + "@REP".length + 1)
                        }
                        else {
                            Cad_HTML = Cad_HTML.substring(0, index) + " " + Cad_HTML.substring(index + "@REP".length + 1)
                        }
                        idxArrIgm = 0
                        MBR_MaxX = 0
                        MBR_MaxY = 0
                        MBR_MinX = 0
                        MBR_MinY = 0

                        arrIgm = new Array()
                        Cad_HTML += "</tr>";
                    }

                    funcioCent = "onclick=\"" + ABSLocalizacion.Afegir_Pag_Result_Tabla_Result_Registro(Nodo_Registro, false)
                    Cad_HTML += "<tr>";
                    Cad_HTML += ABSLocalizacion.Crear_Pag_Result_Tabla_Grafic_Registro(Nodo_Registro, Color_Celda_Gris, i, Tipo_Busqueda)
                }
                else {
                    funcioCent += ABSLocalizacion.Afegir_Pag_Result_Tabla_Result_Registro(Nodo_Registro, false)
                }

                arrIgm[idxArrIgm] = this.Doc_XML.TextoNodo(Nodo_Registro, "AA_IGM");
                idxArrIgm++

                MBR_MaxX = (parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxX").replace(',', '.')) > MBR_MaxX) ? this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxX").replace(',', '.') : MBR_MaxX
                MBR_MaxY = (parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxY").replace(',', '.')) > MBR_MaxY) ? this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxY").replace(',', '.') : MBR_MaxY
                MBR_MinX = (parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinX").replace(',', '.')) < MBR_MinX || MBR_MinX == 0) ? this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinX").replace(',', '.') : MBR_MinX
                MBR_MinY = (parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinY").replace(',', '.')) < MBR_MinY || MBR_MinY == 0) ? this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinY").replace(',', '.') : MBR_MinY

                if (i + 1 == Lista_Registros.length) {
                    var index = Cad_HTML.lastIndexOf("onclick@F=")
                    Cad_HTML = Cad_HTML.substring(0, index) + "onclick=\"" + ABSLocalizacion.CreaFuncionMarcar(arrIgm, Nodo_Registro, MBR_MaxX, MBR_MaxY, MBR_MinX, MBR_MinY, true) + "\" " + Cad_HTML.substring(index + "onclick@F=".length + 1)
                    index = Cad_HTML.lastIndexOf("onclick@Z=")
                    Cad_HTML = Cad_HTML.substring(0, index) + funcioCent + ABSLocalizacion.CreaFuncionMarcar(arrIgm, Nodo_Registro, MBR_MaxX, MBR_MaxY, MBR_MinX, MBR_MinY, false) + "\" " + Cad_HTML.substring(index + "onclick@Z=".length + 1)
                    index = Cad_HTML.lastIndexOf("@REP")
                    if (idxArrIgm > 1) {
                        Cad_HTML = Cad_HTML.substring(0, index) + "  <br\><span class=\"clsTBBusquedaDefault\"> [" + idxArrIgm + "&nbsp;" + ABSLocalizacion_Literal.TEXTO_AUX_TOTAL_REGISTROS + "] </span>" + Cad_HTML.substring(index + "@REP".length + 1)
                    }
                    else {
                        Cad_HTML = Cad_HTML.substring(0, index) + " " + Cad_HTML.substring(index + "@REP".length + 1)
                    }
                    Cad_HTML += "</tr>";
                    idxArrIgm = 0
                    MBR_MaxX = 0
                    MBR_MaxY = 0
                    MBR_MinX = 0
                    MBR_MinY = 0
                    arrIgm = new Array()
                }
            } // Tipo_Busqueda == GENERAL
            else {
                Cad_HTML += "<tr>";

                var Matching;
                var Tabla;

                // Afegim el nom de la taula a cada full de resultats
                Tabla = this.Doc_XML.TextoNodo(Nodo_Registro, "Tabla_Descripcion");
                if (this.TablaElem != Tabla) {
                    this.TablaElem = Tabla;
                    Cad_HTML += "<td class=\"clsTextoResultado\" style=\"text-decoration: underline;\" colspan=\"4\">" + Tabla + "</td></tr><tr>"

                }
                // Indiquem si el resultat es de matching baix
                if (!this.MatchingBajo) {
                    Matching = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Matching").replace(',', '.')); //albert
                    if (Matching < 500) {
                        Cad_HTML += "<td class=\"clsTextoResultado\" style=\"font-style:italic;\" colspan=\"4\">" + ABSLocalizacion_Literal.TEXTO_MATCHING_BAJO + "</td></tr><tr>"
                        this.MatchingBajo = true;
                    }
                }

                var tablaElem = this.Doc_XML.TextoNodo(Nodo_Registro, "Tabla_Elemento");
                // en caso de POIS filtrar si el nivel no es visible
                if (tablaElem == "LOCG_POI") {
                   
                    //mirem si el nivell es visible
                    var absmapas = ObtenerABSMapas();
                    var capa = absmapas.mapa.ObtenerCapa(Tabla);
                    //1. obtener ID tipo de poi (@TIPO_POI)
                    var clave_tipo_poi = unescape(this.Doc_XML.TextoNodo(Nodo_Registro, "Descripcion_Elemento")).split("@")[1];
                    if (!clave_tipo_poi)
                        return;

                    //1.1 Obtener relacion parametros                           

                    var cfg = absmapas.mapa.config;
                    if (!cfg)
                        return;
                    var tipo_poi;
                    tipo_poi = ABSMapaCiudad.ObtenerIdParamPorValor2(cfg, clave_tipo_poi);

                    if (!tipo_poi)
                        return;

                    if (tipo_poi.length < 1)
                        return;

                    //2. comprobar visibilidad servicio
                    var capa = absmapas.mapa.ObtenerCapa(tablaElem);
                    if (!capa)
                        return;
                    if (!capa.nivelPorId)
                        return;

                    var nivel = capa.nivelPorId[tipo_poi[0]];
                    if (!nivel)
                        return;


                    //3. si es visible ComponerCadena

                    if (nivel.visible) {                        
                        Cad_HTML += ABSLocalizacion.Crear_Pag_Result_Tabla_Grafic_Registro(Nodo_Registro, Color_Celda_Gris, i, Tipo_Busqueda)
                    }

                }
                else {  //OTROS distintos de POIS                    
                    
                    Cad_HTML += ABSLocalizacion.Crear_Pag_Result_Tabla_Grafic_Registro(Nodo_Registro, Color_Celda_Gris, i, Tipo_Busqueda)

                }


                Cad_HTML += "</tr>";
            }         


            //Cambiamos el color a la celda
            if (Color_Celda_Gris == 0) Color_Celda_Gris = 1;
            else Color_Celda_Gris = 0;


            Descripcion_Elemento = unescape(this.Doc_XML.TextoNodo(Nodo_Registro, "Descripcion_Elemento")).split("@")[0];

        }




    }
    else {
        Cad_HTML += "<tr>";
        Cad_HTML += "<td>";
        Cad_HTML += ABSLocalizacion_Literal.SIN_RESULTADOS;
        Cad_HTML += "</td>";
        Cad_HTML += "</tr>";
    }

    Cad_HTML += "</table>";
    return Cad_HTML;
}


/************************************************************************/
/*ABSLocalizacion.Crear_Pag_Result_Tabla_Result_Registro                */
/************************************************************************/
ABSLocalizacion.Crear_Pag_Result_Tabla_Result_Registro = function (Nodo_Registro, Color_Celda_Gris)
{
    var Cad_HTML="";
    //var MBR_MaxX = this.Doc_XML.SeleccionarNodo(Nodo_Registro, "MBR_MaxX");
    var MBR_MaxX = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxX").replace(',','.'));
    var MBR_MaxY = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxY").replace(',','.'));
    var MBR_MinX = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinX").replace(',','.'));
    var MBR_MinY = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinY").replace(',','.'));
    var Centro_X = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_X").replace(',','.'));
    var Centro_Y = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_Y").replace(',','.'));
    var Tabla_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Tabla_Elemento");
    var Clave_UBIGEO = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_UBIGEO");
    var Clave_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_Elemento");
    var Descripcion_Elemento = unescape(this.Doc_XML.TextoNodo(Nodo_Registro, "Descripcion_Elemento"));
   
    var AA_IGMs = this.Doc_XML.TextoNodo(Nodo_Registro, "AA_IGM");
    
    if (Tabla_Elemento=="LOCG_CRUCES")
    {
        Descripcion_Elemento = ABSLocalizacion_Literal.TEXTO_CRUCE + Descripcion_Elemento;
    }
    
    if (MBR_MinX==0) MBR_MinX =ABSLocalizacion.MBR_Mapa_Min_X() - 100;
    if (MBR_MaxX==0) MBR_MaxX =ABSLocalizacion.MBR_Mapa_Min_X() + 100;
    if (Centro_X==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        {
            Centro_X =MBR_MinX;
        }
        else
        {
            Centro_X =ABSLocalizacion.MBR_Mapa_Min_X();
        }
    }

    if (MBR_MinY==0) MBR_MinY =ABSLocalizacion.MBR_Mapa_Min_Y() - 100;
    if (MBR_MaxY==0) MBR_MaxY =ABSLocalizacion.MBR_Mapa_Min_Y() + 100;
    if (Centro_Y==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        {
            Centro_Y =MBR_MinY;
        }
        else
        {
            Centro_Y =ABSLocalizacion.MBR_Mapa_Min_Y();
        }
    }
    
    Cad_HTML += "<td width=\"40\" class=\"clsRegistroTabla1\" >";
	
    
//    Cad_HTML += "<img class=\"clsInfoIco\" src=\"" + ABSLocalizacion.urlImgItem() + "\"/> \r\n";                      
//    Cad_HTML += " - ";

    Cad_HTML += "<img class=\"clsInfoIco\" src=\"" + ABSLocalizacion.urlImgFicha() + "\" " +
                "onclick=\"ABSLocalizacion.MostrarInforme(" +
                     MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                     ", '" + AA_IGMs +"','" + Tabla_Elemento + 
                     "')\" " +
                "onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\" " +
                "alt=\""+ ABSLocalizacion.etqFitxa() + "\" " +
                "title=\"" + ABSLocalizacion.etqFitxaLong() + "\"/>";

/*SOLO CENTRAR*//*
    Cad_HTML += "<img class=\"clsInfoIco\" " +
                "src=\"" + ABSLocalizacion.urlImgZoom() + "\" " +
                "onclick=\"ABSLocalizacion.CentrarElemento_Y_Etiquetar(" +
                     MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                      ", '" + AA_IGMs + "' ,'" + Tabla_Elemento + "', 0)\" " +
                "onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\" " +
                "alt=\""+ ABSLocalizacion.etqCentrar() + "\" " +
                "title=\""+ ABSLocalizacion.etqCentrarCompleta() + "\"/>" +
                "&nbsp; \r\n";
                
                
*/              

     

    Cad_HTML += "<img class=\"clsInfoIco\" " +
                "src=\"" + ABSLocalizacion.urlImgZoom() + "\" " +
                "onclick=\"ABSLocalizacion.CentrarElemento_Y_Etiquetar(" +
                     MBR_MinX + ", " + MBR_MinY + ", " + MBR_MaxX + ", " + MBR_MaxY + 
                      ", '" + AA_IGMs + "' ,'" + Tabla_Elemento + "', 1, '" + 
                      Tabla_Elemento + "', " + Centro_X + ", " + Centro_Y + ", '" + 
                      Descripcion_Elemento + 
                      "' , 'Ubicación')\" " +
                "onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\" " +
                "alt=\""+ ABSLocalizacion.etqCentrar() + "\" " +
                "title=\""+ ABSLocalizacion.etqCentrarCompleta() + "\"/>";

	Cad_HTML += "</td>";
    if (Color_Celda_Gris==0)
    {
        Cad_HTML += "<td class=\"clsRegistroTabla1\" >";
        
    }
    else
    {
        Cad_HTML += "<td class=\"clsRegistroTabla2\" >";
    }

    //Cad_HTML += "&nbsp;" + Descripcion_Elemento;
    var texto = ABSLocalizacion.ObtenerTextoCorto(Descripcion_Elemento,40);
        
    Cad_HTML += "<span title='"+Descripcion_Elemento + "'>" +texto +"</span>";
                
                /*
    Cad_HTML += "<img class=\"clsInfoIco\" " +
                "src=\"" + ABSLocalizacion.urlImgCartel() + "\" " +
                "onclick=\"ABSLocalizacion.MostrarCartel(" + 
                      MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                        "," + AA_IGMs +  ",'" + "NO_CAPA" +  "'," + 
                      Centro_X +","+ Centro_Y +",'" + escape(Descripcion_Elemento)+"'" + 
                      ",'SIN_CAPA')\" " +
                "alt=\""+ ABSLocalizacion.etqCartel() + "\" " +
                "title=\"" + ABSLocalizacion.etqCartel() + "\" " +
                "onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\"/> \r\n";
*/                
	Cad_HTML += "</td>";

    return Cad_HTML;

}



/************************************************************************/
/*ABSLocalizacion.Crear_Pag_Result_Tabla_Grafic_Registro                */
/************************************************************************/
ABSLocalizacion.Crear_Pag_Result_Tabla_Grafic_Registro = function (Nodo_Registro, Color_Celda_Gris, id, TipoBusqueda)
{
    var Cad_HTML="";
    //var MBR_MaxX = this.Doc_XML.SeleccionarNodo(Nodo_Registro, "MBR_MaxX");
    var MBR_MaxX = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxX").replace(',','.'));
    var MBR_MaxY = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxY").replace(',','.'));
    var MBR_MinX = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinX").replace(',','.'));
    var MBR_MinY = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinY").replace(',','.'));
    var Centro_X = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_X").replace(',','.'));
    var Centro_Y = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_Y").replace(',','.'));
    
   
    
    var Tabla_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Tabla_Elemento");
    var Clave_UBIGEO = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_UBIGEO");
    var Clave_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_Elemento");
    var Descripcion_Elemento = unescape(this.Doc_XML.TextoNodo(Nodo_Registro, "Descripcion_Elemento")).split("@")[0];
   
    var AA_IGMs = this.Doc_XML.TextoNodo(Nodo_Registro, "AA_IGM");
    
    if (Tabla_Elemento=="LOCG_CRUCES")
    {
        Descripcion_Elemento = ABSLocalizacion_Literal.TEXTO_CRUCE + Descripcion_Elemento;
    }
    
    if (MBR_MinX==0) MBR_MinX =ABSLocalizacion.MBR_Mapa_Min_X() - 100;
    if (MBR_MaxX==0) MBR_MaxX =ABSLocalizacion.MBR_Mapa_Min_X() + 100;
    if (Centro_X==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        {
            Centro_X =MBR_MinX;
        }
        else
        {
            Centro_X =ABSLocalizacion.MBR_Mapa_Min_X();
        }
    }

    if (MBR_MinY==0) MBR_MinY =ABSLocalizacion.MBR_Mapa_Min_Y() - 100;
    if (MBR_MaxY==0) MBR_MaxY =ABSLocalizacion.MBR_Mapa_Min_Y() + 100;
    if (Centro_Y==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        {
            Centro_Y =MBR_MinY;
        }
        else
        {
            Centro_Y =ABSLocalizacion.MBR_Mapa_Min_Y();
        }
    }
    
    Cad_HTML += "<td width=\"60\" class=\"clsRegistroTabla1\" valign=\"top\" >";
	
   if(TipoBusqueda != "GRAFICO" && TipoBusqueda != "GRAFICO_TOT")
   {

        Cad_HTML += "<img id=\"info"+id+"\" class=\"clsInfoIco\" src=\"" + ABSLocalizacion.urlImgFicha() + "\" " +
                  "onclick=\"ABSLocalizacion.MostrarInforme(" +
                     MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                     ", '" + AA_IGMs +"','" + Tabla_Elemento + 
                     "')\" " +
                "onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\" " +
                "alt=\""+ ABSLocalizacion.etqFitxa() + "\" " +
                "title=\"" + ABSLocalizacion.etqFitxaLong() + "\"/>";



        Cad_HTML += "<img  id=\"zoom"+id+"\" class=\"clsInfoIco\" " +
                "src=\"" + ABSLocalizacion.urlImgZoom() + "\" " +
                   "onclick=\"ABSLocalizacion.CentrarElemento_Y_Etiquetar(" +
                     MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                      ", '" + AA_IGMs + "' ,'" + Tabla_Elemento + "', 0,"+
                      "'" + Tabla_Elemento + "'," +
                      Centro_X + "," +
                      Centro_Y + "," +
                      "'" + Descripcion_Elemento + "'," +
                      "'"+ ABSLocalizacion_Literal.TEXTO_UBICACION + "'" +                                         
                      ")\" " + 
                "onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\" " +
                "alt=\""+ ABSLocalizacion.etqCentrar() + "\" " +
                "title=\""+ ABSLocalizacion.etqCentrarCompleta() + "\"/>";
                
     }
     else{
       
           Cad_HTML += "<img id=\"info"+id+"\" class=\"clsInfoIco\" src=\"" + ABSLocalizacion.urlImgFicha() + "\" " +
                "onclick@F= onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\" " +
                "alt=\""+ ABSLocalizacion.etqFitxa() + "\" " +
                "title=\"" + ABSLocalizacion.etqFitxaLong() + "\"/>";



          Cad_HTML += "<img  id=\"zoom"+id+"\" class=\"clsInfoIco\" " +
                "src=\"" + ABSLocalizacion.urlImgZoom() + "\" " +              
                "onclick@Z= onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                "onmouseout=\"ABSLocalizacion.CursorDefault()\" " +
                "alt=\""+ ABSLocalizacion.etqCentrar() + "\" " +
                "title=\""+ ABSLocalizacion.etqCentrarCompleta() + "\"/>";
     
     }           
	
	if(ABSLocalizacion.mostrar_google())
        Cad_HTML += "<img class=\"clsInfoIco\" alt=\"icono_info\" src=\"" + ABSLocalizacion.urlImgGoogle() + "\" onclick=\"ABSLocalizacion.ConectarGoogleEarth([" + 
                     AA_IGMs +  "],'" + Tabla_Elemento +  "')\" alt=\""+ ABSLocalizacion.etqGoogle() + "\" title=\"" + ABSLocalizacion.etqGoogle() + 
                     "\" onmouseover=\"ABSLocalizacion.CursorSeleccion()\" " +
                     " onmouseout=\"ABSLocalizacion.CursorDefault()\"/>" ;
    
    
    Cad_HTML += "</td>";



    if (Color_Celda_Gris==0)
    {
        Cad_HTML += "<td class=\"clsRegistroTabla1\" valign=\"top\" >";
        
    }
    else
    {
        Cad_HTML += "<td class=\"clsRegistroTabla2\" valign=\"top\" >";
    }



    //Cad_HTML += "&nbsp;" + Descripcion_Elemento;
    var texto = ABSLocalizacion.ObtenerTextoCorto(Descripcion_Elemento,40);
     
     if(TipoBusqueda != "GRAFICO" && TipoBusqueda != "GRAFICO_TOT")
   {    
    Cad_HTML += "<span title='"+Descripcion_Elemento + "'>" +texto  +"</span>"; 
   }
   else{
     Cad_HTML += "<span title='"+Descripcion_Elemento + "'>" +texto   +"</span> "+"@REP" ; 
   }             
             
	Cad_HTML += " </td>";

    return Cad_HTML;

}








/************************************************************************/
/*ABSLocalizacion.Afegir_Pag_Result_Tabla_Result_Registro                */
/************************************************************************/
ABSLocalizacion.Afegir_Pag_Result_Tabla_Result_Registro = function (Nodo_Registro, mostrarInforme)
{
    var Cad_HTML="";
    //var MBR_MaxX = this.Doc_XML.SeleccionarNodo(Nodo_Registro, "MBR_MaxX");
    var MBR_MaxX = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxX").replace(',','.'));
    var MBR_MaxY = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MaxY").replace(',','.'));
    var MBR_MinX = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinX").replace(',','.'));
    var MBR_MinY = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "MBR_MinY").replace(',','.'));
    var Centro_X = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_X").replace(',','.'));
    var Centro_Y = parseFloat(this.Doc_XML.TextoNodo(Nodo_Registro, "Centro_Y").replace(',','.'));
    var Tabla_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Tabla_Elemento");
    var Clave_UBIGEO = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_UBIGEO");
    var Clave_Elemento = this.Doc_XML.TextoNodo(Nodo_Registro, "Clave_Elemento");
    var Descripcion_Elemento = unescape(this.Doc_XML.TextoNodo(Nodo_Registro, "Descripcion_Elemento"));
   
    var AA_IGMs = this.Doc_XML.TextoNodo(Nodo_Registro, "AA_IGM");
    
    var cercadorGrafic =  document.getElementById("WebPanelBusquedaGrafica_LBBusquedaGrafica1");
    var mapLit         =  cercadorGrafic.options[cercadorGrafic.selectedIndex].text.replace("'","´ ");
    if (Tabla_Elemento=="LOCG_CRUCES")
    {
        Descripcion_Elemento = ABSLocalizacion_Literal.TEXTO_CRUCE + Descripcion_Elemento;
    }
    
    if (MBR_MinX==0) MBR_MinX =ABSLocalizacion.MBR_Mapa_Min_X() - 100;
    if (MBR_MaxX==0) MBR_MaxX =ABSLocalizacion.MBR_Mapa_Min_X() + 100;
    if (Centro_X==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        { Centro_X =MBR_MinX;}
        else
        {  Centro_X =ABSLocalizacion.MBR_Mapa_Min_X();}
    }

    if (MBR_MinY==0) MBR_MinY =ABSLocalizacion.MBR_Mapa_Min_Y() - 100;
    if (MBR_MaxY==0) MBR_MaxY =ABSLocalizacion.MBR_Mapa_Min_Y() + 100;
    if (Centro_Y==0) 
    {
        if (Tabla_Elemento=="LOCG_VIA")
        { Centro_Y =MBR_MinY; }
        else
        {  Centro_Y =ABSLocalizacion.MBR_Mapa_Min_Y();}
    }
    

    if(mostrarInforme){

        Cad_HTML += "ABSLocalizacion.MostrarInforme(" +
                     MBR_MinX + "," + MBR_MinY + "," + MBR_MaxX + "," + MBR_MaxY + 
                     ", '" + AA_IGMs +"','" + Tabla_Elemento + 
                     "'); ";

    }
    else{
        Cad_HTML += "ABSLocalizacion.ZommCercadorGrafic(" +
                     MBR_MinX + ", " + MBR_MinY + ", " + MBR_MaxX + ", " + MBR_MaxY + 
                      ", '" + AA_IGMs + "' ,'" + Tabla_Elemento + "', 1, '" + 
                      Tabla_Elemento + "', " + Centro_X + ", " + Centro_Y + ", '" + 
                      Descripcion_Elemento + 
                      "' ,'" + mapLit + "'); ";
   }                   

    return Cad_HTML;

}



/************************************************************************/
/*ABSLocalizacion.ObtenerTextoCorto                                     */
/************************************************************************/
ABSLocalizacion.ObtenerTextoCorto= function(
   descripcion, 
    longitud)
{

   if( descripcion.length>parseInt(longitud))
          return  unescape( descripcion).substring(0,parseInt(longitud)-3)+ "...";
    else return unescape( descripcion);
  
 }
    
/************************************************************************/
/*ABSLocalizacion.Agregar_Botonera                                      */
/************************************************************************/
ABSLocalizacion.Agregar_Botonera  = function (Tipo_Busqueda)
{
    var Cad_HTML="";
    
    Cad_HTML += "<table align=\"right\">";
    Cad_HTML += "<tr>";
    Cad_HTML += "<td>";
    Cad_HTML += ABSLocalizacion.Agregar_Boton_Primero(Tipo_Busqueda) + "&nbsp;";
    Cad_HTML += ABSLocalizacion.Agregar_Boton_Anterior(Tipo_Busqueda) + "&nbsp;";
    Cad_HTML += ABSLocalizacion.Agregar_Boton_Siguiente(Tipo_Busqueda) + "&nbsp;";
    Cad_HTML += ABSLocalizacion.Agregar_Boton_Ultimo(Tipo_Busqueda);
    Cad_HTML += "</td>";
    Cad_HTML += "</tr>";
    Cad_HTML += "</table>";

    return Cad_HTML;
}

/************************************************************************/
/*ABSLocalizacion.Agregar_Boton_Primero                                 */
/************************************************************************/
ABSLocalizacion.Agregar_Boton_Primero  = function (Tipo_Busqueda)
{
    var Cad_HTML="";
    Cad_HTML += "<span style=\"cursor: pointer;\"><img style=\"border-width: 0px;\" alt=\"ico_buscar_primero\" " +
                "src=\"" + ABSLocalizacion.Url_Imagen_Primera() + "\" " +
                "onclick=\"javascript:ABSLocalizacion.Buscar_Primero('" + Tipo_Busqueda + "');\" " +
                "id=\"WebPanelBusqueda_ImgBuscar_Primero\"/></span>";
    return Cad_HTML;

}

/************************************************************************/
/*ABSLocalizacion.Agregar_Boton_Anterior                                */
/************************************************************************/
ABSLocalizacion.Agregar_Boton_Anterior  = function (Tipo_Busqueda)
{
    var Cad_HTML="";
    Cad_HTML += "<span style=\"cursor: pointer;\"><img style=\"border-width: 0px;\"  alt=\"ico_buscar_anterior\" " +
                "src=\"" + ABSLocalizacion.Url_Imagen_Anterior() + "\" " +
                "onclick=\"javascript:ABSLocalizacion.Buscar_Anterior('" + Tipo_Busqueda + "');\" " +
                "id=\"WebPanelBusqueda_ImgBuscar_Anterior\"/></span>";
    return Cad_HTML;
}

/************************************************************************/
/*ABSLocalizacion.Agregar_Boton_Siguiente                               */
/************************************************************************/
ABSLocalizacion.Agregar_Boton_Siguiente  = function (Tipo_Busqueda)
{
    var Cad_HTML="";
    Cad_HTML += "<span style=\"cursor: pointer;\"><img style=\"border-width: 0px;\"  alt=\"ico_buscar_siguiente\" " +
                "src=\"" + ABSLocalizacion.Url_Imagen_Siguiente() + "\" " +
                "onclick=\"javascript:ABSLocalizacion.Buscar_Siguiente('" + Tipo_Busqueda + "');\" " +
                "id=\"WebPanelBusqueda_ImgBuscar_Siguiente\"/></span>";
    return Cad_HTML;
}

/************************************************************************/
/*ABSLocalizacion.Agregar_Boton_Ultimo                                  */
/************************************************************************/
ABSLocalizacion.Agregar_Boton_Ultimo  = function (Tipo_Busqueda)
{
    var Cad_HTML="";
    Cad_HTML += "<span style=\"cursor: pointer;\"><img style=\"border-width: 0px;\"  alt=\"ico_buscar_ultimo\" " +
                "src=\"" + ABSLocalizacion.Url_Imagen_Ultima() + "\" " +
                "onclick=\"javascript:ABSLocalizacion.Buscar_Ultimo('" + Tipo_Busqueda + "');\" " +
                "id=\"WebPanelBusqueda_ImgBuscar_Ultimo\"/></span>";
    return Cad_HTML;
}

/************************************************************************/
/*ABSLocalizacion.Buscar_Primero                                        */
/*                                                                      */
/* Tipo_Busqueda puede ser : 'GENERAL', 'POIS' o 'POSTAL' segun el      */
/* TextBox desde el que he hecho la llamada                             */
/************************************************************************/
ABSLocalizacion.Buscar_Primero  = function (Tipo_Busqueda)
{
    

    
    if (this.Texto_Buscado=="")
    {
        this.Texto_Buscado_2 = ""; //En esta funcion lo relleno si es necesario
        
    	var TB_Busqueda;
    	var TB_Busqueda_2;
        if (Tipo_Busqueda=="GENERAL")
        {
	        var TB_Busqueda = document.getElementById("WebPanelBusqueda_TBBusqueda");
	        if ((TB_Busqueda.value !="") && (TB_Busqueda.value != ABSLocalizacion_Literal.TEXTO_DEFECTO_GENERAL))
	        {
    	        this.Texto_Buscado = TB_Busqueda.value;
	        }
        }
        else if (Tipo_Busqueda=="POIS")
        {
	       var TB_Busqueda = document.getElementById("WebPanelBusquedaPois_TBBusquedaPois");
           if ((TB_Busqueda.value !="") && (TB_Busqueda.value != ABSLocalizacion_Literal.TEXTO_DEFECTO_POIS))
	       {
    	       this.Texto_Buscado = TB_Busqueda.value;
	       }
	     }
        else if (Tipo_Busqueda=="POSTAL")
        {
            //Primero la calle 1
	        var TB_Busqueda = document.getElementById("WebPanelBusquedaPostal_TBBusquedaPostal1");
	        if ((TB_Busqueda.value !="") && (TB_Busqueda.value !=ABSLocalizacion_Literal.TEXTO_DEFECTO_CARRER_1))
			{
                this.Texto_Buscado = TB_Busqueda.value;
                //Ahora el numero
	            var TB_Postal_2 = document.getElementById("WebPanelBusquedaPostal_TBBusquedaPostal2");
	            if ((TB_Postal_2.value !="") && (TB_Postal_2.value !=ABSLocalizacion_Literal.TEXTO_DEFECTO_CARRER_NUM))
			    {
	               this.Texto_Buscado += ", " + TB_Postal_2.value ;
			    } 
			    //Ahora la calle 3
	            var TB_Postal_3 = document.getElementById("WebPanelBusquedaPostal_TBBusquedaPostal3");
	            if ((TB_Postal_3.value !="") && (TB_Postal_3.value !=ABSLocalizacion_Literal.TEXTO_DEFECTO_CARRER_2))
			    {
                    this.Texto_Buscado_2 = TB_Postal_3.value;
                }
			}
        }
         else if (Tipo_Busqueda=="GRAFICO")
        {

           //Primero la calle 1
	       var selTipo  = document.getElementById("WebPanelBusquedaGrafica_LBBusquedaGrafica1");
           var strTexto = document.getElementById("WebPanelBusquedaGrafica_TBBusquedaGrafica1");
           
           if(selTipo.selectedIndex != 0){
               this.Texto_Buscado   = selTipo.options[selTipo.selectedIndex].value;
               this.Texto_Buscado_2 = strTexto.value;
           }    
           else{
              alert (ABSLocalizacion_Literal.ERROR_SINCAPA_SEL);
           }
        }    
    }
    
    if (Tipo_Busqueda=="GRAFICO_TOT")
        {

           //Primero la calle 1
	       var selTipo  = document.getElementById("WebPanelBusquedaGrafica_LBBusquedaGrafica1");
           var strTexto = document.getElementById("WebPanelBusquedaGrafica_TBBusquedaGrafica1");
           
           if(selTipo.selectedIndex != 0){
               this.Texto_Buscado   = selTipo.options[selTipo.selectedIndex].value;
               this.Texto_Buscado_2 = '';
           }    
           else{
              alert (ABSLocalizacion_Literal.ERROR_SINCAPA_SEL);
              return;
           }
      }    
    

    if ( this.Texto_Buscado!="" || Tipo_Busqueda == "GRAFICO_TOT" )
    {
        this.Pos_Actual=1;
        ABSLocalizacion.Buscar(Tipo_Busqueda);
    }
}

/************************************************************************/
/*ABSLocalizacion.Buscar_Anterior                                       */
/************************************************************************/
ABSLocalizacion.Buscar_Anterior  = function (Tipo_Busqueda)
{
    if (this.Texto_Buscado!="")
    {
        this.Pos_Actual -= (this.Total_Repetido + ABSLocalizacion.Max_Resultados);
        if (this.Pos_Actual<1) this.Pos_Actual=1;
        ABSLocalizacion.Buscar(Tipo_Busqueda);
    } 
}

/************************************************************************/
/*ABSLocalizacion.Buscar_Siguiente                                      */
/************************************************************************/
ABSLocalizacion.Buscar_Siguiente  = function (Tipo_Busqueda)
{
    if (this.Texto_Buscado!="")
    {
        var Busqueda_Pos_Actual_Temp;

        //Guardo la posicion actual por si acaso
        Busqueda_Pos_Actual_Temp=this.Pos_Actual;

        this.Pos_Actual += this.Total_Repetido + ABSLocalizacion.Max_Resultados;
        if (this.Total_Encontrados>0)
        {
            if (this.Pos_Actual>this.Total_Encontrados)
                this.Pos_Actual=Busqueda_Pos_Actual_Temp;
        }
        ABSLocalizacion.Buscar(Tipo_Busqueda);
    } 
}

/************************************************************************/
/*ABSLocalizacion.Buscar_Ultimo                                         */
/************************************************************************/
ABSLocalizacion.Buscar_Ultimo  = function (Tipo_Busqueda)
{
    if (this.Texto_Buscado!="")
    {
            var Busqueda_Pos_Actual_Temp;

            //Guardo la posicion actual por si acaso
            Busqueda_Pos_Actual_Temp=this.Pos_Actual;
            
            if (Tipo_Busqueda=="GRAFICO" || Tipo_Busqueda=="GRAFICO_TOT" )
            {
                if(this.Pos_Actual + this.Total_Repetido + ABSLocalizacion.Max_Resultados - 1 < this.Total_Encontrados)
                {
                  this.Pos_Actual = this.Total_Encontrados - 1
                }
            }
            else
            {
                //Ejemplo: (16 resultados, 15 por pagina): 1 + 15 -1 < 16
                //si no ponemos el -1 no entra en el while, y no va a la última página
                while (this.Pos_Actual + this.Total_Repetido + ABSLocalizacion.Max_Resultados - 1 < this.Total_Encontrados)
                {
                    this.Pos_Actual += ABSLocalizacion.Max_Resultados;
                }
               
             }   
            
             //Si nos hemos pasado del maximo, restamos max_resultados;
                if(this.Pos_Actual > this.Total_Encontrados)
                {
                    this.Pos_Actual -= ABSLocalizacion.Max_Resultados;
                }
            
            if (this.Pos_Actual<1) this.Pos_Actual=1;
            
            ABSLocalizacion.Buscar(Tipo_Busqueda);
    }
}

ABSLocalizacion.isArray =function (testObject) {
    return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
}




