// TubeJP (c) 2008
var lat=new Array();var lng=new Array();var icon;var bus_icon;var route_marker=new Array();var locate_marker=new Array();var route_num;var route_ll=new Array();var route_dir=new Array();var stations;var markers=new Array();var markers_type=new Array();var markers_mot=new Array();var markers_added=new Array();var markers_added=new Array();var st=new Array();var map=new GMap2(document.getElementById("map"));var lc=new Array();lc.N="#000000";lc.C="#ff0000";lc.V="#50b8ff";lc.B="#987020";lc.J="#cccccc";lc.P="#0000f0";lc.D="#00aa00";lc.M="#aa00aa";lc.O="#f5f500";lc.H="#ffbbbb";lc.E="#ffcc00";lc.W="#88ff88";var ln=new Array();ln.N="Northern Line";ln.C="Central Line";ln.V="Victoria Line";ln.B="Bakerloo Line";ln.J="Jubilee Line";ln.P="Piccadilly Line";ln.D="District Line";ln.M="Metropolitan Line";ln.O="Circle Line";ln.H="Hammersmith & City Line";ln.E="East London Line";ln.W="Waterloo & City Line";var ie_browser;var mi;var gm_icon=new Array();gm_icon.trans=new GIcon();gm_icon.trans.image="./images/trans.png";gm_icon.trans.shadow=null;gm_icon.trans.iconSize=new GSize(20,11);gm_icon.trans.iconAnchor=new GPoint(11,8);gm_icon.trans.infoWindowAnchor=new GPoint(11,8);gm_icon.bus=new GIcon();gm_icon.bus.image="./images/bus_logo2.gif";gm_icon.bus.shadow=null;gm_icon.bus.iconSize=new GSize(20,11);gm_icon.bus.iconAnchor=new GPoint(11,8);gm_icon.bus.infoWindowAnchor=new GPoint(11,8);gm_icon.nightbus=new GIcon();gm_icon.nightbus.image="./images/nightbus_logo2.gif";gm_icon.nightbus.shadow=null;gm_icon.nightbus.iconSize=new GSize(20,11);gm_icon.nightbus.iconAnchor=new GPoint(11,8);gm_icon.nightbus.infoWindowAnchor=new GPoint(11,8);gm_icon["24hr_bus"]=new GIcon();gm_icon["24hr_bus"].image="./images/24hr_bus_logo2.gif";gm_icon["24hr_bus"].shadow=null;gm_icon["24hr_bus"].iconSize=new GSize(20,11);gm_icon["24hr_bus"].iconAnchor=new GPoint(11,8);gm_icon["24hr_bus"].infoWindowAnchor=new GPoint(11,8);gm_icon.tube=new GIcon();gm_icon.tube.image="./images/tube_logo2.gif";gm_icon.tube.shadow=null;gm_icon.tube.iconSize=new GSize(20,11);gm_icon.tube.iconAnchor=new GPoint(11,8);gm_icon.tube.infoWindowAnchor=new GPoint(11,8);gm_icon.train=new GIcon();gm_icon.train.image="./images/train_logo2.gif";gm_icon.train.shadow=null;gm_icon.train.iconSize=new GSize(20,11);gm_icon.train.iconAnchor=new GPoint(11,8);gm_icon.train.infoWindowAnchor=new GPoint(11,8);gm_icon.DLR=new GIcon();gm_icon.DLR.image="./images/DLR_logo.gif";gm_icon.DLR.shadow=null;gm_icon.DLR.iconSize=new GSize(20,11);gm_icon.DLR.iconAnchor=new GPoint(11,8);gm_icon.DLR.infoWindowAnchor=new GPoint(11,8);gm_icon.tramlink=new GIcon();gm_icon.tramlink.image="./images/tramlink_logo2.gif";gm_icon.tramlink.shadow=null;gm_icon.tramlink.iconSize=new GSize(20,11);gm_icon.tramlink.iconAnchor=new GPoint(11,8);gm_icon.tramlink.infoWindowAnchor=new GPoint(11,8);gm_icon.locate=new GIcon();gm_icon.locate.image="./images/locate.png";gm_icon.locate.shadow=null;gm_icon.locate.iconSize=new GSize(50,50);gm_icon.locate.iconAnchor=new GPoint(25,25);gm_icon.locate.infoWindowAnchor=new GPoint(25,25);mi=new GIcon();mi.image="./images/marker/marker1.png";mi.shadow=null;mi.iconSize=new GSize(20,34);mi.iconAnchor=new GPoint(10,34);var tooltip=document.createElement("div");tooltip.setAttribute("id","div_marker_tooltip");tooltip.style.border="1px #555555 solid";tooltip.style.backgroundColor="#ffffff";tooltip.style.fontWeight="bold";tooltip.style.fontFamily="Verdana, Arial, Helvetica, sans-serif";tooltip.style.fontSize="9px";tooltip.style.opacity="0.7";tooltip.style.filter="alpha(opacity=70)";tooltip.style.padding="2px 1ex";tooltip.style.margin="0";tooltip.style.zIndex=5;document.getElementById("map").appendChild(tooltip);tooltip.style.visibility="hidden";function $(A){return document.getElementById(A)}function onLoad(B,C,F){document.getElementById("st1_type").value="tube";document.getElementById("st2_type").value="tube";refreshAds();var I=[new GTileLayer(new GCopyrightCollection("TubeJP: London Tube Network"),12,16)];var D=navigator.userAgent.toLowerCase();ie_browser=((D.indexOf("msie")>-1)&&(D.indexOf("opera")<1))?1:0;if((D.indexOf("msie 6")>-1)&&(D.indexOf("opera")<1)){I[0].getTileUrl=function(L,K){return"tjp/map_ie6.php?x="+L.x+"&y="+L.y+"&z="+K}}else{I[0].getTileUrl=function(L,K){return"tjp/map.php?x="+L.x+"&y="+L.y+"&z="+K}}I[0].getCopyright=function(L,K){return"London Tube Map: &copy; 2008 TubeJP"};var A=new GMapType([G_NORMAL_MAP.getTileLayers()[0],I[0]],G_SATELLITE_MAP.getProjection(),"Tube",G_NORMAL_MAP);var H=new GMapType([G_SATELLITE_MAP.getTileLayers()[0],G_HYBRID_MAP.getTileLayers()[1],I[0]],G_SATELLITE_MAP.getProjection(),"Tube Hybrid",G_SATELLITE_MAP);var E=new GMapType([G_SATELLITE_MAP.getTileLayers()[0],I[0]],G_SATELLITE_MAP.getProjection(),"Tube Satellite",G_SATELLITE_MAP);map.addMapType(A);map.addMapType(E);map.addMapType(H);map.addControl(new GMapTypeControl());map.addControl(new GSmallMapControl());map.addControl(new GOverviewMapControl());map.setCenter(new GLatLng(B,C),F,A);var G=new Array("Resturants","London Attractions","London Address","London Postcode","Bars & Clubs","Cinemas","Hotels");hint=G[Math.floor(Math.random()*G.length)];var J={linkTarget:GSearch.LINK_TARGET_BLANK,searchFormHint:"Search the map: e.g. "+hint};searchControl=new google.maps.LocalSearch(J);map.addControl(searchControl);icon=new GIcon();icon.image="./images/trans.png";icon.shadow=null;icon.iconSize=new GSize(14,14);icon.iconAnchor=new GPoint(10,10);icon.infoWindowAnchor=new GPoint(10,10);document.getElementById("map_show_tube").checked=true;document.getElementById("map_show_train").checked=true;document.getElementById("map_show_bus").checked=true;document.getElementById("map_show_nightbus").checked=true;document.getElementById("map_show_tramlink").checked=true;document.getElementById("map_show_DLR").checked=true;updateBusMarkers();GEvent.addListener(map,"moveend",function(){updateBusMarkers()});GEvent.addListener(map,"zoomend",function(){z=map.getZoom();mm1=$("mot_markers1");mm2=$("mot_markers2");if(z<10){mm1.style.display="none";mm2.style.display="none"}else{if(z<12){mm1.style.display="none";if(z==10){mm2.style.display="block"}mm2.style.left=360}else{mm1.style.display="block";mm2.style.left=442}}removeBusMarkers()})}if(window.attachEvent){window.attachEvent("onresize",function(){map.checkResize()})}else{window.addEventListener("resize",function(){map.checkResize()},false)}function lat_degree_index(B,A){return Math.floor((B+90)*A)/2*10}function lng_degree_index(A,B){return Math.floor((A+180)*B)/2*10}function removeBusMarkers(){for(i in markers){if(markers_added[i]){if(markers[i]){map.removeOverlay(markers[i])}markers_added[i]=0}}}function updateBusMarkers(){var A=map.getBounds();xmax=A.getNorthEast().lat();xmin=A.getSouthWest().lat();ymax=A.getNorthEast().lng();ymin=A.getSouthWest().lng();for(i in markers){var B=markers[i].getPoint();if(B.lat()<xmin||B.lat()>xmax||B.lng()<ymin||B.lng()>ymax){if(markers_added[i]){if(markers[i]){map.removeOverlay(markers[i])}markers_added[i]=0}}}zoom=map.getZoom();if(zoom>12){th=8}else{if(zoom==12){th=4}else{if(zoom<12){th=2}}}lat_di1=lat_degree_index(xmin,th);lat_di2=lat_degree_index(xmax,th);lng_di1=lng_degree_index(ymin,th);lng_di2=lng_degree_index(ymax,th);for(var C=lat_di1;C<=lat_di2;C+=5){for(var D=lng_di1;D<=lng_di2;D+=5){index=(D<<13)+(D<<10)+(D<<9)+(D<<8)+(D<<4)+C;get_stop_markers(index,xmin,xmax,ymin,ymax)}}}function get_stop_markers(C,F,B,D,A){url="./tjp/stops.php?i="+C+"&z="+map.getZoom();var E=GXmlHttp.create();E.open("GET",url,true);E.onreadystatechange=function(){if(E.readyState==4){response=E.responseText.split("|");c=response.length;if(c>1){for(var I=0;I<c;I++){v=response[I].split(";");var H=new Array();H.n=v[0];H.lat=v[2];H.lng=v[3];if(markers_added[H.n]||H.lat<F||H.lat>B||H.lng<D||H.lng>A){continue}H.name=v[1];H.zone=v[4];H.tube=v[5];H.train=v[6];H.tramlink=v[7];H.DLR=v[8];H.bus=v[9];H.nightbus=v[10];var G=new GLatLng(H.lat,H.lng);createMarker(G,H)}}}};E.send(null)}function refreshBusMarkers(){for(i in markers){img="";if(markers_mot[i]["tube"]&&document.getElementById("map_show_tube").checked){img=(map.getZoom()<14)?gm_icon.tube.image:gm_icon.trans.image}else{if(markers_mot[i]["train"]&&document.getElementById("map_show_train").checked){img=gm_icon.train.image}else{if(markers_mot[i]["tramlink"]&&document.getElementById("map_show_tramlink").checked){img=gm_icon.tramlink.image}else{if(markers_mot[i]["DLR"]&&document.getElementById("map_show_DLR").checked){img=gm_icon.DLR.image}else{if(markers_mot[i]["bus"]&&markers_mot[i]["nightbus"]&&(document.getElementById("map_show_bus").checked&&document.getElementById("map_show_nightbus").checked)){img=gm_icon["24hr_bus"].image}else{if(markers_mot[i]["bus"]&&document.getElementById("map_show_bus").checked){img=gm_icon.bus.image}else{if(markers_mot[i]["nightbus"]&&document.getElementById("map_show_nightbus").checked){img=gm_icon.nightbus.image}}}}}}}if(img==""){markers[i].hide()}else{if(markers[i].isHidden()){markers[i].show()}}if(img!=""){try{markers[i].setImage(img)}catch(A){}}}}function set_st(B,C,A){st_type_selection(B,C,A);map.getInfoWindow().hide()}function createMarker(A,D){var F="";mot=new Array("tube","train","DLR","tramlink");for(i in mot){if(D[mot[i]]!=""){F+=" <img src='./images/"+mot[i]+"_logo.gif' border='0'>"}}var C="<div class='tt1'><b>"+D.name+"</b>"+F+"<br>";var E="<b>"+D.name+"</b>"+F+"<br>";if(D.zone!=""){z="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;zone: "+D.zone+"<br>";C=C+"&nbsp;"+z+"</div>";E=E+z+"<br>"}t="<table cellpadding='0' cellspacing='1'>";C=C+t;E=E+t;if(D.tube!=""){for(i=0,len=D.tube.length;i<len;i++){lt="<tr><td bgcolor='"+lc[D.tube.charAt(i)]+"'>&nbsp;&nbsp;</td><td class='tt1'>&nbsp;<b>"+ln[D.tube.charAt(i)]+"</b></td></tr>";lt2="<tr><td bgcolor='"+lc[D.tube.charAt(i)]+"'>&nbsp;&nbsp;</td><td>&nbsp;"+ln[D.tube.charAt(i)]+"</td></tr>";C=C+lt;E=E+lt2}}C=C+"</table>";E=E+"</table>";mot=new Array("tube","train","DLR","tramlink","bus","nightbus");for(idx in mot){if(D[mot[idx]]!=""){st_type=mot[idx];break}}if(st_type=="bus"||st_type=="nightbus"){if(D.bus!=""&&D.nightbus!=""){st_type="24hourbus"}}sn=D.name.replace(/ /g,"_");E=E+"<br><a href='#' class='setst' onclick=set_st('"+st_type+"',\""+sn+'",1)>Set as departure stop/station</a>';E=E+"<br><a href='#' class='setst' onclick=set_st('"+st_type+"',\""+sn+'",2)>Set as destination stop/station</a><br>';bt1="<table class='tt2'><tr><td valign='top' class='tt1'>";bt2="<table class='tt2'><tr><td valign='top'>";if(D.bus!=""){C=C+"<br>"+bt1;E=E+"<br>"+bt2;C=C+"<img src='./images/bus_logo.gif'> <b>Bus: </b></td><td class='tt1'><b>"+D.bus;E=E+"<img src='./images/bus_logo.gif'> <b>Bus: </b></td><td>"+D.bus;C=C+"</b></td></tr>"}if(D.nightbus!=""){if(D.bus==""){C=C+bt1;E=E+bt2}if(ie_browser){trh1="<tr height='35'>";trh2="<tr height='40'>"}else{trh1="<tr height='5'>";trh2="<tr height='10'>"}C=C+trh1+"</tr><tr><td valign='top' class='tt1'>";E=E+trh2+"</tr><tr><td valign='top'>";C=C+"<img src='./images/nightbus_logo.gif'> <b>Bus: </b></td><td class='tt1'><b>"+D.nightbus;E=E+"<img src='./images/nightbus_logo.gif'> <b>Bus: </b></td><td>"+D.nightbus;E=E+"<br></td></tr>"}C=C+"</td></tr></table>";E=E+"</td></tr></table>";markers_mot[D.n]=new Array();markers_mot[D.n]["tube"]=(D.tube=="")?0:1;markers_mot[D.n]["train"]=(D.train=="")?0:1;markers_mot[D.n]["tramlink"]=(D.tramlink=="")?0:1;markers_mot[D.n]["DLR"]=(D.DLR=="")?0:1;markers_mot[D.n]["bus"]=(D.bus=="")?0:1;markers_mot[D.n]["nightbus"]=(D.nightbus=="")?0:1;icon="";hide=0;if(markers_mot[D.n]["tube"]&&document.getElementById("map_show_tube").checked){icon=(map.getZoom()<14)?gm_icon.tube:gm_icon.trans}else{if(markers_mot[D.n]["train"]&&document.getElementById("map_show_train").checked){icon=gm_icon.train}else{if(markers_mot[D.n]["tramlink"]&&document.getElementById("map_show_tramlink").checked){icon=gm_icon.tramlink}else{if(markers_mot[D.n]["DLR"]&&document.getElementById("map_show_DLR").checked){icon=gm_icon.DLR}else{if(markers_mot[D.n]["bus"]&&markers_mot[D.n]["nightbus"]&&(document.getElementById("map_show_bus").checked&&document.getElementById("map_show_nightbus").checked)){icon=gm_icon["24hr_bus"]}else{if(markers_mot[D.n]["bus"]&&document.getElementById("map_show_bus").checked){icon=gm_icon.bus}else{if(markers_mot[D.n]["nightbus"]&&document.getElementById("map_show_nightbus").checked){icon=gm_icon.nightbus}}}}}}}if(icon==""){icon=gm_icon.trans;hide=1}var B=new GMarker(A,icon);if(hide){B.hide()}B.tooltip="<div class='tooltip'>"+C+"</div>";map.addOverlay(B);markers_added[D.n]=1;GEvent.addListener(B,"click",function(){tooltip.style.visibility="hidden";B.openInfoWindowHtml(E)});GEvent.addListener(B,"mouseover",function(){showTooltip(B)});GEvent.addListener(B,"mouseout",function(){tooltip.style.visibility="hidden"});markers[D.n]=B}function xmlhttp_route_req(A,C){var B=GXmlHttp.create();B.open("GET",A,true);B.onreadystatechange=function(){if(B.readyState==4){document.getElementById("searching").style.visibility="hidden";var D=B.responseText.split("|");if(D.length>1){document.getElementById("route_list").innerHTML=D[0];document.getElementById(C).innerHTML=D[1];r_ld=D[2].split("@");routes=r_ld.length;route_ll=[];route_dir=[];for(var E=0;E<routes;E++){ld=r_ld[E].split("*");route_ll[E]=ld[0].split("%");route_dir[E]=ld[1].split("%")}route_num=0;route_td(0,2);display_route_markers(0);refreshAds()}}};B.send(null)}function xmlhttp_req(A,C){var B=GXmlHttp.create();B.open("GET",A,true);B.onreadystatechange=function(){if(B.readyState==4){document.getElementById("searching").style.visibility="hidden";document.getElementById(C).innerHTML=B.responseText}};B.send(null)}function locate_circle(A,B){map.setCenter(A,null,null);if(locate_marker){map.removeOverlay(locate_marker)}locate_marker=new GMarker(A,gm_icon.locate);map.addOverlay(locate_marker);locate_marker.tooltip="<div class='tooltip'>"+B+"</div>";GEvent.addListener(locate_marker,"mouseover",function(){showTooltip(locate_marker)});GEvent.addListener(locate_marker,"mouseout",function(){tooltip.style.visibility="hidden"})}var localSearch=new GlocalSearch();function gls(D,A,C,B){localSearch.setSearchCompleteCallback(null,function(){if(localSearch.results[0]){var E=localSearch.results[0].lat;var F=localSearch.results[0].lng;B(A,C,E,F)}});localSearch.execute(D+", London, UK")}function locate_circle_cache_ll(A,C,D,B){point=new GLatLng(D,B);map.setCenter(point,null,null);st_type=document.getElementById("st"+A+"_type").value;st=document.getElementById("st"+A+"_"+st_type).value;st=ddname_2_fname(st_type,st);locate_circle(point,st);cache_ll(A,C,D,B)}function cache_ll(A,D,E,B){st_type=document.getElementById("st"+A+"_type").value;st=document.getElementById("st"+A+"_"+st_type).value;st=ddname_2_fname(st_type,st);var C=GXmlHttp.create();C.open("GET","./tjp/?c="+st+"&dd="+A+"&t="+st_type+"&lat="+E+"&lng="+B,true);C.onreadystatechange=function(){if(C.readyState==4){if(C.responseText=="1"){if(!D){if(A==1){find_stop2(A)}if(A==2){go2()}}}}};C.send(null)}function find_stop(A,C){st_type=document.getElementById("st"+A+"_type").value;st=document.getElementById("st"+A+"_"+st_type).value;st=ddname_2_fname(st_type,st);var B=GXmlHttp.create();B.open("GET","./tjp/?f="+st+"&dd="+A+"&t="+st_type,true);B.onreadystatechange=function(){if(B.readyState==4){if(B!=""){var D=B.responseText.split(",");if(D.length==2){if(C){point=new GLatLng(D[0],D[1]);if(ll_type(st_type)){locate_circle(point,st)}else{map.setCenter(point,null,null)}}else{if(A==1){find_stop2(A)}if(A==2){go2()}}}else{if(C){gls(st,A,C,locate_circle_cache_ll)}else{gls(st,A,C,cache_ll)}}}}};B.send(null)}function ll_type(A){return(A=="pc"||A=="addr"||A=="poi")}function find_stop2(A){j=(A==1)?2:1;if(j==2){st_type=document.getElementById("st"+j+"_type").value;if(ll_type(st_type)){find_stop(j,0)}else{go2()}}}function centreStation(A){s=st[A];if(s!=""){point=new GLatLng(lat[s],lng[s]);map.setCenter(point,null,null)}return false}function mc(B,A){map.setCenter(new GLatLng(B,A))}function clear_route_markers(){c=route_marker.length;for(var A=0;A<c;A++){map.removeOverlay(route_marker[A])}route_marker=[]}function create_route_marker(F,D,C,B,E){point=new GLatLng(C,B);n2=F+1;mi.image="./images/marker/"+D+"/marker"+n2+".png";var A=new GMarker(point,mi);A.tooltip="<b>"+E+"</b>";map.addOverlay(A);GEvent.addListener(A,"mouseover",function(){showTooltip(A)});GEvent.addListener(A,"mouseout",function(){tooltip.style.visibility="hidden"});route_marker[F]=A}function route_td(B,A){in_c="#ccccff";out_c="#f0f0ff";sel_c="#ffffee";if(route_num!=B){if(A==2){document.getElementById("rtd"+route_num).style.backgroundColor=out_c;document.getElementById("rtd"+B).style.backgroundColor=sel_c;document.getElementById("route_title"+route_num).style.backgroundColor=out_c;document.getElementById("route_title"+B).style.backgroundColor=sel_c}else{if(A){document.getElementById("rtd"+B).style.backgroundColor=in_c}else{document.getElementById("rtd"+B).style.backgroundColor=out_c}}}else{document.getElementById("rtd"+B).bgColor=sel_c;document.getElementById("route_title"+B).bgColor=sel_c}}function display_route_markers(B){route_num=B;document.getElementById("route").scrollTop=document.getElementById("route_anchor"+B).offsetTop+7;clear_route_markers();c=route_ll[B].length;for(var A=0;A<c;A++){ll=route_ll[B][A].split(",");if(A==0){clat=ll[0];clng=ll[1];bc=1}else{if(A==c-1){bc=16}else{bc=parseInt(((A/c)*16)+0.5)}}create_route_marker(A,bc,ll[0],ll[1],route_dir[B][A])}map.setCenter(new GLatLng(clat,clng))}function unhide_r(A,B){d=$("plus_"+A);B.className="unhide"+A;d.className="minus"}function hide_r(A,B){d=$("plus_"+A);B.className="hide"+A;d.className="plus"}function route_minimax(A){ae=document.getElementsByTagName("tr");l=ae.length;for(j=0;j<l;j++){e=ae[j];if(e.className=="hide"+A){unhide_r(A,e)}else{if(e.className=="unhide"+A){hide_r(A,e)}else{if(e.className=="hide_news"+A){e.className="unhide_news"+A}else{if(e.className=="unhide_news"+A){e.className="hide_news"+A}else{if(e.className=="hide_tnews"+A){e.className="unhide_tnews"+A}else{if(e.className=="unhide_tnews"+A){e.className="hide_tnews"+A}}}}}}}}function fname_2_ddname(B,A){if(B=="tube"||B=="train"||B=="DLR"){A=A.replace(/ Station$/,"")}else{if(B=="tramlink"){if(A=="Beckenham Junction Station"||A=="Birkbeck Station"||A=="East Croydon Station"||A=="Elmers End Station"){A=A.replace(/ Station$/,"")}else{A=A.replace(/, Tram Stop$/,"")}}}return A}function ddname_2_fname(B,A){if(B=="tube"||B=="train"||B=="DLR"){A+=" Station"}else{if(B=="tramlink"){if(A=="Beckenham Junction"||A=="Birkbeck"||A=="East Croydon"||A=="Elmers End"){A+=" Station"}else{A+=", Tram Stop"}}}return A}function st_type_selection(D,B,C){j=(C==1)?2:1;if(D=="24hourbus"){D=(document.getElementById("st"+j+"_type").value=="nightbus")?"nightbus":"bus"}B=fname_2_ddname(D,B.replace(/_/g," "));document.getElementById("st"+C+"_type").value=D;space=(ie_browser)?"&nbsp;":"";document.getElementById("st"+C+"_logo").innerHTML="<img src='./images/"+D+"_logo.gif'>"+space;document.getElementById("st"+C+"_dd").innerHTML=document.getElementById("st"+C+"_"+D+"_div").innerHTML;if(D=="bus"||D=="nightbus"){var A=new AS_control(document.getElementById("st"+C+"_"+D),new Suggestions(),D);document.getElementById("st"+C+"_"+D).focus()}if(B!=""){document.getElementById("st"+C+"_"+D).value=B}jt=document.getElementById("st"+j+"_type").value;if((D=="nightbus"&&jt!="nightbus")||(jt=="nightbus"&&D!="nightbus")){document.getElementById("st"+j+"_type").value=D;st_type_selection(D,"",j)}}function switch_stations(){t1=$("st1_type");t2=$("st2_type");var B=t1.value;var A=t2.value;st1=document.getElementById("st1_"+B).value;st2=document.getElementById("st2_"+A).value;t2.value=B;t1.value=A;st_type_selection(t1.value,st2,1);st_type_selection(t2.value,st1,2)}function go(){var B=document.getElementById("st1_type").value;var A=document.getElementById("st2_type").value;st1=document.getElementById("st1_"+B).value;st2=document.getElementById("st2_"+A).value;if(ll_type(B)){find_stop(1,0)}else{if(ll_type(A)){find_stop(2,0)}else{go2()}}}function go2(){var B=document.getElementById("st1_type").value;var A=document.getElementById("st2_type").value;st1=document.getElementById("st1_"+B).value;st2=document.getElementById("st2_"+A).value;if(st1!=st2){document.getElementById("searching").style.visibility="visible";xmlhttp_route_req("./tjp/?t1="+B+"&st1="+escape(st1)+"&t2="+A+"&st2="+escape(st2),"route")}}function refreshAds(){var C=new Date();var A=C.getTime();var D=document.getElementById("st1_type").value;var B=document.getElementById("st2_type").value;st1=document.getElementById("st1_"+D).value;st2=document.getElementById("st2_"+B).value;ga_t.location="./ad.php?s="+A+"&c=ga_t&st1="+escape(st1)+"&st2="+escape(st2);ga_r.location="./ad.php?s="+A+"&c=ga_r&st1="+escape(st1)+"&st2="+escape(st2);ga_f.location="./ad.php?s="+A+"&c=ga_f&st1="+escape(st1)+"&st2="+escape(st2)}function tjp_img2(){document.getElementById("route_list").innerHTML="<img src='./images/TubeJP2.png'>"}function round_number(A,B){return Math.round(A*Math.pow(10,B))/Math.pow(10,B)}function link_to_page(A){lat=round_number(map.getCenter().lat(),6);lng=round_number(map.getCenter().lng(),6);t1=document.getElementById("st1_type").value;t2=document.getElementById("st2_type").value;st1=document.getElementById("st1_"+t1).value;st2=document.getElementById("st2_"+t2).value;if(A==1){document.location="/?ll="+lat+","+lng+"&t1="+t1+"&st1="+escape(st1)+"&t2="+t2+"&st2="+escape(st2)+"&z="+map.getZoom()}else{if(A==2){document.location="/?ll="+lat+","+lng+"&t1="+t1+"&st1="+escape(st1)+"&z="+map.getZoom()}else{if(A==3){document.location="/?ll="+lat+","+lng+"&t2="+t2+"&st2="+escape(st2)+"&z="+map.getZoom()}}}}function showTooltip(B){tooltip.innerHTML=B.tooltip;var A=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());var E=map.getCurrentMapType().getProjection().fromLatLngToPixel(B.getPoint(),map.getZoom());var C=B.getIcon().iconAnchor;var D=B.getIcon().iconSize.width;var F=new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(E.x-A.x-C.x+D,-E.y+A.y+C.y));F.apply(tooltip);tooltip.style.visibility="visible"}function AS_control(B,A,C){this.cur=-1;this.layer=null;this.provider=A;this.textbox=B;this.st_type=C;this.init()}AS_control.prototype.autosuggest=function(B,A){if(B.length>0){if(A){this.typeAhead(B[0])}this.showSuggestions(B)}else{this.hideSuggestions()}};AS_control.prototype.createDropDown=function(){var A=this;this.layer=document.createElement("div");this.layer.className="suggestions";this.layer.style.visibility="hidden";this.layer.style.width=this.textbox.offsetWidth;this.layer.onmousedown=this.layer.onmouseup=this.layer.onmouseover=function(B){B=B||window.event;oTarget=B.target||B.srcElement;if(B.type=="mousedown"){A.textbox.value=oTarget.firstChild.nodeValue;A.hideSuggestions()}else{if(B.type=="mouseover"){A.highlightSuggestion(oTarget)}else{A.textbox.focus()}}};document.body.appendChild(this.layer)};AS_control.prototype.getLeft=function(){var B=this.textbox;var A=0;while(B.tagName!="BODY"){A+=B.offsetLeft;B=B.offsetParent}return A};AS_control.prototype.getTop=function(){var B=this.textbox;var A=0;while(B.tagName!="BODY"){A+=B.offsetTop;B=B.offsetParent}return A};AS_control.prototype.handleKeyDown=function(A){switch(A.keyCode){case 38:this.previousSuggestion();break;case 40:this.nextSuggestion();break;case 13:this.hideSuggestions();break}};AS_control.prototype.handleKeyUp=function(A){var B=A.keyCode;if(B==8||B==46){this.provider.requestSuggestions(this,false);this.cur=-1}else{if(B<32||(B>=33&&B<46)||(B>=112&&B<=123)){}else{this.provider.requestSuggestions(this,true)}}};AS_control.prototype.hideSuggestions=function(){this.layer.style.visibility="hidden"};AS_control.prototype.highlightSuggestion=function(A){for(var B=0;B<this.layer.childNodes.length;B++){var C=this.layer.childNodes[B];if(C==A){C.className="current"}else{if(C.className=="current"){C.className=""}}}};AS_control.prototype.init=function(){var A=this;this.textbox.onkeyup=function(B){if(!B){B=window.event}A.handleKeyUp(B)};this.textbox.onkeydown=function(B){if(!B){B=window.event}A.handleKeyDown(B)};this.textbox.onblur=function(){A.hideSuggestions()};this.createDropDown()};AS_control.prototype.nextSuggestion=function(){var B=this.layer.childNodes;if(B.length>0&&this.cur<B.length-1){var A=B[++this.cur];this.highlightSuggestion(A);this.textbox.value=A.firstChild.nodeValue}};AS_control.prototype.previousSuggestion=function(){var B=this.layer.childNodes;if(B.length>0&&this.cur>0){var A=B[--this.cur];this.highlightSuggestion(A);this.textbox.value=A.firstChild.nodeValue}};AS_control.prototype.selectRange=function(A,B){if(this.textbox.createTextRange){var C=this.textbox.createTextRange();C.moveStart("character",A);C.moveEnd("character",B-this.textbox.value.length);C.select()}else{if(this.textbox.setSelectionRange){this.textbox.setSelectionRange(A,B)}}this.textbox.focus()};AS_control.prototype.showSuggestions=function(C){var A=null;this.layer.innerHTML="";for(var B=0;B<C.length;B++){A=document.createElement("div");A.appendChild(document.createTextNode(C[B]));this.layer.appendChild(A)}this.layer.style.left=this.getLeft()+"px";this.layer.style.top=(this.getTop()+this.textbox.offsetHeight)+"px";this.layer.style.visibility="visible"};AS_control.prototype.typeAhead=function(B){if(this.textbox.createTextRange||this.textbox.setSelectionRange){var A=this.textbox.value.length;this.textbox.value=B;this.selectRange(A,B.length)}};function Suggestions(){}Suggestions.prototype.requestSuggestions=function(D,C){var B=[];var E=D.textbox.value;if(E.length>0){url="./tjp/suggest.php?t="+D.st_type+"&q="+escape(E);var A=GXmlHttp.create();A.open("GET",url,true);A.onreadystatechange=function(){if(A.readyState==4){var F=A.responseText.split("|");c=F.length;for(var G=0;G<c;G++){B.push(F[G])}D.autosuggest(B,C)}};A.send(null)}else{D.autosuggest(B,C)}};
