//  ADVERTENCIA: Todos los contenidos de mapealo.com, (javascripts, imagenes, css, html) estan protegidos por la leyes de derechos de autor
//  ADVERTENCIA: Cualquier copia es estrictamente prohibida
//  (c) 2006-2009 Mapealo.com
//  Todos los derechos reservados
//  Nota: Cualquier copia o utilizacion de los contenidos de mapealo.com sin la autorizacion por
//        escrita de la empresa esta completamente prohibido.
var NewTab=false;var TabActivo="TabMapealo";var ValEmpresa="mapealo";var Expandido=true;var ExpandidoOriginal=true;var ExpandidoDerecha=true;var ExpandidoDerechaOriginal=true;var ObjMap=null;var EventClick=null;var xmlfilas=null;var GLBactivado=false;var Lastid="";var rutaIconoCuadro="../../images/direccion/iconoCuadrado.gif";var EventClick=null;var lineaPorremover=null;var GlobalColor="#009900";var GlobalAncho=5;var GlobalTransparencia=0.9;var cualPunto=0;var Glbpoint=null;var Distancia=new Array();var indiceDistancia=-1;var ObjetoLineas=new Array();var Cuadrados=new Array();var ObjetoCuadrados=new Array();var indiceCuadrado=-1;var timerID=null;var timerRunning=false;var indiceMapa=0;var GLBActual=0;var GLBFinal=0;var GLBresPag=new Array();var timer2ID=0;var cerrandoTab=false;var invertir=true;var GLBfoLlegar="shortest";var GLBCarrito=null;var ocultarcategoria1;var GLBtextobusqueda="";var GLBCategoria="";function mostrarDisplay(capa,val){if(val){clearTimeout(retardo);}ocultarcategoria1=false;document.getElementById(capa).style.display='';}function ocultarDeinmediato(capa){clearTimeout(retardo);ocultarcategoria1=true;document.getElementById(capa).style.display='none';}function ValidarRealizarBusqueda(e,idioma){var key=window.event?e.keyCode:e.which;var keychar=String.fromCharCode(key);if(key==13){Search(idioma);return false;}}function show(idobjeto){var estado=document.getElementById(idobjeto).style.display;document.getElementById("contenidoPuntosRef").style.display="none";document.getElementById("contenidoDirecciones").style.display="none";document.getElementById("contenidoResultados").style.display="none";document.getElementById("contenidoRutasInteres").style.display="none";if(estado==""){document.getElementById(idobjeto).style.display="none";}else{document.getElementById(idobjeto).style.display="";}}function showforzado(idobjeto){document.getElementById("contenidoPuntosRef").style.display="none";document.getElementById("contenidoDirecciones").style.display="none";document.getElementById("contenidoResultados").style.display="none";document.getElementById("contenidoRutasInteres").style.display="none";document.getElementById(idobjeto).style.display="";}function DeleteBadChars(valor){var nuevostring="",temp=valor;while(nuevostring!=temp){nuevostring=temp;temp=temp.replace("í","i");temp=temp.replace("á","a");temp=temp.replace("é","e");temp=temp.replace("ó","o");temp=temp.replace("ú","u");temp=temp.replace("Á","A");temp=temp.replace("É","E");temp=temp.replace("Í","I");temp=temp.replace("Ó","O");temp=temp.replace("Ú","U");temp=temp.replace("ñ","n");temp=temp.replace("Ñ","N");}return temp;}function closeTab(){cerrandoTab=true;if(EventClick){GEvent.removeListener(EventClick);}stopTimer();document.getElementById("tab2Mapa").innerHTML="";document.getElementById("tab2Mapa").className="";document.getElementById("tab1Mapa").className="tabberactive";document.getElementById("Tab1ContentMap").className="";document.getElementById("Tab2ContentMap").className="tabbertabMapa tabbertabMapaHide";document.getElementById("TabsMapa").className="tabbernavMapa tabbertabMapaHide";map.setCenter(map.getCenter());}function GuardarExpander(){if(EventClick){GEvent.removeListener(EventClick);}ExpandidoOriginal=Expandido;Expandido=true;document.getElementById("mContent").style.display="";ExpandidoOriginalDerecha=ExpandidoDerecha;}function ExpandirContraer(quien){if(EventClick){GEvent.removeListener(EventClick);}switch(quien){case "izquierda":if(Expandido){Expandido=false;document.getElementById("mContent").style.display="none";}else{Expandido=true;document.getElementById("mContent").style.display="";};break;}}function RestaurarSides(){if(EventClick){GEvent.removeListener(EventClick);}oTextbox.hideSuggestions();oTextboxDesde.hideSuggestions();oTextboxHasta.hideSuggestions();if(ExpandidoOriginal){Expandido=true;document.getElementById("mContent").style.display="";}else{Expandido=false;document.getElementById("mContent").style.display="none";}}function switchTab(cual,quien){if(EventClick){GEvent.removeListener(EventClick);}if(quien=="tabbernavMapa"){if(cual==1){document.getElementById("tab1Mapa").className="tabberactive";document.getElementById("tab2Mapa").className="";document.getElementById("Tab2ContentMap").className="tabbertabMapa tabbertabMapaHide";document.getElementById("Tab1ContentMap").className="tabbertabMapa";}else{document.getElementById("tab2Mapa").className="tabberactive";document.getElementById("tab1Mapa").className="";document.getElementById("Tab1ContentMap").className="tabbertabMapa tabbertabMapaHide";document.getElementById("Tab2ContentMap").className="tabbertabMapa";}}else{if(cual==1){showforzado('contenidoResultados');}if(cual==2){showforzado('contenidoResultados');}}}function Ajax(){this.executeQuery=function(mode,dataSource,idioma,divID){XMLHttpRequestObject=false;var XMLHttpRequestObject=false;if(window.XMLHttpRequest){try{XMLHttpRequestObject=new XMLHttpRequest();}catch(e){}}else if(window.ActiveXObject){try{XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}if(XMLHttpRequestObject){XMLHttpRequestObject.open("GET",dataSource);XMLHttpRequestObject.onreadystatechange=function(){GLBactivado=false;if(XMLHttpRequestObject.readyState==4&&XMLHttpRequestObject.status==200){switch(mode){case "mostrar_busqueda":delete GlobalResultados;GlobalResultados=null;eval(XMLHttpRequestObject.responseText);CargarResultados(divID);break;break;}}};XMLHttpRequestObject.send(null);}}}function hideAllFila(total){var i=1;for(i=1;i<total;i++){document.getElementById('filAd'+i).style.display='none';document.getElementById('filBd'+i).style.display='none';}}function CargarResultados(divID){if(ObjMap){var val="";if(GlobalResultados.length>1){ObjMap.removeLocales();}var i=1;var IC=GlobalResultados[0][2];for(i=1;i<GlobalResultados.length;i++){var local=GlobalResultados[i];var clickText="";if(GlobalIdioma=="esp")clickText="<font style=\"color:#FF0000; font-size:10px \">Para ver haz click</font>";if(GlobalIdioma=="ing")clickText="<font style=\"color:#FF0000; font-size:10px \">Click to show</font>";val+="<tr style=\"cursor:pointer;background-image:url(../../Mapealo/images/repsearchBack.jpg);background-repeat:repeat-x;\" onclick=\"hideAllFila("+GlobalResultados.length+");document.getElementById('filAd"+i+"').style.display='';document.getElementById('filBd"+i+"').style.display='';ObjMap.centrarLocal("+(i-1)+");\">";val+="<td align=\"Left\" class=\"filas\" colspan=\"2\" style=\"overflow:hidden;text-align:left; padding:2px 2px 2px 4px;\">";val+="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"Left\" style=\"overflow:hidden;\" >";val+="<tr>";val+="<td align=\"Left\" style=\"text-align:left\"><font class=\"textoNombre\"><strong>"+(IC+i)+":</strong></font></td>";val+="<td style=\"overflow:hidden;white-space:nowrap;text-align:left\" align=\"Left\"><font class=\"textoNombre\">&nbsp;"+local[7]+"</font></td>";val+="</tr>";val+="<tr id=\"filAd"+i+"\" style=\"display:none;\">";val+="<td align=\"Left\" style=\"text-align:left\"></td>";val+="<td style=\"overflow:hidden;white-space:nowrap;text-align:left\" align=\"Left\"><font class=\"textoNombre\">"+local[3]+"&nbsp;/&nbsp;"+local[4]+"</font></td>";val+="</tr>";val+="<tr id=\"filBd"+i+"\" style=\"display:none;\">";val+="<td align=\"Left\" style=\"text-align:left\"></td>";val+="<td style=\"overflow:hidden;white-space:nowrap;text-align:left\" align=\"Left\"><font class=\"textoTelefono\">"+local[5]+"</font>&nbsp;"+clickText+"</td>";val+="</tr>";val+="</table>";val+="</td>";val+="</tr>";val+="<tr><td style=\"height:5px;\" colspan=\"2\"></td></tr>";ObjMap.addLocal(local[0],local[1],local[2],local[7],local[6],local[7],local[8],local[9],local[10],local[11],local[12],local[13],local[14],local[15],local[16],local[17],local[18],local[19],local[20],GlobalIdioma,local[22],local[23],local[24]);}if(GlobalResultados[0][0]==-1){if(GlobalIdioma=="esp"){val+="<tr>";val+="<td colspan=\"2\" align=\"Left\" style=\"border: 1px solid; color:#666666; background-color:#ffffff; font-family: Tahoma, sans-serif; font-size: 12px;font-style: normal; text-decoration: none; \">";val+="<table style=\" padding: 2px 4px 2px 4px\" cellpadding=\"0\" cellspacing=\"0\" align=\"Left\">";val+="<tr><td align=\"Left\">No se encontro la busqueda exacta</td></tr>";val+="<tr><td align=\"Left\">Cambie los criterios de b&uacute;squeda</td></tr>";val+="<tr><td align=\"Left\">Intente con otro mapa</td></tr>";val+="<tr><td align=\"Left\"><strong>C&oacute;mo cambio de mapa?</strong></td></tr>";val+="<tr><td style=\"color:#336600;\" align=\"Left\">En la esquina superior derecha,</td></tr>";val+="<tr><td style=\"color:#336600;\" align=\"Left\">hay una opci&oacute;n que dice <strong>Cambiar mapa:</strong></td></tr>";val+="</table>";val+="</td>";val+="</tr>";}if(GlobalIdioma=="ing"){val+="<tr>";val+="<td colspan=\"2\" align=\"Left\" style=\"border: 1px solid; color:#666666; background-color:#ffffff; font-family: Tahoma, sans-serif; font-size: 12px;font-style: normal; text-decoration: none; \">";val+="<table align=\"Left\" style=\" padding: 2px 4px 2px 4px\" cellpadding=\"0\" cellspacing=\"0\">";val+="<tr><td align=\"Left\">There were no exact results</td></tr>";val+="<tr><td align=\"Left\">Change your search criteria</td></tr>";val+="<tr><td align=\"Left\">Try with other map</td></tr>";val+="<tr><td align=\"Left\"><strong>How to change the map?</strong></td></tr>";val+="<tr><td align=\"Left\" style=\"color:#336600;\">On the top right corner,</td></tr>";val+="<tr><td align=\"Left\" style=\"color:#336600;\">there is an option <strong>Change map to:</strong></td></tr>";val+="</table>";val+="</td>";val+="</tr>";}}else{val+="<tr><td colspan=\"2\" align=\"right\" style=\"padding:2px 2px 2px 6px;\">";if(GlobalIdioma=="esp"){textoPagSi="Siguiente";textoPagAnte="Anterior";}if(GlobalIdioma=="ing"){textoPagSi="Next";textoPagAnte="Previous";}if(GlobalResultados[0][4].length>0)val+="<a class=\"Links_paging\" href=\"javascript:Mostrar("+GlobalResultados[0][4][0]+","+GlobalResultados[0][4][1]+","+GlobalResultados[0][4][2]+","+GlobalResultados[0][4][3]+","+GlobalResultados[0][4][4]+",'"+GlobalResultados[0][4][5]+"','"+GlobalResultados[0][4][6]+"',"+GlobalResultados[0][4][7]+","+GlobalResultados[0][4][8]+","+GlobalResultados[0][4][9]+");\"><-"+textoPagAnte+"</a>&nbsp;";if(GlobalResultados[0][5].length>0)val+="<a class=\"Links_paging\" href=\"javascript:Mostrar("+GlobalResultados[0][5][0]+","+GlobalResultados[0][5][1]+","+GlobalResultados[0][5][2]+","+GlobalResultados[0][5][3]+","+GlobalResultados[0][5][4]+",'"+GlobalResultados[0][5][5]+"','"+GlobalResultados[0][5][6]+"',"+GlobalResultados[0][5][7]+","+GlobalResultados[0][5][8]+","+GlobalResultados[0][5][9]+");\">"+textoPagSi+"-></a>&nbsp;";val+="</td></tr>";};if(GlobalResultados.length>1){showforzado('contenidoResultados');document.getElementById(divID).innerHTML="<table border=\"0\" width=\"220px\" cellpadding=\"0\" cellspacing=\"0\" style=\"overflow:hidden; table-layout:fixed\">"+val+"</table>";ObjMap.centrarLocal(0);map.setZoom(15);showforzado('contenidoResultados');}else{showforzado('contenidoResultados');document.getElementById(divID).innerHTML="<table border=\"0\" width=\"220px\" cellpadding=\"0\" cellspacing=\"0\" style=\"overflow:hidden;table-layout:fixed\">"+val+"</table>";};RestaurarSides();}}var ListaTipos=new Array();function AgregarTipoPunto(obj,id){if(ObjMap){stopTimer();if(document.getElementById("ckPr"+id).checked){ListaTipos[id]=id;}else{ListaTipos[id]=-1;};GLBtiposPuntos="";var i=0;for(i=0;i<ListaTipos.length;i++){if(ListaTipos[i]&&ListaTipos[i]!=-1){GLBtiposPuntos+=","+ListaTipos[i];}}loadAllStructure();}}function AgregarTodosChecks(ids){if(ObjMap){stopTimer();GLBtiposPuntos="";var arreglo=ids.split(",");var elem="";for(i=0;i<arreglo.length-1;i++){elem=arreglo[i].replace("ckPr","");document.getElementById(arreglo[i]).checked=true;GLBtiposPuntos+=","+elem;ListaTipos[elem]=elem;}loadAllStructure();}}function QuitarTodosChecks(ids){if(ObjMap){stopTimer();GLBtiposPuntos="";var elem="";var arreglo=ids.split(",");for(i=0;i<arreglo.length-1;i++){elem=arreglo[i].replace("ckPr","");document.getElementById(arreglo[i]).checked=false;ListaTipos[elem]=-1;}loadAllStructure();}}function MostrarSubcategorias(val){stopTimer();var HTMLSubcat=new ComboboxLoader();HTMLSubcat.inicializar("Subcategorias","Subcategorias","TextoInput","","");var IdcatS=GetSelectedValue(val);var j=0,i=0;var encontro=false;for(i=0;i<GlobalMenu.length;i++){var categoriaCompleta=GlobalMenu[i];var cat=categoriaCompleta[0];var imagenCat=cat[0];var nombreCat=cat[1];var idCat=cat[3];var subcategorias=categoriaCompleta[1];if(idCat==IdcatS){encontro=true;for(j=0;j<subcategorias.length;j++){var subcat=subcategorias[j];var nombreSubcat=subcat[0];var rutaIrASubcat=subcat[1];var idSubcat=subcat[2];HTMLSubcat.agregaropcion("",idSubcat,nombreSubcat);}break;}}if(!encontro){if(GlobalIdioma=="esp"){HTMLSubcat.agregaropcion("",-1,"Todos");}else{HTMLSubcat.agregaropcion("",-1,"All");}}HTMLSubcat.finalizar();window.document.getElementById("Subcategorias_Div").innerHTML=HTMLSubcat.getCombo();}function hidesugestions(){oTextbox.hideSuggestions();oTextboxDesde.hideSuggestions();oTextboxHasta.hideSuggestions();}function Search(idioma){if(ObjMap){if(EventClick){GEvent.removeListener(EventClick);}hidesugestions();stopTimer();GuardarExpander();showforzado('contenidoResultados');var obj=document.getElementById("Tab2Content");obj.innerHTML="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding-top:2px; padding-bottom:2px; padding-right:2px; padding-left:2px; \"><tr><td align=\"center\"><img alt=\"costa rica\" src=\"../../images/index/loading.gif\" width=\"32\" height=\"32\"></td></tr></table>";var subcat=-1;var cat=-1;var cantones=-1;GLBtextobusqueda=DeleteBadChars(window.document.getElementById("txtBusqueda").value);var txtBusqueda=DeleteBadChars(window.document.getElementById("txtBusqueda").value);var conection=new Ajax();var query="../../Mapealo/CapaControl/cntrl_busquedas.php?modo=search";query+="&subcategoria="+subcat;query+="&cat="+cat;query+="&sector="+GlobalSector;query+="&pais="+GlobalPais;query+="&provincia=-1";query+="&cantones=-1";query+="&distancia="+1;query+="&puntosRef="+1;query+="&txtBusqueda="+txtBusqueda;query+="&idioma="+idioma;query+="&pag=0";query+="&pag2=0";query+="&empresa=";GlobalEmpresa="";conection.executeQuery("mostrar_busqueda",query,idioma,"Tab2Content");}}function SearchT(idioma,textoBusqueda,categoria){if(ObjMap){window.document.getElementById("txtBusqueda").value=textoBusqueda;if(categoria==""){categoria=-1;}Mostrar(-1,categoria,"","","",textoBusqueda,idioma,0,0,GlobalPais);}}function Mostrar(subcategoria,cat,cantones,distancia,puntosRef,txtBusqueda,idioma,pag,pag2,pais){if(ObjMap){if(EventClick){GEvent.removeListener(EventClick);}hidesugestions();stopTimer();GuardarExpander();GLBtextobusqueda=txtBusqueda;showforzado('contenidoResultados');var obj=document.getElementById("Tab2Content");obj.innerHTML="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding-top:2px; padding-bottom:2px; padding-right:2px; padding-left:2px; \"><tr><td align=\"center\"><img alt=\"costa rica\" src=\"../../images/index/loading.gif\" width=\"32\" height=\"32\"></td></tr></table>";var conection=new Ajax();var query="../../Mapealo/CapaControl/cntrl_busquedas.php?modo=search";query+="&subcategoria="+subcategoria;query+="&cat="+cat;query+="&sector="+GlobalSector;query+="&provincia=-1";query+="&cantones=-1";query+="&distancia="+1;query+="&puntosRef="+1;query+="&pais="+pais;query+="&txtBusqueda="+txtBusqueda;query+="&idioma="+idioma;query+="&pag="+pag;query+="&pag2="+pag2;query+="&empresa="+GlobalEmpresa;conection.executeQuery("mostrar_busqueda",query,idioma,"Tab2Content");}}function SearchAuto(cat,subcategoria,idioma){if(ObjMap){if(EventClick){GEvent.removeListener(EventClick);}hidesugestions();stopTimer();GuardarExpander();showforzado('contenidoResultados');GLBCategoria=cat;var obj=document.getElementById("Tab2Content");obj.innerHTML="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding-top:2px; padding-bottom:2px; padding-right:2px; padding-left:2px; \"><tr><td align=\"center\"><img alt=\"costa rica\" src=\"../../images/index/loading.gif\" width=\"32\" height=\"32\"></td></tr></table>";var conection=new Ajax();var query="../../Mapealo/CapaControl/cntrl_busquedas.php?modo=search";query+="&subcategoria="+subcategoria;query+="&cat="+cat;query+="&sector="+GlobalSector;query+="&pais="+GlobalPais;query+="&provincia=-1";query+="&cantones=-1";query+="&distancia="+1;query+="&puntosRef="+1;query+="&txtBusqueda=";query+="&idioma="+idioma;query+="&pag=0";query+="&pag2=0";query+="&empresa=";GlobalEmpresa="";conection.executeQuery("mostrar_busqueda",query,idioma,"Tab2Content");}}function SearchInicial(idioma){if(ObjMap){if(EventClick){GEvent.removeListener(EventClick);}hidesugestions();stopTimer();GuardarExpander();showforzado('contenidoResultados');var obj=document.getElementById("Tab2Content");obj.innerHTML="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding-top:2px; padding-bottom:2px; padding-right:2px; padding-left:2px; \"><tr><td align=\"center\"><img alt=\"costa rica\" src=\"../../images/index/loading.gif\" width=\"32\" height=\"32\"></td></tr></table>";var conection=new Ajax();var query="../../Mapealo/CapaControl/cntrl_busquedas.php?modo=search";query+="&subcategoria=-1";query+="&cat=-1";query+="&provincia=-1";query+="&cantones=-1";query+="&empresa="+GlobalEmpresa;query+="&distancia="+1;query+="&puntosRef="+1;query+="&pais="+GlobalPais;query+="&txtBusqueda=";query+="&idioma="+idioma;query+="&pag=0";query+="&pag2=0";conection.executeQuery("mostrar_busqueda",query,idioma,"Tab2Content");}}function CreateTab(id,idioma,nombre){cerrandoTab=false;hidesugestions();showPaginaClientes();LoadContentEmpresa(id,idioma,'Tab2ContentMapTD',"../../Mapealo/scripts/infopage.js");}function LoadContentEmpresa(id,idioma,content,jsFile){if(!cerrandoTab){if(id!=Lastid){stopTimer();Lastid=id;ajaxpagecontent("../../Mapealo/Mapealo/infopageincrustada.php?id="+id+"&idioma="+idioma,content,jsFile);}else{}}else{cerrandoTab=false;}}function distanciaTotal(puntosDistancia){var suma=0;var i=0;var medida=" KM.";if(puntosDistancia.length>1){for(i=0;i<puntosDistancia.length-1;i++){suma=suma+distHaversine(puntosDistancia[i].getPoint(),puntosDistancia[i+1].getPoint());}}suma=(Math.round(suma*100)/100);if(suma<1){suma=suma*1000;medida=" Metros.";}return suma+medida;}function distHaversine(punto1,punto2){var lat1=punto1.lat();var lon1=punto1.lng();var lat2=punto2.lat();var lon2=punto2.lng();var R=6371;var dLat=(new GLatLng((lat2-lat1),0)).latRadians();var dLon=(new GLatLng(0,(lon2-lon1))).lngRadians();lat1=punto1.latRadians(),lat2=punto2.latRadians();var a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(lat1)*Math.cos(lat2)*Math.sin(dLon/2)*Math.sin(dLon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=R*c;return d;}function getScrollTop(){if(document.documentElement.scrollTop)return document.documentElement.scrollTop;if(document.body.scrollTop)return document.body.scrollTop;if(window.pageYOffset)return window.pageYOffset;return 0;}function getWinHeight(){if(window.innerHeight)return window.innerHeight;if(document.documentElement.clientHeight)return document.documentElement.clientHeight;if(document.body.clientHeight)return document.body.clientHeight;return 0;}function PosObjeto(cP,objeto){var dB=document.body;var eL=0;var eT=0;var cF=objeto;for(var p=cP;p&&p.tagName!='BODY';p=p.offsetParent){eL+=p.offsetLeft;eT+=p.offsetTop;}var eH=cP.offsetHeight;var dH=parseInt(cF.style.height);var sT=getScrollTop();if(eT-dH>=sT&&eT+eH+dH>getWinHeight()+sT)eT-=dH;else eT+=eH;cF.style.left=(eL-30)+'px';cF.style.top=eT+'px';}var paradaAnterior=0;function PlaySlideShow(){StopSlideShow();if(GlobalgeoXml){if(GlobalgeoXml.Totalpoints.length>0){GLBActual=0;GLBFinal=GlobalgeoXml.Totalpoints.length;var car=new GIcon();car.image="../../images/direccion/carrito.png";car.iconSize=new GSize(32,18);car.iconAnchor=new GPoint(16,9);GLBCarrito=new GMarker(GlobalgeoXml.Totalpoints[0],{icon:car});map.addOverlay(GLBCarrito);paradaAnterior=0;document.getElementById("paradaruta"+paradaAnterior).style.backgroundColor="#FFFF99";map.panTo(GlobalgeoXml.Totalpoints[0]);startTimer('ActivarAnimacion()');}}}function StopSlideShow(){GLBActual=0;if(GLBCarrito){map.removeOverlay(GLBCarrito);}stopTimer();}function stopTimer(){if(timerRunning){clearTimeout(timerID);timerRunning=false;}}function startTimer(funcion){stopTimer();timerID=setTimeout(funcion,100);timerRunning=true;}function ActivarAnimacion(){if(GLBActual==GLBFinal){stopTimer();}else{if(GLBActual%10==0){map.panTo(GlobalgeoXml.Totalpoints[GLBActual]);}var ppas=Math.round(GLBFinal/GLBTotalTags)+1;if(GLBActual%ppas==0){document.getElementById("Tab2Content").scrollTop=paradaAnterior*45;if(document.getElementById("paradaruta"+paradaAnterior)){document.getElementById("paradaruta"+paradaAnterior).style.backgroundColor="#FFFFFF";}paradaAnterior++;if(document.getElementById("paradaruta"+paradaAnterior)){document.getElementById("paradaruta"+paradaAnterior).style.backgroundColor="#FFFF99";}}GLBCarrito.setPoint(GlobalgeoXml.Totalpoints[GLBActual]);GLBActual++;timerID=setTimeout('ActivarAnimacion()',100);}}function crearIcono(ruta){var baseIcon=new GIcon();var ancho=10;var alto=10;baseIcon.image=ruta;baseIcon.iconSize=new GSize(ancho,alto);baseIcon.iconAnchor=new GPoint(ancho/2,alto);return baseIcon;}var divPuntosactivo=true;function mostrarDiv(quien){if(quien=="divPuntos"){if(divPuntosactivo==true){divPuntosactivo=false;document.getElementById("divPuntos").style.display="none";}else{divPuntosactivo=true;document.getElementById("divPuntos").style.display="";}}}function ObtenerCoordenadasPunto(id,figuras_puntosFigura){if(figuras_puntosFigura){for(p=0;p<figuras_puntosFigura.length;p++){if(figuras_puntosFigura[p][0]==id){var figuras_puntolat=parseFloat(replaceZeros(figuras_puntosFigura[p][1]));var figuras_puntolng=parseFloat(replaceZeros(figuras_puntosFigura[p][2]));return new GLatLng(figuras_puntolat,figuras_puntolng);}}}}function ResultSuggestions(){this.results=[];this.oAutoSuggestControl=null;}ResultSuggestions.prototype.requestSuggestions=function(oAutoSuggestControl,bTypeAhead){var aSuggestions=this.results;var sTextboxValue=oAutoSuggestControl.textbox.value;var txtBusqueda=DeleteBadChars(sTextboxValue);var query="../../Mapealo/CapaControl/cntrl_busquedas.php?modo=searchSuggestions";this.oAutoSuggestControl=oAutoSuggestControl;query+="&subcategoria=-1";query+="&cat=-1";query+="&sector="+GlobalSector;query+="&pais="+GlobalPais;query+="&txtBusqueda="+txtBusqueda;query+="&idioma="+GlobalIdioma;ajaxReq.get(query,funcionR);};function funcionR(result){if(result!=""){var res=eval(result);GLBsuggestionsResults.results=res;GLBsuggestionsResults.oAutoSuggestControl.autosuggest(res,false);}}function EnviarPeticionDefault(){if(PuntosDireccion){if(GlobalgeoXml){GlobalgeoXml.remove();map.removeOverlay(GlobalgeoXml);}EnviarPeticion(PuntosDireccion[0],PuntosDireccion[1]);}}function EnviarPeticion(Punto1,Punto2){if(Punto1!=null&&Punto2!=null&&!GLBprocesando){GLBprocesando=true;if(StopSlideShow){StopSlideShow();}hidesugestions();stopTimer();GuardarExpander();showforzado('contenidoResultados');var resultados="";if(document.getElementById("formallegar")){GLBfoLlegar=GetSelectedValue(document.getElementById("formallegar"));resultados+="&Algoritmo="+GLBfoLlegar;}else{resultados+="&Algoritmo=shortest";};var obj=document.getElementById("Tab2Content");obj.innerHTML="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"padding-top:2px; padding-bottom:2px; padding-right:2px; padding-left:2px; \"><tr><td align=\"center\"><img alt=\"cargando\" src=\"../../images/index/loading.gif\" width=\"32\" height=\"32\"></td></tr></table>";resultados+="&XOrigen="+Punto1.point.lng();resultados+="&YOrigen="+Punto1.point.lat();resultados+="&XDestino="+Punto2.point.lng();resultados+="&YDestino="+Punto2.point.lat();resultados+="&Idioma="+GlobalIdioma;resultados+="&Zoom="+map.getZoom();if(GlobalgeoXml){map.removeOverlay(GlobalgeoXml);}ajaxReq.get("http://"+window.location.hostname+"/MDireccion/CapaControl/cntrl_direccion.php?modo=direccionText"+resultados,funcionrespuesta);if(GlobalgeoXml){GlobalgeoXml.remove();}document.getElementById("loadingDIV").innerHTML=loadingText;GlobalgeoXml=new EGeoXml("GlobalgeoXml",map,"http://"+window.location.hostname+"/MDireccion/CapaControl/cntrl_direccion.php?modo=direccionKML"+resultados,document.getElementById("loadingDIV"));GlobalgeoXml.parse();var markerBounds=new GLatLngBounds();markerBounds.extend(new GLatLng(Punto1.point.lat(),Punto1.point.lng()));markerBounds.extend(new GLatLng(Punto2.point.lat(),Punto2.point.lng()));map.setCenter(new GLatLng((Punto1.point.lat()+Punto2.point.lat())/2,(Punto1.point.lng()+Punto2.point.lng())/2),map.getBoundsZoomLevel(markerBounds));}}var estadoruta=false;var rutaVar=null;function RutaDemo(){if(!estadoruta){estadoruta=true;if(PuntosDireccion[0]!=null){PuntosDireccion[0].remove();}PuntosDireccion[0]=new PuntoDireccion();PuntosDireccion[0].set(map.getCenter(),0);PuntosDireccion[0].createMarker(map.getZoom(),false);PuntosDireccion[0].addOverlay();if(PuntosDireccion[1]!=null){PuntosDireccion[1].remove();}PuntosDireccion[1]=new PuntoDireccion();PuntosDireccion[1].set(new GLatLng(9.929962275855889,-84.05227661132812,0),1);PuntosDireccion[1].createMarker(map.getZoom(),false);PuntosDireccion[1].addOverlay();EnviarPeticion(PuntosDireccion[0],PuntosDireccion[1]);map.setZoom(14);}else{estadoruta=false;PuntosDireccion[0].remove();PuntosDireccion[1].remove();PuntosDireccion[0]=null;PuntosDireccion[1]=null;}}function funcionrespuesta(respuesta){var j=0;var i=0;var p=0;var k=0;var entrar=true;var puntoCentro;var xmlfilas=eval(respuesta);GLBresPag=null;GLBresPag=new Array();val='<tr valign="top" ><td style="vertical-align:top; padding:2px;border-bottom:1px solid #cccccc;"><img style="cursor:pointer" onclick="PlaySlideShow()" src="../../images/direccion/animar.gif" />&nbsp;<img style="cursor:pointer" onclick="StopSlideShow()" src="../../images/direccion/parar.gif" /></td></tr>';if(GLBfoLlegar=="shortest"){comboFollegar='<select id="formallegar" onchange="EnviarPeticionDefault()"><option value="shortest" selected>Ruta mas corta</option><option value="quickest">Ruta mas rapida</option></select>';}else{comboFollegar='<select id="formallegar" onchange="EnviarPeticionDefault()"><option value="shortest">Ruta mas corta</option><option value="quickest" selected>Ruta mas rapida</option></select>';};val+='<tr valign="top" ><td style="vertical-align:top; padding:2px;border-bottom:1px solid #cccccc;"><strong>Ruta:&nbsp;'+comboFollegar+'<strong></td></tr>';val+='<tr valign="top" ><td style="vertical-align:top; padding:2px;border-bottom:1px solid #cccccc; " align="right"><img style="cursor:pointer" onclick="InvertirRuta()" src="../../images/direccion/rutaInvertida.gif" /></td></tr>';if(xmlfilas){GLBTotalTags=xmlfilas[1].length;i=0;for(i=0;i<xmlfilas[1].length;i++){val+='<tr valign="top" ><td style="vertical-align:top; padding:2px;border-bottom:1px solid #cccccc; background-color:#ffffff" id="paradaruta'+i+'">'+xmlfilas[1][i]+'</td></tr>';}val+='<tr valign="top" ><td align="top" style="vertical-align:top; padding:2px;border-bottom:1px solid #cccccc; background-color:#FFFFFF;"><a href="http://www.rsgps.net" target="_blank">Comprar mapa para GPS Garmin</a></td></tr>';ShowParadas(val);}}function ShowParadas(val){document.getElementById("Tab2Content").innerHTML="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:100%;table-layout:fixed\">"+val+"</table>";}function InvertirRuta(){if(invertir){EnviarPeticion(PuntosDireccion[1],PuntosDireccion[0]);invertir=false;}else{EnviarPeticion(PuntosDireccion[0],PuntosDireccion[1]);invertir=true;}}window.onresize=setHeightsforContent;var GLBsuggestionsResults=new ResultSuggestions();function setHeightsforContent(){if(document.getElementById("map")){document.getElementById("map").style.height=vpHeight()-112-70+"px";}if(document.getElementById("mContent")){document.getElementById("mContent").style.height=vpHeight()-124+"px";}if(document.getElementById("Tab2ContentMapTD")){document.getElementById("Tab2ContentMapTD").style.height=vpHeight()-76+"px";}if(document.getElementById("Tab2Content")){document.getElementById("Tab2Content").style.height=vpHeight()-136-90+"px";}if(document.getElementById("divPuntosRef")){document.getElementById("divPuntosRef").style.height=vpHeight()-160-70+"px";}if(document.getElementById("DivSendMapa")){document.getElementById("DivSendMapa").style.left=(vpWidth()-390)/2+"px";}}function showPaginaClientes(){if(document.getElementById("Tab2ContentMapTD")){document.getElementById("Tab2ContentMapTD").style.display="";}}function hidePaginaClientes(){document.getElementById("Tab2ContentMapTD").style.display="none";}function vpHeight(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;}function vpWidth(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;}function EnviarMapaC(form){if(CheckEmail(form.CorreoAmigo.value)&&CheckEmail(form.Correotuyo.value)){document.getElementById('Layer2').style.visibility="hidden";form.submit();}else{document.getElementById('Layer2').style.visibility="visible";document.getElementById('RespuestaTexto').innerHTML="Revisa tu correo";window.document.getElementById('Correotuyo').value='';window.document.getElementById('CorreoAmigo').value='';}}function CrearRutaMapa(){var xp1="";var yp1="";var xp2="";var yp2="";if(PuntosDireccion[0]!=null){xp1=PuntosDireccion[0].point.lat();yp1=PuntosDireccion[0].point.lng();}if(PuntosDireccion[1]!=null){xp2=PuntosDireccion[1].point.lat();yp2=PuntosDireccion[1].point.lng();}var urlA=encodeURIComponent("http://mapealo.navegalo.com/Mapealo/Mapealo/index.php?pais="+GlobalPais+"&idioma="+GlobalIdioma+"&Xcentro="+map.getCenter().lat()+"&Ycentro="+map.getCenter().lng()+"&Xp1="+xp1+"&Yp1="+yp1+"&Xp2="+xp2+"&Yp2="+yp2+"&Zoom="+map.getZoom()+"&empresa="+GlobalEmpresa+"&sector="+GlobalSector+"&textobusqueda="+GLBtextobusqueda+"&Categoria="+GLBCategoria);var textA=encodeURIComponent("Revisa mi mapa");window.location.href="http://www.facebook.com/sharer.php?u="+urlA+"&t="+textA;}function AbrirMapa(){var xp1="";var yp1="";var xp2="";var yp2="";if(PuntosDireccion[0]!=null){xp1=PuntosDireccion[0].point.lat();yp1=PuntosDireccion[0].point.lng();}if(PuntosDireccion[1]!=null){xp2=PuntosDireccion[1].point.lat();yp2=PuntosDireccion[1].point.lng();}document.getElementById("Mensaje").value="http://mapealo.navegalo.com/Mapealo/Mapealo/index.php?pais="+GlobalPais+"&idioma="+GlobalIdioma+"&Xcentro="+map.getCenter().lat()+"&Ycentro="+map.getCenter().lng()+"&Xp1="+xp1+"&Yp1="+yp1+"&Xp2="+xp2+"&Yp2="+yp2+"&Zoom="+map.getZoom()+"&empresa="+GlobalEmpresa+"&sector="+GlobalSector+"&textobusqueda="+GLBtextobusqueda+"&Categoria="+GLBCategoria;document.getElementById("DivSendMapa").style.display="";}function CerrarMapa(){document.getElementById("DivSendMapa").style.display="none";}function CerrarCorreo(){parent.CerrarMapa();}function Ubicame(){ajaxReq.get("http://"+window.location.hostname+"/Mapealo/CapaControl/cntrl_rutas.php?modo=getmylocation",crearPuntoMyUbicacion);}function crearPuntoMyUbicacion(respuesta){eval(respuesta);if(GlobalMyLng!=""&&GlobalMyLng!=""){if(PuntosDireccion[0]!=null){PuntosDireccion[0].remove();}var punto=new GLatLng(parseFloat(GlobalMyLat),parseFloat(GlobalMyLng),0);PuntosDireccion[0]=AgregarPunto(punto,1);map.setZoom(16);map.panTo(punto);}}var estadoGrid=false;var gridVar=null;var gridPapa=null;function HabilitarGrid(){if(!estadoGrid){gridVar=new LatLonGraticule();gridPapa=map.addOverlay(gridVar);estadoGrid=true;}else{estadoGrid=false;gridVar.remove();gridVar=null;}}
