
var side_bar_html="";var gmarkers=[];var htmls=[];var mapa;var k=0;var mostrarInfo=false;var numeroIconoAbierto=0;var geocoder=new google.maps.Geocoder();var shadow=null;var clickIcon=null;var clickMarker=null;var markers=null;var selected=null;var boundsOverlay=null;var viewportOverlay=null;var initialized=false;var hashFragment="";var params={};var infowindow=new google.maps.InfoWindow();var fromMarker;var toMarker=null;var iconfile="/viajes_mp/appBase/images/HAL1024/punto.png";geocoder.firstItem={};var localizacionBusqueda="";var bounds=null;var aplicarZoom=true;var intervaloDistancia=null;var intervalo1=null;var intervalo2=null;var intervalo3=null;var intervalo4=null;var matriz=new Array(20);matriz[21]=0.025;matriz[20]=0.05;matriz[19]=0.1;matriz[18]=0.25;matriz[17]=0.75;matriz[16]=1;matriz[15]=1.75;matriz[14]=2.5;matriz[13]=5;matriz[12]=10;matriz[11]=25;matriz[10]=50;matriz[9]=100;matriz[8]=250;matriz[7]=500;matriz[6]=1000;matriz[5]=1500;matriz[4]=2500;matriz[3]=5000;matriz[2]=10000;matriz[1]=250000;matriz[0]=2500000;var matrizZoom=new Array(8);matrizZoom[0]='200#10000000';matrizZoom[1]='50#100';matrizZoom[2]='25#50';matrizZoom[3]='10#25';matrizZoom[4]='5#10';matrizZoom[5]='2.5#5';matrizZoom[6]='1#2.5';matrizZoom[7]='0.5#1';matrizZoom[8]='0#0.5';function myclick(k){var icono=MapIconMaker.createLabeledMarkerIcon({label:new String(parseInt(numeroIconoAbierto)+1)});gmarkers[numeroIconoAbierto].setIcon(icono);numeroIconoAbierto=parseInt(k);mapa.setCenter(gmarkers[k].getPosition(),15);icono=MapIconMaker.createLabeledMarkerIcon({label:new String(parseInt(k)+1),colorIcono:"#D42D12",labelColor:"FFF8DC"});gmarkers[k].setIcon(icono);openInfoWindow(gmarkers[k],htmls[k],k);}
function setFromMarca(posicion){var marker=new google.maps.Marker({icon:iconfile,map:mapa,position:posicion});return marker;}
function crearMarca(point,name,html,icono,indice,htmlInfo,indiceOrden){mostrarInfo=false;var marca=new google.maps.Marker({icon:icono,map:mapa,position:point});marca.zIndex=indice;google.maps.event.addListener(marca,"mouseover",function(){if(mostrarInfo==false){openInfoWindow(marca,htmlInfo,indiceOrden);mostrarInfo=false;}});google.maps.event.addListener(marca,"mouseout",function(){if(mostrarInfo==false){infowindow.close();}});google.maps.event.addListener(marca,"click",function(){icono=MapIconMaker.createLabeledMarkerIcon({label:new String(numeroIconoAbierto+1)});gmarkers[numeroIconoAbierto].setIcon(icono);var icono=MapIconMaker.createLabeledMarkerIcon({label:new String(parseInt(indiceOrden)+1),colorIcono:"#D42D12",labelColor:"FFF8DC"});numeroIconoAbierto=parseInt(indiceOrden);marca.setIcon(icono);openInfoWindow(marca,html,indiceOrden);mostrarInfo=true;});gmarkers[indiceOrden]=marca;htmls[indiceOrden]=html;side_bar_html+='<a href="javascript:myclick('+indiceOrden+')" alt="'+name+'">'+name+'</a><br>';return marca;}
function crearMarcaIndividual(point,icono){var marca=new google.maps.Marker({icon:icono,map:mapa,position:point});return marca;}
function addAddressToMap(response){if(!response||response.Status.code!=200){alert("Lo sentimos, es imposible posicionar esa dirección");}else{place=response.Placemark[0];point=new google.maps.LatLng(place.Point.coordinates[1],place.Point.coordinates[0]);mapa.setCenter(point,15);var html=place.address;document.getElementById("q").value=html;var label=place.address;var icono=creaIcono("../appBase/images/HAL/bola-azul.gif",35,26)
var marker=crearMarca(point,label,html,icono);mapa.addOverlay(marker);}}
function buscarDireccion(){var direccion=document.getElementById("buscarPuntoInteres").value;geocoder=new GClientGeocoder();geocoder.getLocations(direccion,addAddressToMap);}
function findLocation(direccion){document.getElementById("q").value=direccion;showLocation();}
function mostrarEnMapaGrande(indice){location.href="#verMapaHoteles";for(var a=0;a<gmarkers.length;a++){var ind=gmarkers[a].indice;if(gmarkers[a].indice==indice){myclick(a);return false;}}}
function openInfoWindow(marker,txt,indiceOrden){var contentInfo=txt;infowindow.setContent(contentInfo);infowindow.disableAutoPan=false;infowindow.maxWidth=550;infowindow.open(mapa,marker);$j('.PINCHAREN').html(obtenerTextoIdioma("PINCHAREN")+" <img src=\""+$j('#contextPath').val()+"/appBase/images/HAL1024/iconoPuntoMapaGoogleBlanco.jpg\" height=\"16\" width=\"10\" border=\"0\"> "+obtenerTextoIdioma("PARAVERMASINFO"));$j('.ENLVUELOHOTEL').html(obtenerTextoIdioma("ENLVUELOHOTEL"));$j('.HOTEL').html(obtenerTextoIdioma("HOTEL"));$j('.SPNPORPERSONA').html(obtenerTextoIdioma("SPNPORPERSONA"));$j('.PRECIONOCHE').html(obtenerTextoIdioma("PRECIONOCHE"));$j('.PORNOCHE').html(obtenerTextoIdioma("PORNOCHE"));$j('.CONTINUAR').html(obtenerTextoIdioma("CONTINUAR"));$j('.VISTADELACALLE').html(obtenerTextoIdioma("VISTADELACALLE"));$j('.TXTNOCHES').html(obtenerTextoIdioma("TXTNOCHES"));google.maps.event.addListener(infowindow,"closeclick",function(){if(indiceOrden==numeroIconoAbierto){var icono=MapIconMaker.createLabeledMarkerIcon({label:new String(numeroIconoAbierto+1)});marker.setIcon(icono);mostrarInfo=false;}});}
function openStreetView(indice){var service=new google.maps.StreetViewService();var posicion=new google.maps.LatLng(document.getElementById("LatitudStreetView_"+indice).value,document.getElementById("LongitudStreetView_"+indice).value);service.getPanoramaByLocation(posicion,50,function(result,status){if(status==google.maps.StreetViewStatus.OK){var panoramaOptions={position:posicion,addressControl:true,addressControlOptions:{position:google.maps.ControlPosition.TOP_RIGHT},linksControl:true,enableCloseButton:true,pov:{heading:160,pitch:10,zoom:1},navigationControl:true,navigationControlOptions:{style:google.maps.NavigationControlStyle.DEFAULT},visible:true};var panorama=new google.maps.StreetViewPanorama(document.getElementById("mapaTodosGoogle"),panoramaOptions);new google.maps.Marker({icon:MapIconMaker.createLabeledMarkerIcon({label:new String(parseInt(indice)+1),colorIcono:"#D42D12",labelColor:"FFF8DC"}),map:panorama,position:posicion});}else{alert("No existe StreetView para este hotel");}});}
function crearMapa(indiceDisponibilidad,nombreCapa,indice,tipoFiltroHotel,tipoOrdenacionHotel,zoom,distanciaPuntoReferencia,desde,hasta,contextPath){var filtroRegimen="";var filtroCategoria="";var filtroNombre="";var filtrar="";var filtroPrecio="";var ArrayPrecios="";var distanciaAlHotel=document.getElementById("distanciaPuntoReferencia").value;var mapOptions={zoom:15,center:new google.maps.LatLng(document.getElementById("ultimaLatitud").value,document.getElementById("ultimaLongitud").value),mapTypeId:google.maps.MapTypeId.ROADMAP,scaleControl:true,scrollwheel:false};mapa=new google.maps.Map(document.getElementById(nombreCapa),mapOptions);directionsDisplay=new google.maps.DirectionsRenderer();var routeMarkerOp={zIndex:1};directionsDisplay.markerOptions=routeMarkerOp;directionsDisplay.setMap(mapa);directionsDisplay.setPanel(document.getElementById("directionsPanel"));infowindow=new google.maps.InfoWindow();document.getElementById(nombreCapa).style.display='block';filtroRegimen=document.getElementById("filtroRegimen").value;filtroCategoria=document.getElementById("filtroCategoria").value;filtroNombre=document.getElementById("filtroNombre").value;ArrayPrecios=document.getElementById("ArrayPrecios").value;if(zoom!=""){zoom=parseInt(zoom);}else{zoom=14;}
var codHotel="-1";if(indice=="-1"){filtrar=document.getElementById("filtrar").value;filtroPrecio=document.getElementById("filtroPrecio").value;if(document.getElementById("latitudPuntoReferencia").value!=""&&document.getElementById("longitudPuntoReferencia").value!=""){mapa.setCenter(new google.maps.LatLng(document.getElementById("latitudPuntoReferencia").value,document.getElementById("longitudPuntoReferencia").value));}else{mapa.setCenter(new google.maps.LatLng(document.getElementById("ultimaLatitud").value,document.getElementById("ultimaLongitud").value));}
mapa.setZoom(zoom);}else{zoom=15;mapa.setCenter(new google.maps.LatLng(document.getElementById("Latitud_"+indice).value,document.getElementById("Longitud_"+indice).value),zoom);codHotel=document.getElementById("codHotel_"+indice).value;mapa.setZoom(zoom);}
var request=creaMarkersAjax();request.open("POST","/viajes_mp/appBase/jsp/googlemaps/coordenadasUnHotelV2.jsp?indiceDisponibilidad="+indiceDisponibilidad+"&indice="+indice+"&filtroRegimen="+filtroRegimen+"&filtroCategoria="+filtroCategoria+"&filtroNombre="+filtroNombre+"&filtrar="+filtrar+"&filtroPrecio="+filtroPrecio+"&ArrayPrecios="+ArrayPrecios+"&tipoFiltroHotel="+tipoFiltroHotel+"&codHotel="+codHotel+"&mostrarPrecioDispo="+$j('#mostrarPrecioDispo').val()+"&tipoOrdenacionHotel="+tipoOrdenacionHotel+"&desde="+desde+"&hasta="+hasta+"&contextPath="+contextPath,true);request.onreadystatechange=function(){if(request.readyState==4){var xmlDoc=request.responseXML;var markers=request.responseXML.documentElement.getElementsByTagName("marker");var marcas=[];if(desde==null||desde=='')
desde=0;else
desde=parseInt(desde);if(hasta==null||hasta=='')
hasta=markers.length;else
hasta=parseInt(hasta);for(var i=0;i<markers.length;i++){var point=new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));var html=GXml.value(markers[i].getElementsByTagName("html")[0]);var htmlInfo=GXml.value(markers[i].getElementsByTagName("html")[1]);var label=markers[i].getAttribute("label");var ind=markers[i].getAttribute("indice");var icono="";var precio=markers[i].getAttribute("precio");var preciodia=markers[i].getAttribute("preciodia");var newIcon=MapIconMaker.createLabeledMarkerIcon({label:new String(desde+i+1)});var marca=crearMarca(point,label,html,newIcon,ind,htmlInfo,desde+i);marcas.push(marca);}}};if(document.getElementById("latitudPuntoReferencia").value!=""&&document.getElementById("longitudPuntoReferencia").value!=""){var marcaReferencia=new google.maps.LatLng(parseFloat(document.getElementById("latitudPuntoReferencia").value),parseFloat(document.getElementById("longitudPuntoReferencia").value));setFromMarca(marcaReferencia);calcularComboDistancias(distanciaPuntoReferencia);$j('#zoomMapa').val(mapa.getZoom());}
request.send(null);if(indice!="-1"){for(var a=0;a<gmarkers.length;a++){if(gmarkers[a].indice==indice){myclick(a);mapa.addOverlay(gmarkers[a]);a=gmarkers.length;}}}
google.maps.event.addListener(mapa,'zoom_changed',function(){if(aplicarZoom){$j('#zoomMapa').val(mapa.getZoom());calcularComboDistancias(distanciaPuntoReferencia);}});}
function crearMapaIndividual(indiceDisponibilidad,nombreCapa,indice,zoom){var filtroRegimen="";var filtroCategoria="";var filtroNombre="";var filtrar="";var filtroPrecio="";var ArrayPrecios="";var mapOptions={zoom:15,center:new google.maps.LatLng($j('#latitudHotel').val(),$j('#longitudHotel').val()),mapTypeId:google.maps.MapTypeId.ROADMAP,scaleControl:true,scrollwheel:false};mapa=new google.maps.Map(document.getElementById(nombreCapa),mapOptions);directionsDisplay=new google.maps.DirectionsRenderer();var routeMarkerOp={zIndex:1};directionsDisplay.markerOptions=routeMarkerOp;directionsDisplay.setMap(mapa);directionsDisplay.setPanel(document.getElementById("directionsPanel"));infowindow=new google.maps.InfoWindow();$j('#'+nombreCapa).show();filtroRegimen=$j('#filtroRegimen').val();filtroCategoria=$j('#filtroCategoria').val();filtroNombre=$j('#filtroNombre').val();ArrayPrecios=$j('#ArrayPrecios').val();if(zoom!=""){zoom=parseInt(zoom);}else{zoom=14;}
var codHotel="-1";zoom=15;codHotel=document.getElementById("codHotel_"+indice).value;mapa.setZoom(zoom);var request=creaMarkersAjax();request.open("POST","/viajes_mp/appBase/jsp/googlemaps/coordenadasUnHotelV2.jsp?indiceDisponibilidad="+indiceDisponibilidad+"&indice="+indice+"&filtroRegimen="+filtroRegimen+"&filtroCategoria="+filtroCategoria+"&filtroNombre="+filtroNombre+"&filtrar="+filtrar+"&filtroPrecio="+filtroPrecio+"&ArrayPrecios="+ArrayPrecios+"&tipoFiltroHotel="+$j('#tipoFiltroHotel').val()+"&codHotel="+codHotel+"&mostrarPrecioDispo="+$j('#mostrarPrecioDispo').val(),true);request.onreadystatechange=function(){if(request.readyState==4){var xmlDoc=request.responseXML;var markers=request.responseXML.documentElement.getElementsByTagName("marker");var marcas=[];for(var i=0;i<markers.length;i++){var point=new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));var newIcon=MapIconMaker.createLabeledMarkerIcon({label:'H'});var marca=crearMarcaIndividual(point,newIcon);marcas.push(marca);}}};request.send(null);for(var a=0;a<gmarkers.length;a++){if(gmarkers[a].indice==indice){myclick(a);mapa.addOverlay(gmarkers[a]);a=gmarkers.length;}}
google.maps.event.addListener(mapa,'zoom_changed',function(){if(aplicarZoom){$j('#zoomMapa').val(mapa.getZoom());}});}
function creaIcono(imagen,ancho,alto){var iconSize=new google.maps.Size(ancho,alto);var iconImage=new google.maps.MarkerImage(imagen,iconSize);return iconImage;}
function reservarHotelGoo(prod,serv){document.getElementById("reservaProductoMapa").value="si";document.getElementById("radioServicios").value=serv;document.getElementById("radioProductoMapa").value=prod;ocultaMapaGoo(prod);cerrarInfo();document.formularioHotel.metodo.value="ajaxSeleccionar";var producto=prod;var capa='bloqueContenido';var paginaInclude='/servlet/multiproducto';forwardPostSincrono(capa,paginaInclude,'formularioHotel');mostrarCargando(2,"0100");document.formSeleccion.submit();}
function ocultaMapaGoo(indice){if(indice=='N'){document.getElementById('mapaGoogle').style.display="none";document.getElementById('mapaGoogleContenedor').style.display="none";}
else{document.getElementById('mapa_todos_hoteles').style.display="none";}}
function verMapaGoo(indice,indiceDisponibilidadHotel,nombre,tipoFiltroHotel,tipoOrdenacionHotel,zoom,distanciaPuntoReferencia,desde,hasta,contextPath){var res=true;if(indice!='-1'){escribe("NOMBREHOTELMAPA",nombre);document.getElementById('mapa_todos_hoteles').style.display="block";crearMapa(indiceDisponibilidadHotel,'mapaTodosGoogle',indice,tipoFiltroHotel,tipoOrdenacionHotel,zoom,distanciaPuntoReferencia,desde,hasta,contextPath);}else{if(document.getElementById('ultimaLatitud')==null){alert("No hay localizaciones para mostrar en el mapa");}else{document.getElementById('mapa_todos_hoteles').style.display="block";crearMapa(indiceDisponibilidadHotel,'mapaTodosGoogle',indice,tipoFiltroHotel,tipoOrdenacionHotel,zoom,distanciaPuntoReferencia,desde,hasta,contextPath);}}}
function verMapaGooIndividual(indice,indiceDisponibilidadHotel,zoom){var res=true;if($j('#latitudHotel').val()=='0.0'||$j('#longitudHotel').val()=='0.0'){alert("No hay localizaciones para mostrar en el mapa");}else{$j('#mapa_todos_hoteles_mas_info').show();crearMapaIndividual(indiceDisponibilidadHotel,'mapaMasInfoGoogle',indice,zoom);}}
function verMapaResumen(){nombre=document.getElementById('nombre').value;indice=0;latitud=document.getElementById('latitud').value;longitud=document.getElementById('longitud').value;var html='';var htmlInfo='';var label=nombre;escribe("NOMBREHOTELMAPA",nombre);document.getElementById('mapaGoogle').style.display="block";document.getElementById('mapaGoogleContenedor').style.display="block";document.getElementById('mapaGoogle').style.display='block';var zoom=15;var mapOptions={zoom:zoom,center:new google.maps.LatLng(latitud,longitud),mapTypeId:google.maps.MapTypeId.ROADMAP,scaleControl:true}
mapa=new google.maps.Map(document.getElementById(nombreCapa),mapOptions);var point=new google.maps.LatLng(parseFloat(latitud),parseFloat(longitud));var marcas=[];var marca=crearMarca(point,label,html,icono,indice,htmlInfo);marcas.push(marca);}
function masInfoHotelMapa(indice){masInfoHotel(indice);if(indice!='-1')indice='N';ocultaMapaGoo(indice);}
function mostrarHoteles(){if(document.getElementById('mapa_todos_hoteles').style.display="block"){document.getElementById('mapa_todos_hoteles').style.display="none";}}
function filtroMapa(indiceFiltro,indiceHotel){if(document.getElementById('ultimaLatitud')==null){alert("No hay localizaciones para mostrar en el mapa");}else{document.getElementById('mapa_todos_hoteles').style.display="block";document.getElementById('filtroPrecio').value=indiceFiltro;if(!document.getElementById('hotel'+indiceHotel).checked){document.getElementById('filtrar').value='';}else{document.getElementById('filtrar').value='precio';}
crearMapa(0,'mapaTodosGoogle','-1');}}
function GXml(){}
GXml.value=value;GXml.parse=parse;function value(node){if(!node){return"";}
var retStr="";if(node.nodeType==3||node.nodeType==4||node.nodeType==2){retStr+=node.nodeValue;}else if(node.nodeType==1||node.nodeType==9||node.nodeType==11){for(var i=0;i<node.childNodes.length;++i){retStr+=arguments.callee(node.childNodes[i]);}}
return retStr;}
function parse(textDoc){try{if(typeof ActiveXObject!="undefined"&&typeof GetObject!="undefined"){var b=new ActiveXObject("Microsoft.XMLDOM");b.loadXML(textDoc);return b;}else if(typeof DOMParser!="undefined"){return(new DOMParser()).parseFromString(textDoc,"text/xml");}else{return Wb(textDoc);}}
catch(c){P.incompatible("xmlparse");}
try{return Wb(textDoc);}
catch(c){P.incompatible("xmlparse");return document.createElement("div");}}
function P(){}
P.write=function(a,b){};P.writeRaw=function(a){};P.writeXML=function(a){};P.writeURL=function(a){};P.dump=function(a){};P.incompatible=function(){};P.clear=function(){};function Wb(a){return null;}
function creaMarkersAjax(){var objetoAjax=false;try{objetoAjax=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{objetoAjax=new ActiveXObject("Microsoft.XMLHTTP");}
catch(E){objetoAjax=false;}}
if(!objetoAjax&&typeof XMLHttpRequest!='undefined'){objetoAjax=new XMLHttpRequest();}
return objetoAjax;}
function geocode(){var query=document.getElementById("buscarPuntoInteres").value;if(query!=''){query+=","+document.getElementById("provinciaPaisHotel").value;}
if(query&&query.trim)query=query.trim();if(query!=geocoder.resultAddress&&query.length>1){clearTimeout(geocoder.waitingDelay);geocoder.waitingDelay=setTimeout(function(){geocoder.geocode({address:query},geocodeResult);},300);}else{document.getElementById("suggest_list").innerHTML="";geocoder.resultAddress="";geocoder.resultBounds=null;$j('#suggest_popup').hide();}
function geocodeResult(response,status){if(status==google.maps.GeocoderStatus.OK&&response[0]){geocoder.firstItem=response[0];clearListItems();var len=response.length;for(var i=0;i<len;i++){addListItem(response[i]);}}else if(status==google.maps.GeocoderStatus.ZERO_RESULTS){document.getElementById("suggest_list").innerHTML="?";geocoder.resultAddress="";geocoder.resultBounds=null;$j('#suggest_popup').hide();}else{document.getElementById("suggest_list").innerHTML=status;geocoder.resultAddress="";geocoder.resultBounds=null;$j('#suggest_popup').hide();}}}
function geocodeHome(){var query=document.getElementById("buscarPuntoInteres").value;if(query&&query.trim)query=query.trim();if(query!=geocoder.resultAddress&&query.length>1){clearTimeout(geocoder.waitingDelay);geocoder.waitingDelay=setTimeout(function(){geocoder.geocode({address:query},geocodeResult);},300);}else{document.getElementById("suggest_list").innerHTML="";geocoder.resultAddress="";geocoder.resultBounds=null;$j('#suggest_popup').hide();}
function geocodeResult(response,status){if(status==google.maps.GeocoderStatus.OK&&response[0]){geocoder.firstItem=response[0];clearListItems();var len=response.length;for(var i=0;i<len;i++){addListItemHome(response[i]);}}else if(status==google.maps.GeocoderStatus.ZERO_RESULTS){document.getElementById("suggest_list").innerHTML="?";geocoder.resultAddress="";geocoder.resultBounds=null;$j('#suggest_popup').hide();}else{document.getElementById("suggest_list").innerHTML=status;geocoder.resultAddress="";geocoder.resultBounds=null;$j('#suggest_popup').hide();}}}
function updateMap(respons){function doIt(respons){respons.geometry&&respons.geometry.viewport&&mapa.fitBounds(respons.geometry.viewport);localizacionBusqueda=respons.geometry.location;bounds=new google.maps.LatLngBounds();bounds.union(respons.geometry.viewport);mapa.fitBounds(bounds);document.getElementById("latitudPuntoReferencia").value=localizacionBusqueda.lat();document.getElementById("longitudPuntoReferencia").value=localizacionBusqueda.lng();document.getElementById("buscarPuntoInteres").value=respons.formatted_address;document.getElementById("buscarPuntoInteresCodificado").value=encode(respons.formatted_address);$j('#suggest_popup').hide();clearListItems();}
doIt(respons);setTimeout(function(){doIt(respons)},500);ordenarListaHotel('MAPA',1,false,$j('#tipoOrdenacionHotel').val());}
function mapFirst(){geocoder.firstItem.geometry&&geocoder.firstItem.geometry.viewport&&mapa.fitBounds(geocoder.firstItem.geometry.viewport);}
function addListItem(resp){var listContainer=document.getElementById("suggest_list");$j('#suggest_popup').css('top',$j('#buscarPuntoInteres').position().top+20);$j('#suggest_popup').css('left',$j('#buscarPuntoInteres').position().left+10);$j('#suggest_popup').show();var loc=resp||{};var row=document.createElement("div");row.innerHTML=loc.formatted_address;row.className="suggest_entry";row.onclick=function(){updateMap(loc);}
listContainer.appendChild(row);}
function addListItemHome(resp){var listContainer=document.getElementById("suggest_list");$j('#suggest_popup').css('top',$j('#buscarPuntoInteres').position().top+20);$j('#suggest_popup').css('left',$j('#buscarPuntoInteres').position().left+10);$j('#suggest_popup').show();var loc=resp||{};var row=document.createElement("div");row.innerHTML=loc.formatted_address;row.className="suggest_entry";row.onclick=function(){function doIt(respons){respons.geometry&&respons.geometry.viewport;localizacionBusqueda=respons.geometry.location;document.getElementById("latitudPuntoReferencia").value=localizacionBusqueda.lat();document.getElementById("longitudPuntoReferencia").value=localizacionBusqueda.lng();document.getElementById("buscarPuntoInteres").value=respons.formatted_address;document.getElementById("buscarPuntoInteresCodificado").value=encode(respons.formatted_address);$j('#suggest_popup').hide();clearListItems();}
doIt(loc);setTimeout(function(){doIt(loc)},500);}
listContainer.appendChild(row);}
function clearListItems(){var listContainer=document.getElementById("suggest_list");while(listContainer.firstChild){listContainer.removeChild(listContainer.firstChild);}}
function distanciaEntreAB(lat1,lng1,lat2,lng2)
{var lats=lat1-lat2;var lngs=lng1-lng2;var latm=lats*60*1845;var lngm=lngs*60*1845;var dist=Math.sqrt(Math.pow(latm,2)+Math.pow(lngm,2));return dist/1000;}
function calcularComboDistancias(distanciaPuntoReferencia)
{if(aplicarZoom){intervaloDistancia=(matriz[mapa.getZoom()]/4);intervalo1=intervaloDistancia;intervalo2=intervaloDistancia*2;intervalo3=intervaloDistancia*3;intervalo4=intervaloDistancia*4;if(distanciaPuntoReferencia!=""){if(distanciaPuntoReferencia<1)
distanciaPuntoReferencia="<option value='"+distanciaPuntoReferencia+"'>"+new Number((distanciaPuntoReferencia*1000)).toFixed(0)+" Mts</option> ";else
distanciaPuntoReferencia="<option value='"+distanciaPuntoReferencia+"'>"+new Number(distanciaPuntoReferencia).toFixed(1)+" Kms</option> ";}
if(intervalo1<1){intervalo1="<option value='"+intervalo1+"'>"+new Number((intervalo1*1000)).toFixed(0)+" Mts</option> ";}else{intervalo1="<option value='"+intervalo1+"'>"+new Number(intervalo1).toFixed(1)+" Kms</option> ";}
if(intervalo2<1){intervalo2="<option value='"+intervalo2+"'>"+new Number((intervalo2*1000)).toFixed(0)+" Mts</option> ";}else{intervalo2="<option value='"+intervalo2+"'>"+new Number(intervalo2).toFixed(1)+" Kms</option> ";}
if(intervalo3<1){intervalo3="<option value='"+intervalo3+"'>"+new Number((intervalo3*1000)).toFixed(0)+" Mts</option> ";}else{intervalo3="<option value='"+intervalo3+"'>"+new Number(intervalo3).toFixed(1)+" Kms</option> ";}
if(intervalo4<1){intervalo4="<option value='"+intervalo4+"'>"+new Number((intervalo4*1000)).toFixed(0)+" Mts</option> ";}else{intervalo4="<option value='"+intervalo4+"'>"+new Number(intervalo4).toFixed(1)+" Kms</option> ";}
$j('#distanciaPuntoReferencia').html("");$j('#distanciaPuntoReferencia').html(distanciaPuntoReferencia+"<option value=''>"+obtenerTextoIdioma("OPCTODOS")+"</option> "+intervalo1+intervalo2+intervalo3+intervalo4);}else{aplicarZoom=false
for(var j=0;j<matrizZoom.length;j++){var intervalo=matrizZoom[j].split('#');if(Number(intervalo[0])<=Number(distanciaPuntoReferencia)&&Number(distanciaPuntoReferencia)<Number(intervalo[1])){mapa.setZoom(j+8);aplicarZoom=true;break}}
intervalo1=Number(distanciaPuntoReferencia)/4;intervalo2=Number(distanciaPuntoReferencia)/3;intervalo3=Number(distanciaPuntoReferencia)/2;intervalo4=Number(distanciaPuntoReferencia);if(intervalo1<1){intervalo1="<option value='"+intervalo1+"'>"+new Number((intervalo1*1000)).toFixed(0)+" Mts</option> ";}else{intervalo1="<option value='"+intervalo1+"'>"+new Number(intervalo1).toFixed(1)+" Kms</option> ";}
if(intervalo2<1){intervalo2="<option value='"+intervalo2+"'>"+new Number((intervalo2*1000)).toFixed(0)+" Mts</option> ";}else{intervalo2="<option value='"+intervalo2+"'>"+new Number(intervalo2).toFixed(1)+" Kms</option> ";}
if(intervalo3<1){intervalo3="<option value='"+intervalo3+"'>"+new Number((intervalo3*1000)).toFixed(0)+" Mts</option> ";}else{intervalo3="<option value='"+intervalo3+"'>"+new Number(intervalo3).toFixed(1)+" Kms</option> ";}
if(intervalo4<1){intervalo4="<option selected=\"selected\" value='"+intervalo4+"'>"+new Number((intervalo4*1000)).toFixed(0)+" Mts</option> ";}else{intervalo4="<option selected=\"selected\" value='"+intervalo4+"'>"+new Number(intervalo4).toFixed(1)+" Kms</option> ";}
$j('#distanciaPuntoReferencia').html("");$j('#distanciaPuntoReferencia').html("<option value=''>"+obtenerTextoIdioma("OPCTODOS")+"</option> "+intervalo1+intervalo2+intervalo3+intervalo4);}}
