﻿var xmlDoc;  
function seleccionarTexto(){var varUbicacion = document.getElementById('ctl00_txtUbicacion').focus();var varUbicacion = document.getElementById('ctl00_txtUbicacion').select();var variable = document.getElementById('Ubicacion');variable.style.display='block';} 
function seleccionaUbicacion(strSeleccion){document.getElementById('ctl00_txtUbicacion').value=strSeleccion;var variable = document.getElementById('Ubicacion');variable.style.display='none';document.getElementById("Ubicacion").innerHTML='';} 
function salirTexto(){var variable = document.getElementById('Ubicacion'); if (variable.style.display!='block'){variable.style.display='none';document.getElementById("Ubicacion").innerHTML='';}} 
function ocultarResultados(){var variable = document.getElementById('Ubicacion');variable.style.display='none';document.getElementById("Ubicacion").innerHTML='';} 
        function buscarUbicacion()
        {  var text = document.getElementById('ctl00_txtUbicacion').value;    
           if (text.length>3)
           {   var nodeXML;var listaHTML='';                    
               var mozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');  
               var ie = (typeof window.ActiveXObject != 'undefined');
                if (mozilla) 
                {   
                      nodeXML = xmlDoc.getElementsByTagName('p');
                      listaHTML = "<div style=\"widtht:256px; height:150px; overflow:auto;\">"
                      listaHTML += '<table cellspacing="2" cellpadding="2" border="0" style="font-size:11px;width:256px;border-collapse:collapse;">';  
                      var strTexto=document.getElementById('ctl00_txtUbicacion').value;
                      for (j=0; j < nodeXML.length; j++)
                      {     var nodeXMLInterno = xmlDoc.getElementsByTagName('p')[j];
                            var strUbicacion = nodeXMLInterno.getElementsByTagName('U')[0].firstChild.nodeValue;                            
                            var Busqueda = BuscaLetra(strUbicacion,strTexto)
                            if (Busqueda==1)
                            {
                                listaHTML += "<tr OnMouseOut=\"javascript:setMouseOutColor(this);return false;\" OnMouseOver=\"javascript:setMouseOverColor(this);return false;\">"
                                listaHTML += "<td OnClick=\"javascript:seleccionaUbicacion('" + strUbicacion + "');return false;\" >" + strUbicacion + "</td>"
                                listaHTML += "</tr>"
                            }                                                                              
                      } 
                       listaHTML += '</table></div>';
                       var variable = document.getElementById('Ubicacion'); 
                       variable.style.display='block';
                       document.getElementById("Ubicacion").innerHTML='';
                       document.getElementById("Ubicacion").innerHTML = listaHTML;
                } 
                else if (ie) 
                {      
                      nodeXML = xmlDoc.getElementsByTagName('p');
                      listaHTML = "<div style=\"widtht:256px; overflow:auto; height:150px;\">"
                      listaHTML += '<table cellspacing="2" cellpadding="2" border="0" style="font-size:11px;width:256px;">';  
                      var strTexto=document.getElementById('ctl00_txtUbicacion').value;
                      for (j=0; j < nodeXML.length; j++)
                      {    
                            var strUbicacion = nodeXML[j].childNodes[0].firstChild.nodeValue;                            
                            var Busqueda = BuscaLetra(strUbicacion,strTexto)
                            if (Busqueda==1)
                            {
                                listaHTML += "<tr OnMouseOut=\"javascript:setMouseOutColor(this);return false;\" OnMouseOver=\"javascript:setMouseOverColor(this);return false;\">"
                                listaHTML += "<td OnClick=\"javascript:seleccionaUbicacion('" + strUbicacion + "');return false;\" >" + strUbicacion + "</td>"
                                listaHTML += "</tr>"
                            }                        
                      } 
                       listaHTML += '</table></div>';
                       var variable = document.getElementById('Ubicacion'); 
                       variable.style.display='block';                       
                       document.getElementById("Ubicacion").innerHTML='';
                       document.getElementById("Ubicacion").innerHTML = listaHTML;                     
                }  
                else 
                {    alert('Tu navegador no puede manejar este script');    
                     return;  }  
            } 
            else
             {var variable = document.getElementById('Ubicacion');variable.style.display='none';document.getElementById("Ubicacion").innerHTML='';} 
        } 
        var oldgridSelectdColor;
        function setMouseOverColor(element)
        {
            oldgridSelectdColor=element.style.backgroundColor;
            element.style.backgroundColor='#CCCCCC';
            element.style.cursor='point';
        }
function setMouseOutColor(element){element.style.backgroundColor=oldgridSelectdColor;}
function BuscaLetra(Ubicacion,Texto){ var sw=0;
var myRegExp = "" + Texto.toUpperCase();  + ""
var matchPos1 = Ubicacion.search(myRegExp);if(matchPos1 != -1){sw=1;}return sw;}        
function OnObtieneUbicacionError(error) {alert("Error cargando modulo de ubicaciones."); } 
function OnObtieneUbicacionOk(arg){var mozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');var ie = (typeof window.ActiveXObject != 'undefined');if (mozilla){xmlDoc = document.implementation.createDocument("", "", null);parser=new DOMParser();xmlDoc=parser.parseFromString(arg,"text/xml");}else if (ie){xmlDoc = new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async = false;xmlDoc.loadXML(arg); }else{alert('Tu navegador no puede manejar este script');return;}}
  
