function CMapa(c,a,b){this.listaContenidos;this.listaMarcadores;this.opcionesMarcadoresLineas;this.managerparadas;this.divCarga=document.getElementById(b);this.initialize=function(){try{var e=null;if(GBrowserIsCompatible()){e=new GMap2(document.getElementById(c));a=a||{};if(a.verGoogleBar!=undefined){e.enableGoogleBar()}if(a.verZoomSel!=undefined){}if(a.verOverview!=undefined&&a.verOverview){var g=new GOverviewMapControl(new GSize(200,200));e.addControl(g)}var d=new GIcon();d={image:"./imagenes/icono_paradaB.png",iconSize:new GSize(7,7),shadowSize:new GSize(1,1),iconAnchor:new GPoint(3,3),infoWindowAnchor:new GPoint(3,3)};this.opcionesMarcadoresLineas={icon:d,draggable:false};e.addControl(new GLargeMapControl(),new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(7,32)));e.addControl(new GMapTypeControl())}return e}catch(f){return null}};this.mapaObj=this.initialize()}CMapa.prototype.centrar=function(c,b,a){if(this.mapaObj==null){return}this.mapaObj.setCenter(new GLatLng(c,b),a)};CMapa.prototype.ajustarZoom=function(b){var a=b;if(b==-1){a=this.mapaObj.getZoom()}this.mapaObj.setZoom(a)};CMapa.prototype.creaMarcador=function(i,f){if(this.mapaObj==null){return}var b=new GLatLng(i.posicionLat,i.posicionLng);var a=new GMarker(b,this.opcionesMarcadoresLineas);var h=new Array(i.lineas.length);for(var e=0;e<i.lineas.length;e++){var c=i.creaHtml(f);var d=new GInfoWindowTab(i.lineas[e],c);h[e]=d}this.listaContenidos[f]=h;GEvent.addListener(a,"click",function(){muestraInformacionParada(i,a);actualizar(f)});this.listaMarcadores[f]=a};CMapa.prototype.callbackClick=function(){};CMapa.prototype.activarMarcadores=function(a){this.managerparadas=new MarkerManager(this.mapaObj);this.managerparadas.addMarkers(this.listaMarcadores,a);this.managerparadas.refresh();this.divCarga.style.display="none"};CMapa.prototype.mostrarMensajeEsperaCarga=function(a){this.divCarga.childNodes[0].innerHTML=a;this.divCarga.style.display=""};CMapa.prototype.ocultarMensajeEsperaCarga=function(){if(this.divCarga.style.display==""){this.divCarga.style.display="none"}};CMapa.prototype.mostrarMarcadores=function(b){for(var a=0;a<this.listaMarcadores.length;a++){if(b){this.listaMarcadores[a].hide()}else{this.listaMarcadores[a].show()}}};CMapa.prototype.borrarMarcadores=function(){this.mapaObj.clearOverlays();this.listaMarcadores=new Array();this.listaContenidos=new Array();if(this.managerparadas){this.managerparadas.clearMarkers()}};CMapa.prototype.mostrarEspera=function(a,b){this.listaMarcadores[a].openInfoWindow(b)};CMapa.prototype.mostrarInfoMarcador=function(a,b){var c=this.listaContenidos[a].length;if((b<0)||(b>=c)){b=0}var d={selectedTab:b};this.listaMarcadores[a].openInfoWindowTabsHtml(this.listaContenidos[a],d)};CMapa.prototype.actualizaTabParada=function(d,b){var e=d.posicionEnMapa;var a=d.creaHtml(e);var c=b;if((this.listaContenidos[e].length==1)||(this.listaContenidos[e].length<=b)){c=0}this.listaContenidos[e][c]=new GInfoWindowTab(d.lineas[c],a);this.mostrarInfoMarcador(e,c)};CMapa.prototype.getTabSeleccionado=function(){return this.mapaObj.getInfoWindow().getSelectedTab()};CMapa.prototype.destroy=function(){this.mapaObj=null;this.listaContenidos=null;this.listaMarcadores=null;this.opcionesMarcadoresLineas=null;this.managerparadas=null;this.divCarga=null};function esMultiple(){if(this.lineas.length>1){return true}return false}function creaHtml(c){var b="auto";if(this.lineas.length>1){b=88*(this.lineas.length)}var a='<table style="width: '+b+'px; ">';a+="<tr>";a+='<td><img src="./imagenes/logoPeq.png" alt="" /><b> N&uacute;m: </b>'+this.numero+"</td>";if(this.lineas.length==1){a+="<td><b>L&iacute;nea: </b>"+this.lineas[0]+"</td>"}a+='</tr><tr><td colspan="2"><hr style="color: #631f27;"/></td></tr><tr>';a+='<td colspan="2">'+this.nombre+"</td>";a+="</tr>";a+="<tr>";a+='<td colspan="2"><b>Primera llegada: </b>';if(this.tiempoE1==""||this.tiempoE1=="-1"){a+="Sin estimaciones"}else{if(this.tiempoE1=="0"){a+="Salida inmediata"}else{if(this.tiempoE1=="-"){a+="Pulse actualizar"}else{if(parseInt(this.tiempoE1)>30){a+="> 30 min."}else{a+=this.tiempoE1+" min. (distancia: "+this.distanciaE1+" m.)"}}}}a+="</td>";a+="</tr><tr>";a+='<td colspan="2"><b>Siguiente: </b>';if(this.tiempoE2==""||this.tiempoE2=="-1"){a+="Sin estimaciones"}else{if(this.tiempoE2=="0"){a+="Salida inmediata"}else{if(this.tiempoE2=="-"){a+="Pulse actualizar"}else{if(parseInt(this.tiempoE2)>30){a+="> 30 min."}else{a+=this.tiempoE2+" min. (distancia: "+this.distanciaE2+" m.)"}}}}a+="</td>";a+="</tr><tr>";a+='<td><a href="javascript:actualizar('+c+')" style="font-weight: bolder;">Actualizar</a></td>';if(this.tieneStView){a+='<td><a href="javascript:centrarVistaReal('+this.posicionLat+","+this.posicionLng+')" style="font-weight: bolder;color: blue;">Centrar vista real</a></td>'}a+="</tr></table>";this.posicionEnMapa=c;return a}function CParada(a,d,e,c,b){this.nombre=a;this.numero=d;this.posicionLat=e;this.posicionLng=c;this.lineas=b;this.esMultiple=esMultiple;this.tiempoE1="-";this.distanciaE1="-";this.tiempoE2="-";this.distanciaE2="-";this.tieneStView=false;this.dirty=false;this.posicionEnMapa=-1;this.creaHtml=creaHtml}CParada.prototype.destroy=function(){this.nombre=null;this.numero=null;this.posicionLat=null;this.posicionLng=null;this.lineas=null;this.esMultiple=null;this.tiempoE1=null;this.distanciaE1=null;this.tiempoE2=null;this.distanciaE2=null;this.tieneStView=null;this.dirty=null;this.posicionEnMapa=null;this.creaHtml=null};function CVistaCalle(a){this.vistaCalle=null;this.initialize=function(){try{if(GBrowserIsCompatible()){return new GStreetviewPanorama(document.getElementById(a))}else{return null}}catch(b){return null}};this.vistaCalle=this.initialize()}CVistaCalle.prototype.centrar=function(c,b,f,d){if(this.vistaCalle==null){return}var a=new GLatLng(c,b);var e={yaw:f,pitch:d};this.vistaCalle.setLocationAndPOV(a,e)};CVistaCalle.prototype.destroy=function(){this.vistaCalle=null};function CTags(){}CTags.lista_paradas="lista_paradas";CTags.parada="parada";CTags.attParada_numero="numero";CTags.attParada_latitud="lat";CTags.attParada_longitud="lng";CTags.lista_datos="lista_datos";CTags.dato="dato";CTags.attDato_ident="id";CTags.attDato_identNombre="nombre";CTags.attDato_identStview="chkstview";CTags.lista_lineas="lista_lineas";CTags.linea="linea";CTags.attLinea_macro="macro";CTags.recorrido="recorrido";CTags.attRecorrido_ancho="ancho";CTags.attRecorrido_color="color";CTags.lista_puntos="lista_puntos";CTags.punto="punto";CTags.attPunto_latitud="lat";CTags.attPunto_longitud="lng";CTags.estimacion="estimacion";function CXML(){this.listaParadas=new Array()}CXML.prototype.generaParadas=function(n){this.listaParadas=new Array();if(n==null){return false}var b=n.documentElement.getElementsByTagName(CTags.parada);if(b==null){return null}var m;var p;var l;var o;var c;var a;var e;var h;for(var g=0;g<b.length;g++){m=b[g].getAttribute(CTags.attParada_numero);p=parseFloat(b[g].getAttribute(CTags.attParada_latitud));l=parseFloat(b[g].getAttribute(CTags.attParada_longitud));o="";c="";a=b[g].childNodes[0];for(var f=0;f<a.childNodes.length;f++){if(a.childNodes[f].attributes.length>0){if(a.childNodes[f].getAttribute(CTags.attDato_ident)==CTags.attDato_identNombre){o=a.childNodes[f].childNodes[0].nodeValue}else{if(a.childNodes[f].getAttribute(CTags.attDato_ident)==CTags.attDato_identStview){c=a.childNodes[f].childNodes[0].nodeValue}else{}}}else{return null}}e=b[g].childNodes[1];if(e.childNodes.length==0){return false}h=new Array(e.childNodes.length);for(var d=0;d<e.childNodes.length;d++){h[d]=e.childNodes[d].childNodes[0].nodeValue}this.listaParadas[g]=new CParada(o,m,p,l,h);this.listaParadas[g].tieneStView=(c=="-1")?true:false}return this.listaParadas};CXML.prototype.crearObjetoXML2=function(a){try{xmlHandler=new ActiveXObject("Microsoft.XMLDOM")}catch(b){try{xmlHandler=document.implementation.createDocument("","",null)}catch(b){alert("Su navegador no puede soportar este script")}}try{xmlHandler.async=false;xmlHandler.load(a);return xmlHandler}catch(b){alert(b.message);return null}};CXML.prototype.cargarParadasDesdeXML2=function(a){return this.generaParadas(this.crearObjetoXML2(a))};CXML.prototype.cargarParadasDesdeURL=function(a,d){var c=GXmlHttp.create();var b=this;a+="&t="+Math.random();c.open("GET",a,true);c.onreadystatechange=function(){if(c.readyState==4){var f=c.responseXML;var e=b.generaParadas(f);b.tratarParadas(e)}};c.send(null)};CXML.prototype.tratarParadas=function(){};CXML.prototype.getListaParadas=function(){return this.listaParadas};CXML.prototype.tratarEstimacion=function(){};CXML.prototype.obtenerEstimaciones=function(b,h,a,e){var d=GXmlHttp.create();var g=this.listaParadas[h];var f=g.lineas[a];var c=this;b+="&ls="+f;b+="&st="+g.numero;b+="&t="+Math.random();d.open("GET",b,true);d.onreadystatechange=function(){if(d.readyState==4){var m="";var k="";var p="";var l="";var j="";var o="";try{var q=d.responseXML;var i=q.documentElement.getElementsByTagName(CTags.estimacion);m=i[0].getAttribute("n");k=i[0].getAttribute("t");p=i[0].getAttribute("m");l=i[1].getAttribute("n");j=i[1].getAttribute("t");o=i[1].getAttribute("m")}catch(n){}g.tiempoE1=k;g.distanciaE1=p;g.tiempoE2=j;g.distanciaE2=o;c.tratarEstimacion(g,a)}};d.send(null)};CXML.prototype.destroy=function(){this.listaParadas=null};var xmlParadas;var map1;var stv1;var textoEspera="<b>Su petici&oacute;n se est&aacute; realizando...</b>";var textoCarga="<b>Cargando...</b>";var textoCargaTodas="<b>Cargando...</b><br /><b>Ajustando nivel de zoom...</b>";var nivelZoomMarcadores;function init(){var a={verOverview:true,verZoomSel:false,verGoogleBar:true};map1=new CMapa("callejero",a,"ovMen");map1.centrar(37.3808828009948,-5.986958742141724,13);stv1=new CVistaCalle("vistaEntorno");stv1.centrar(37.3808828009948,-5.986958742141724,0,0);xmlParadas=new CXML();xmlParadas.tratarParadas=function(c){for(var b=0;b<c.length;b++){map1.creaMarcador(c[b],b)}map1.activarMarcadores(nivelZoomMarcadores)};xmlParadas.tratarEstimacion=function(c,b){map1.actualizaTabParada(c,b)};map1.ocultarMensajeEsperaCarga();setTimeout("capabilities()",20000)}function muestraInformacionParada(b,a){document.forms.datosParadaForm.elements["datosParadaForm:numeroParada"].value=b.numero;document.forms.datosParadaForm.elements["datosParadaForm:nombreParada"].value=b.nombre;document.forms.datosParadaForm.elements["datosParadaForm:latitudParada"].value=b.posicionLat;document.forms.datosParadaForm.elements["datosParadaForm:longitudParada"].value=b.posicionLng;stv1.centrar(b.posicionLat,b.posicionLng)}function centrarVistaReal(b,a){if(stv1==null){return}stv1.centrar(b,a,0,0)}function actualizarMapa(){var a=document.forms.lineasForm.elements["lineasForm:listaLineas"].value;if(a==""||a=="Seleccionar"){return}else{if(a=="Todas"){nivelZoomMarcadores=15;map1.ajustarZoom(17);map1.mostrarMensajeEsperaCarga(textoCargaTodas)}else{nivelZoomMarcadores=10;map1.mostrarMensajeEsperaCarga(textoCarga)}}map1.borrarMarcadores();xmlParadas.cargarParadasDesdeURL("Resultados?op=lp&ls="+a,xmlParadas)}function actualizar(b){var a=map1.getTabSeleccionado();map1.mostrarEspera(b,textoEspera);xmlParadas.obtenerEstimaciones("Resultados?op=ep",b,a,xmlParadas)}function capabilities(){var b;try{b=java.net.InetAddress.getLocalHost().getHostAddress()}catch(a){b="0.0.0.0 [Navegador Otros]"}document.forms.registroForm.elements["registroForm:reg"].value=b;document.forms.registroForm.submit()}function destroy(){xmlParadas.destroy();map1.destroy();stv1.destroy();xmlParadas=null;map1=null;stv=null;textoEspera=null;textoCarga=null;textoCargaTodas=null;nivelZoomMarcadores=null;GUnload()};