function Marker(B,A){this.position=new GLatLng(B,A);this.shown=false;this.info_shown=false;this.closeup_shown=false;this.marker=null}function initMarker(A){Marker.prototype.map=A}function createMarker(B){var A=this.upper.position;if(A==null){return }var D=null;if(B){D=createMarkerIcon(B)}else{switch(this.type){case"generic":D=createMarkerIcon(this.addressIcon);break;case"bus":D=createMarkerIcon(this.busIcon);break;case"metro":D=createMarkerIcon(this.metroIcon)}}this.upper.marker=new GMarker(A,{icon:D,title:this.label});var C=this;GEvent.addListener(this.upper.marker,"click",function(){if(C.upper.info_shown){C.upper.marker.closeInfoWindow()}else{C.upper.marker.openInfoWindowHtml(C.toHTML());C.goToStreet()}});GEvent.addListener(this.upper.marker,"infowindowopen",function(){C.upper.info_shown=true});GEvent.addListener(this.upper.marker,"infowindowclose",function(){if(C.upper.closeup_shown){C.upper.marker.openInfoWindowHtml(C.toHTML());C.upper.closeup_shown=false}else{C.upper.info_shown=false}})}function showMarker(){if(!this.upper||!this.upper.marker){return }if(!this.upper.shown){this.upper.map.addOverlay(this.upper.marker);this.upper.shown=true}}function hideMarker(){if(!this.upper||!this.upper.marker){return }if(this.upper.shown){this.upper.map.removeOverlay(this.upper.marker);this.upper.shown=false}if(this.upper.info_shown){this.upper.map.closeInfoWindow();this.upper.info_shown=false}}function zoom(A){if(!this.upper||!this.upper.marker){return }this.upper.marker.showMapBlowup({zoomLevel:A});this.upper.closeup_shown=true}function openInfoWindow(){if(!this.upper||!this.upper.marker){return }this.upper.marker.openInfoWindowHtml(this.toHTML());this.upper.info_shown=true}function goToMarker(){if(!this.upper||!this.upper.marker){return }var A=this.upper.position;this.upper.map.panTo(A);this.show();this.upper.marker.openInfoWindowHtml(this.toHTML())}function toggleMarker(){if(!this.upper||!this.upper.marker){return }if(this.upper.shown){this.show()}else{this.hide()}}function createMarkerIcon(A){var B=new GIcon();B.image=A.image;B.shadow=A.shadow;B.iconSize=new GSize(A.iw,A.ih);B.shadowSize=new GSize(A.sw,A.sh);B.iconAnchor=new GPoint(A.ax,A.ay);B.infoWindowAnchor=new GPoint(A.ix,A.iy);return B}var helpDialog,feedbackDialog,statusPanel;function initHelpDialog(){helpDialog=new YAHOO.widget.SimpleDialog("help",{width:"800px",fixedcenter:true,constraintoviewport:false,icon:YAHOO.widget.SimpleDialog.ICON_TIP,close:true,visible:false,modal:false,buttons:[{text:"OK",handler:handleCancel,isDefault:true}],draggable:true});helpDialog.render()}function initDialogs(A){var B,C;if(A=="fr"){B="Annuler";C="Formulaire de contact"}else{B="Cancel";C="Contact form"}feedbackDialog=new YAHOO.widget.Dialog("feedback_dialog",{width:"300px",visible:false,fixedcenter:true,modal:false,postmethod:"async",buttons:[{text:"Ok",handler:handleSubmit,isDefault:true},{text:B,handler:handleCancel}]});feedbackDialog.callback.success=FeedbackSuccess;feedbackDialog.callback.failure=onFailure;feedbackDialog.callback.argument=A;feedbackDialog.validate=validateFeedback;feedbackDialog.lng=A;feedbackDialog.setHeader(C);feedbackDialog.render();statusPanel=new YAHOO.widget.SimpleDialog("status_panel",{width:"300px",icon:YAHOO.widget.SimpleDialog.ICON_HELP,fixedcenter:true,constraintoviewport:false,visible:false,modal:false,buttons:[{text:"OK",handler:handleCancel,isDefault:true}]});statusPanel.render()}var FeedbackSuccess=function(B){var A;if(B.argument=="fr"){A="Merci, votre message a été envoyé avec succès."}else{A="Thank you, your message has been successfully sent."}confirm(A,B.argument)};var onFailure=function(B){var A;if(B.argument=="fr"){A="Erreur de soumission"}else{A="Submission failure"}error(A,B.argument)};var validateFeedback=function(){var A=this.getData();var B,C;if(this.lng=="fr"){B="Veuillez entrer votre message";C="Adresse électronique invalide"}else{B="Please type in your message";C="Please enter a valid email address"}if(A.message==""){error(B,this.lng);return false}if(A.email.search(/\w+@\w+\.\w{2,3}/)!=0){error(C,this.lng);return false}return true};function error(B,A){var C;if(A=="fr"){C="Erreur"}else{C="Error"}statusPanel.setHeader(C);statusPanel.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_WARN);statusPanel.setBody('<div style="color:red;font-weight:bold;">'+B+"!</div>");statusPanel.show()}function confirm(B,A){statusPanel.setHeader("Confirmation");statusPanel.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_INFO);statusPanel.setBody(B);statusPanel.show()}function about(A){var C,B;if(A=="fr"){C="À propos";B="Le planificateur de trajets est un service Web 2.0 qui intégre Tous azimuts, Google maps, google street View et Flickr.<br/><br/>Cité comme <a href='http://googlemapsmania.blogspot.com/2009/10/first-canadian-street-view-mashup.html'>le premier mashup basé sur street view au Canada</a> par Google Maps Mania.<br/><br/>Une application conçue par Skander Kort."}else{C="About";B="Montreal trip planner is a mashup integrating Tous azimuts, Google maps, Google street view and Flickr. Cited as <a href='http://googlemapsmania.blogspot.com/2009/10/first-canadian-street-view-mashup.html'>the first Canadian street view mashup</a> (chronologically speaking) by Google Maps Mania.<br/><br/>Designed By Skander Kort."}statusPanel.setHeader(C);statusPanel.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_INFO);statusPanel.setBody(B);statusPanel.show()}var handleCancel=function(){this.cancel()};var handleSubmit=function(){this.submit()};function initMenus(){var A=new YAHOO.widget.MenuBar("menu_bar",{lazyload:true});A.render();A.show()}function feedback(){feedbackDialog.show()}function help(){helpDialog.show()}YAHOO.util.Event.onContentReady("menu_bar",initMenus);function Stop(B){this.id=null;this.type=null;this.label=null;this.borough=null;this.title=null;this.description=null;this.photos=[];this.upper=null;this.x=null;this.y=null;this.getPhotosCallback={success:Stop.prototype.getPhotosCB,scope:this};if(typeof B!="object"){return }for(var A in B){if(A!="lat"&&A!="lng"){this[A]=B[A]}if(B.lat&&B.lng){this.upper=new Marker(B.lat,B.lng);this.createMarker(B.icon)}}}Stop.prototype.save=function(E){var A={"type":this.type,"label":this.label};if(this.x&&this.y){A.x=this.x;A.y=this.y}var C=this.getLatLng();if(C){A.lat=C.lat();A.lng=C.lng()}if(this.borough){A.borough=this.borough}var B=new Date((new Date()).getTime()+365*24*60*60*1000);try{YAHOO.util.Cookie.setSubs(E,A,{expires:B})}catch(D){}};Stop.prototype.load=function(B){var A=YAHOO.util.Cookie.getSubs(B);if(A){if(A.x){A.x=parseInt(A.x)}if(A.y){A.y=parseInt(A.y)}if(A.lat){A.lat=parseFloat(A.lat)}if(A.lng){A.lng=parseFloat(A.lng)}return new Stop(A)}return null};Stop.prototype.factory=function(D,C){var H=new Object();var A=D.getElementsByTagName("position");if(A.length){H.lat=parseFloat(A[0].getAttribute("lat"));H.lng=parseFloat(A[0].getAttribute("lng"))}var F=D.getElementsByTagName("xy");if(F.length){H.x=parseInt(F[0].getAttribute("x"));H.y=parseInt(F[0].getAttribute("y"))}H.type=D.getElementsByTagName("type")[0].firstChild.nodeValue;var E=D.getElementsByTagName("id");if(E.length){H.id=parseInt(E[0].firstChild.nodeValue,10)}var B=D.getElementsByTagName("label")[0].firstChild.nodeValue;H.label=(H.type=="metro")?((C=="en"?"Metro ":"Métro ")+B):B;var G=D.getElementsByTagName("borough");if(G.length){H.borough=G[0].firstChild.nodeValue}return new Stop(H)};Stop.prototype.getPhotos=function(C){var B=["addr","bus","metro"];var D=C||1;var A="http://busmontreal.com/scripts/action.php?action=get_photos&type="+B[this.type]+"&label="+this.label+"&n="+D;YAHOO.util.Connect.asyncRequest("POST",A,this.getPhotosCallback)};Stop.prototype.getPhotosCB=function(F){var C="";var G=F.responseXML.getElementsByTagName("header")[0];var E=G.getElementsByTagName("count");if(E){var D=parseInt(E[0].firstChild.nodeValue)}if(D){var A=F.responseXML.getElementsByTagName("photo");for(var B=0;B<A.length;B++){this.photos.push(this.parsePhoto(A[B]))}}};Stop.prototype.parsePhoto=function(A){var D=A.getElementsByTagName("title");if(D.length){var B=D[0].firstChild.nodeValue}var C=A.getElementsByTagName("uri")[0].firstChild.nodeValue;return{t:B,u:C}};Stop.prototype.toHTML=function(){var B='<div id="stop_info">';if(this.title){B+=this.title}if(this.label){B+="<br/>"+this.label}if(this.description){B+="<br/>"+this.description}if(this.photos.length){B+='<div id="stop_photo" style="width:160px;height:75px;">';var C=Math.min(this.photos.length,2);for(var A=0;A<C;A++){B+='<img src="'+this.photos[A].u+'" style="border-style:solid;" title="'+this.photos[A].t+'" />&#160;'}B+="</div>"}B+="</div>";return B};Stop.prototype.getLabel=function(){return this.label};Stop.prototype.getBorough=function(){return this.borough};Stop.prototype.setLabel=function(A){this.label=A};Stop.prototype.setTitle=function(A){this.title=A};Stop.prototype.setDescription=function(A){this.description=A};Stop.prototype.setLatLng=function(A){this.upper=new Marker(A.lat(),A.lng());this.createMarker()};Stop.prototype.setPosition=function(A){this.upper=new Marker(A);this.createMarker()};Stop.prototype.geocode=function(E,G,D){if(this.isGeocoded()){return }if(this.type=="metro"){var F=D[this.id].getLatLng();this.setLatLng(F);var A=E.pop();A.stopGeocoded(E)}else{var C=this.label.replace(/\([^)]+\)\s*$/,"")+", "+this.borough+", qc";C=C.replace("/"," and ");var B=this;G.getLatLng(C,function(I){if(I){B.setLatLng(I);var H=E.pop();H.stopGeocoded(E)}})}};Stop.prototype.isGeocoded=function(){if(this.upper){return true}return false};Stop.prototype.getLatLng=function(){if(this.upper){return this.upper.position}return null};Stop.prototype.getX=function(){return this.x};Stop.prototype.getY=function(){return this.y};Stop.prototype.createMarker=createMarker;Stop.prototype.show=showMarker;Stop.prototype.hide=hideMarker;Stop.prototype.toggle=toggleMarker;Stop.prototype.goTo=goToMarker;Stop.prototype.zoom=zoom;Stop.prototype.openInfoWindow=openInfoWindow;Stop.prototype.goToStreet=function(){this.goTo();if(this.streetViewer){this.streetViewer.setLocation(this);this.streetViewer.rotate()}};Stop.prototype.metroIcon={image:"http://busmontreal.com/icones/subway.png",shadow:"http://busmontreal.com/icones/subway.shadow.png",iw:28,ih:28,sw:40,sh:28,ax:6,ay:20,ix:5,iy:1};Stop.prototype.busIcon={image:"http://busmontreal.com/icones/bus.png",shadow:"http://busmontreal.com/icones/bus.shadow.png",iw:32,ih:32,sw:59,sh:32,ax:6,ay:20,ix:5,iy:0};Stop.prototype.addressIcon={image:"http://busmontreal.com/icones/rangerstation.png",shadow:"http://busmontreal.com/icones/rangerstation.shadow.png",iw:32,ih:32,sw:59,sh:32,ax:6,ay:20,ix:10,iy:1};function Line(A){this.label=A.getElementsByTagName("label")[0].firstChild.nodeValue;this.direction=Utilities.getOptionalElement(A,"direction");this.transitCompany=Utilities.getOptionalElement(A,"transitCompany");var B=Utilities.getOptionalElement(A,"fares");this.fares=B?B.split(","):null;var C=parseInt(this.label,10);if(C<=5&&C!=3){this.type="metro"}else{this.type="bus"}}Line.prototype.toString=function(){var A=this.label;if(this.direction!=null){A+=", direction "+this.direction}return A};Line.prototype.toHTML=function(C){var E={"en":"line","fr":"ligne"};var B=["Green","Orange","","Yellow","Blue"];var G=["verte","orange","","jaune","bleue"];var A=["#2FB548","#F29A02","","#E3F238","#3847F2"];var D;if(this.type=="bus"){D="bus "+this.label}else{if(this.type=="metro"){var F=parseInt(this.label,10);D='<span style="color: '+A[F-1]+';">';if(C=="en"){D+=B[F-1]+" "+E[C]}else{D+=E[C]+" "+G[F-1]}D+="</span>"}}if(this.direction!=null){D+=", direction "+this.direction}return D};function Walk(A){this.distance=parseInt(A.getElementsByTagName("distance")[0].firstChild.nodeValue)}function Section(B,A){this.departureTime=B.getElementsByTagName("departureTime")[0].firstChild.nodeValue;this.arrivalTime=B.getElementsByTagName("arrivalTime")[0].firstChild.nodeValue;this.totalTime=Utilities.getOptionalElement(B,"totalTime");this.description=Utilities.getOptionalElement(B,"description");this.departurePoint=Stop.prototype.factory(B.getElementsByTagName("departurePoint")[0].getElementsByTagName("location")[0],A);this.arrivalPoint=Stop.prototype.factory(B.getElementsByTagName("arrivalPoint")[0].getElementsByTagName("location")[0],A);var C=B.getElementsByTagName("line");if(C.length){this.line=new Line(C[0])}else{this.walk=new Walk(B.getElementsByTagName("walk")[0])}}Section.prototype.geocode=function(B,C,A){B.push(this);this.departurePoint.geocode(B,C,A)};Section.prototype.stopGeocoded=function(B){var A=B.pop();A.sectionGeocoded(B)};Section.prototype.isGeocoded=function(){return this.departurePoint.isGeocoded()};Section.prototype.getLine=function(){var A={"en":"walk for ","fr":"marchez sur "};var B={"en":"meters","fr":"m&#233;tres"};return(this.line)?this.line.toHTML(this.lng):A[this.lng]+this.walk.distance+" "+B[this.lng]};Section.prototype.getDescription=function(){return this.description};Section.prototype.getWalkingDistance=function(){return(this.walk)?this.walk.distance:0};Section.prototype.getDeparture=function(){var A={"en":"Departure:","fr":"D&#233;part :"};return A[this.lng]+" "+this.departureTime};Section.prototype.getArrival=function(){var A={"en":"Arrival:","fr":"Arriv&#233;e :"};return A[this.lng]+" "+this.arrivalTime};Section.prototype.getDuration=function(){var A={"en":"Duration:","fr":"Dur&#233;e :"};return A[this.lng]+" "+this.totalTime};Section.prototype.getDeparturePoint=function(){return this.departurePoint};Section.prototype.getArrivalPoint=function(){return this.arrivalPoint};Section.prototype.setDeparturePoint=function(A){if(A){this.departurePoint=A}};Section.prototype.setArrivalPoint=function(A){if(A){this.arrivalPoint=A}};Section.prototype.toHTML=function(G){var I={"en":"Depart from ","fr":"Départ de "};var B={"en":" at ","fr":" à "};var D={"en":". Arrive at ","fr":". Arrivée à "};var F={"en":" around ","fr":" vers "};var H={"en":"walk for ","fr":"marchez sur "};var C={"en":"meters","fr":"mètres"};var A={"en":"line","fr":"ligne"};var E=I[G]+'<span class="stop">'+this.departurePoint.getLabel()+"</span>"+B[G]+this.departureTime+", ";if(this.line){E+=this.line.toHTML(G)}else{E+=H[G]+this.walk.distance+" "+C[G]}E+=D[G]+'<span class="stop">'+this.arrivalPoint.getLabel()+"</span>"+F[G]+this.arrivalTime+".";return E};function Route(C){this.departureTime=C.getElementsByTagName("departureTime")[0].firstChild.nodeValue;this.arrivalTime=C.getElementsByTagName("arrivalTime")[0].firstChild.nodeValue;this.tripTime=C.getElementsByTagName("tripTime")[0].firstChild.nodeValue;this.waitingTime=C.getElementsByTagName("waitingTime")[0].firstChild.nodeValue;this.walkingTime=C.getElementsByTagName("walkingTime")[0].firstChild.nodeValue;this.linesSummary=C.getElementsByTagName("linesSummary")[0].firstChild.nodeValue;this.sections=new Array();this.line=null;var A=C.getElementsByTagName("section");for(var B=0;B<A.length;B++){this.sections.push(new Section(A[B]))}}Route.prototype.getDeparturePoint=function(){return this.sections[0].getDeparturePoint()};Route.prototype.getArrivalPoint=function(){return this.sections[this.sections.length-1].getArrivalPoint()};Route.prototype.setDeparturePoint=function(A){return this.sections[0].setDeparturePoint(A)};Route.prototype.setArrivalPoint=function(A){return this.sections[this.sections.length-1].setArrivalPoint(A)};Route.prototype.getTotalWalkingDistance=function(){var B=0;for(var A=0;A<this.sections.length;B+=this.sections[A].getWalkingDistance(),A++){}return B};Route.prototype.setPositions=function(C){var A=C.getElementsByTagName("stop");for(var B=0;B<A.length;B++){this.stop[B].setPosition(A[B])}};Route.prototype.toHTML=function(E,N,M,L){var D={"en":"Route number","fr":"Trajet num&#233;ro"};var H={"en":"Departure time:","fr":"Heure de d&#233;part :"};var G={"en":"Arrival time:","fr":"Heure d'arriv&#233;e :"};var I={"en":"Trip time:","fr":"Dur&#233;e :"};var C={"en":"Waiting time:","fr":"Temps d'attente : "};var A={"en":"Walking distance:","fr":"Marche à pieds : "};var B={"en":"meters","fr":"mètres"};var F=this.getTotalWalkingDistance();var K='<div class="route_header">'+D[L]+"  "+(E+1)+"</div>";K+="<hr/><em>"+H[L]+" "+this.departureTime+", ";K+=G[L]+" "+this.arrivalTime+"</em><br/>";K+="<em>"+I[L]+" "+this.tripTime+" minutes</em>";if(this.waitingTime&&parseInt(this.waitingTime)>0){K+="<br/><em>"+C[L]+" "+this.waitingTime+" minutes</em>"}if(F>0){K+="<br/><em>"+A[L]+" "+F+" "+B[L]+"</em>"}K+="<hr/><ol>";for(var J=0;J<this.sections.length;J++){K+='<li><div class="section">'+this.sections[J].toHTML(L)+"</div></li>"}K+="</ol>";return K};Route.prototype.show=function(B){if(!this.isGeocoded()){return }var G={"en":"Origin","fr":"Origine"};var E={"en":"next","fr":"suivant"};var A={"en":"previous","fr":"pr&#233;c&#233;dent"};var K=[this.getDeparturePoint().upper.position];var J,C,I,F,L;this.adjustView(B.map);this.getDeparturePoint().setTitle("<center><strong>"+G[this.lng]+"</strong></center>");this.getArrivalPoint().setTitle("<center><strong>Destination</strong></center>");I='<a onclick="'+B.ctrl+".route["+B.index+'].getDeparturePoint().goToStreet();return false;" href="#" onmouseover="return true;">'+G[this.lng]+"</a>";F='<a onclick="'+B.ctrl+'.destination.goToStreet();return false;" href="#" onmouseover="return true;">destination</a>';for(var D=0;D<this.sections.length;D++){var H=this.sections[D].getDeparturePoint();if(D>0){C='<a onclick="'+B.ctrl+".route["+B.index+"].sections["+(D-1)+'].getDeparturePoint().goToStreet();return false;" href="#" onmouseover="return true;">&#171;&#160;'+A[this.lng]+"</a>"}if(D==this.sections.length-1){J='<a onclick="'+B.ctrl+'.destination.goToStreet();return false;" href="#" onmouseover="return true;">'+E[this.lng]+"&#160;&#187;</a>"}else{J='<a onclick="'+B.ctrl+".route["+B.index+"].sections["+(D+1)+'].getDeparturePoint().goToStreet();return false;" href="#" onmouseover="return true;">'+E[this.lng]+"&#160;&#187;</a>"}L='<a onclick="'+B.ctrl+".route["+B.index+"].sections["+D+'].getDeparturePoint().zoom(15);return false;" href="#" onmouseover="return true;"><img src="icones/magnify_icon.gif"/ title="zoom"></a>';if(D>0){H.setDescription(this.sections[D-1].getArrival()+"<br/>"+this.sections[D].getDeparture()+"<br/>"+this.sections[D].getLine()+"<br/>"+C+"&#160;&#160;"+J+"&#160;&#160;"+I+"&#160;&#160;"+F+"<br/>"+L)}else{H.setDescription(this.sections[D].getDeparture()+"<br/>"+this.sections[D].getLine()+"<br/>"+J+"&#160;&#160;"+F+"<br/>"+L)}H.show();K.push(H.getLatLng())}if(this.sections.length){C='<a onclick="'+B.ctrl+".route["+B.index+"].sections["+(this.sections.length-1)+'].getDeparturePoint().goToStreet();return false;" href="#" onmouseover="return true;">&#171;&#160;'+A[this.lng]+"</a>"}else{C='<a onclick="'+B.ctrl+'.origin.goToStreet();return false;" href="#" onmouseover="return true;">&#171;&#160;'+A[this.lng]+"</a>"}L='<a onclick="'+B.ctrl+'.destination.zoom(15);return false;" href="#" onmouseover="return true;"><img src="icones/magnify_icon.gif"/ title="zoom"></a>';B.destination.setDescription(this.sections[this.sections.length-1].getArrival()+"<br/>"+C+"&#160;&#160;"+I+"&#160;&#160;"+L);K.push(B.destination.getLatLng());if(!this.line){this.line=new GPolyline(K,B.color,5)}B.map.addOverlay(this.line);this.getDeparturePoint().goToStreet()};Route.prototype.adjustView=function(B){var J=this.getDeparturePoint();var D=J.upper.position.lat();var E=J.upper.position.lng();var F=D;var I=E;for(var G=1;G<this.sections.length;G++){J=this.sections[G].getDeparturePoint();D=Math.min(D,J.upper.position.lat());F=Math.max(F,J.upper.position.lat());E=Math.min(E,J.upper.position.lng());I=Math.max(I,J.upper.position.lng())}var K=new GLatLng(D,E);var C=new GLatLng(F,I);var H=new GLatLngBounds(K,C);var A=new GLatLng((K.lat()+C.lat())/2,(K.lng()+C.lng())/2);var L=B.getBoundsZoomLevel(H)-1;B.setCenter(A,L)};Route.prototype.hide=function(A){if(!this.isGeocoded()){return }for(var B=0;B<this.sections.length;B++){this.sections[B].getDeparturePoint().hide()}A.removeOverlay(this.line)};Route.prototype.geocode=function(D,E,B){if(this.isGeocoded()){return }D.push(this);for(var C=0;C<this.sections.length;C++){var F=new Array();for(var A=0;A<D.length;F.push(D[A]),A++){}this.sections[C].geocode(F,E,B)}};Route.prototype.sectionGeocoded=function(B){if(this.isGeocoded()){var A=B.pop();A.routeGeocoded(B)}};Route.prototype.isGeocoded=function(){var A=0;while(A<this.sections.length){if(!this.sections[A].isGeocoded()){return false}A++}return true};function Controller(C,A,B){this.myName=C;this.lng=B;this.map=A;this.origin=null;this.destination=null;this.route=new Array();this.currentRoute=null;this.panel=new Panel(B);this.selectedSearchResultIndex=null;this.searchResults=null;this.board={"setLocation":new Array(),"getRoutes":null};this.colors=["#FF0000","#00FF00","#22FFCC","#3423AA","#453227","#230770"];this.metro=new Array();this.geocoder=new GClientGeocoder();Section.prototype.lng=B;Route.prototype.lng=B;this.getMetroCallback={success:Controller.prototype.getMetroCB,failure:Controller.prototype.requestFailure,scope:this};this.searchCallback={success:Controller.prototype.searchCB,failure:Controller.prototype.requestFailure,scope:this};this.getRoutesCallback={success:Controller.prototype.getRoutesCB,failure:Controller.prototype.requestFailure,scope:this};this.geocodeRouteCallback={success:Controller.prototype.geocodeRouteCB,failure:Controller.prototype.requestFailure,scope:this}}Controller.prototype.originIcon={image:"http://busmontreal.com/icones/rangerstation.png",shadow:"http://busmontreal.com/icones/rangerstation.shadow.png",iw:32,ih:32,sw:59,sh:32,ax:6,ay:20,ix:10,iy:1};Controller.prototype.destinationIcon={image:"http://busmontreal.com/icones/flag.png",shadow:"http://busmontreal.com/icones/flag.shadow.png",iw:32,ih:32,sw:59,sh:32,ax:6,ay:20,ix:10,iy:1};Controller.prototype.renderPanels=function(){this.panel.renderParametersForm()};Controller.prototype.getMetro=function(){var A="http://busmontreal.com/front.php?ctrl=location&action=getMetroStations";YAHOO.util.Connect.asyncRequest("POST",A,this.getMetroCallback)};Controller.prototype.swap=function(){};Controller.prototype.loadPreferences=function(){var A;try{A=Stop.prototype.load("origin");if(A){this.setLocation(A,"o");if(A.type=="metro"){YAHOO.util.Dom.setAttribute("origin_type_metro","checked",true);YAHOO.util.Dom.setAttribute("origin_type_address","checked",false)}else{YAHOO.util.Dom.setAttribute("origin_type_metro","checked",false);YAHOO.util.Dom.setAttribute("origin_type_address","checked",true)}}}catch(B){}try{A=Stop.prototype.load("destination");if(A){this.setLocation(A,"d");if(A.type=="metro"){YAHOO.util.Dom.setAttribute("destination_type_metro","checked",true);YAHOO.util.Dom.setAttribute("destination_type_address","checked",false)}else{YAHOO.util.Dom.setAttribute("destination_type_metro","checked",false);YAHOO.util.Dom.setAttribute("destination_type_address","checked",true)}}}catch(B){}};Controller.prototype.setLocation=function(E,B){var A={"en":"Origin","fr":"Origine"};var F=(B=="o")?this.originIcon:this.destinationIcon;var D=E.getLabel().replace(/\([^)]+\)\s*$/,"")+", "+E.getBorough()+", qc";D=D.replace("/"," and ");var C=this;if(B=="o"){this.origin=E;this.origin.setTitle("<center><strong>"+A[this.lng]+"</strong></center>");this.panel.showLocation(B,this.origin.getLabel());if(this.origin.isGeocoded()){this.origin.goToStreet(stViewer)}else{this.geocoder.getLatLng(D,function(G){if(G){C.origin.setLatLng(G);C.origin.goToStreet(stViewer)}})}}else{if(B=="d"){this.destination=E;this.destination.setTitle("<center><strong>Destination</strong></center>");this.panel.showLocation(B,this.destination.getLabel());if(this.destination.isGeocoded()){this.destination.goToStreet(stViewer)}else{this.geocoder.getLatLng(D,function(G){if(G){C.destination.setLatLng(G);C.destination.goToStreet(stViewer)}})}}}E.save((B=="o")?"origin":"destination");if(this.route.length){if(this.currentRoute){this.route[this.currentRoute].hide(this.map)}this.route=new Array();this.refreshPanel(Panel.prototype.SEC_ROUTE,Panel.prototype.OP_EMPTY)}};Controller.prototype.setMetro=function(B,A){B=parseInt(B);if(B<=0){return }this.setLocation(this.metro[B],A)};Controller.prototype.searchStreetIntersection=function(D,C,A){this.selectedSearchResultIndex=null;this.searchResults=null;var B="http://busmontreal.com/front.php?ctrl=location&action=search&lng="+this.lng+"&q="+D+"/"+C;this.searchCallback.argument={"type":"intersection","od":A};YAHOO.util.Connect.asyncRequest("POST",B,this.searchCallback)};Controller.prototype.search=function(C,A){this.selectedSearchResultIndex=null;this.searchResults=null;var B="http://busmontreal.com/front.php?ctrl=location&action=search&lng="+this.lng+"&q="+C;this.searchCallback.argument={"type":"address","od":A};YAHOO.util.Connect.asyncRequest("POST",B,this.searchCallback)};Controller.prototype.changeLocation=function(B){var A={ctrl:this.myName};switch(B){case"o":if(this.origin){this.origin.hide()}if(this.destination){this.destination.setDescription("")}this.origin=null;if(YAHOO.util.Dom.getAttribute("origin_type_metro","checked")=="true"){this.panel.showLocationForm(B,"metro")}else{this.panel.showLocationForm(B,"address")}break;case"d":if(this.destination){this.destination.hide()}if(this.origin){this.origin.setDescription("")}this.destination=null;if(YAHOO.util.Dom.getAttribute("destination_type_metro","checked")=="true"){this.panel.showLocationForm(B,"metro")}else{this.panel.showLocationForm(B,"address")}break;case"od":if(this.origin){this.origin.hide()}if(this.destination){this.destination.setDescription("")}this.origin=null;this.destination=null;this.panel.showLocationForm("o","metro");this.panel.showLocationForm("d","metro")}if(this.route.length){if(this.currentRoute!=null){this.route[this.currentRoute].hide(this.map)}this.route=new Array();this.panel.showParametersForm()}};Controller.prototype.getRoutes=function(I,G,H,B,F,J,L,D,C,E){if(!this.origin||!this.destination){return }this.panel.showFetchingRoutesPanel();I=I.replace(/^\w+, /,"");var K=I.split("/");if(K[0].length==1){K[0]="0"+K[0]}if(K[1].length==1){K[1]="0"+K[1]}I=K[0]+"/"+K[1]+"/"+K[2];var A="http://busmontreal.com/front.php?ctrl=route&action=get&xd="+this.origin.getX()+"&yd="+this.origin.getY()+"&xa="+this.destination.getX()+"&ya="+this.destination.getY()+"&day="+I+"&hour="+G+"&min="+H+"&pwalk="+B+"&ptrans="+F+"&umetro="+J+"&utrain="+L+"&deparr="+D+"&lng="+this.lng;YAHOO.util.Connect.asyncRequest("POST",A,this.getRoutesCallback)};Controller.prototype.geocodeRoute=function(B){return ;var A="http://busmontreal.com/scripts/action.php?action=geocode_route&n="+B+"&sid="+this.id;YAHOO.util.Connect.asyncRequest("POST",A,this.geocodeRouteCallback)};Controller.prototype.geocodeRoutes=function(){for(var A=0;A<this.route.length;A++){this.route[A].geocode([this],this.geocoder,this.metro)}};Controller.prototype.routeGeocoded=function(A){if(this.route[this.currentRoute]&&this.route[this.currentRoute].isGeocoded()){this.route[this.currentRoute].show({ctrl:this.myName,map:this.map,origin:this.origin,destination:this.destination,index:this.currentRoute})}};Controller.prototype.geocodeRouteCB=function(D){var A=D.responseXML.getElementsByTagName("header")[0];var C=this.parseHeader(A);if(C.code=="OK"){var B=D.responseXML.getElementsByTagName("route")[0];this.route[C.routeIndex].setPositions(B);if(this.currentRoute==C.routeIndex){this.route[C.routeIndex].show({ctrl:this.myName,map:this.map,origin:this.origin,destination:this.destination,index:C.routeIndex})}}};Controller.prototype.adjustRoutesEndPoints=function(){if(!this.route){return }for(var A=0;A<this.route.length;A++){if(this.route[A].getDeparturePoint().getLabel()=="Origine"){this.route[A].setDeparturePoint(this.origin)}if(this.route[A].getArrivalPoint().getLabel()=="Destination"){this.route[A].setArrivalPoint(this.destination)}}};Controller.prototype.recompute=function(){if(this.currentRoute!=null){this.route[this.currentRoute].hide(this.map)}this.route=[];this.currentRoute=null;this.panel.showParametersForm()};Controller.prototype.requestFailure=function(B){var A={"en":"Request failure","fr":"Échec de requête"};error(A[this.lng],this.lng)};Controller.prototype.getMetroCB=function(B){var D;var C=this.parseLocations(B.responseXML);for(var A=0;A<C.length;A++){D=C[A].id;delete C[A].id;this.metro[D]=C[A]}};Controller.prototype.searchCB=function(B){var A={"en":"No locations found.","fr":"Aucun résultat."};this.searchResults=this.parseLocations(B.responseXML);if(this.searchResults.length==0){error(A[this.lng],this.lng)}else{if(this.searchResults.length==1){this.setLocation(this.searchResults[0],B.argument.od)}else{this.selectedSearchResultIndex=0;this.panel.showResults(this.searchResults,B.argument.od)}}};Controller.prototype.setLocationCB=function(F){var C={"en":"Failed to set location","fr":"Erreur lors de l'initialisation de l'adresse"};var G=F.responseXML.getElementsByTagName("header")[0];var E=this.parseHeader(G).code;if(E=="OK"){var B=F.responseXML.getElementsByTagName("data")[0];var D=this.parseLocation(B);var A={ctrl:this.myName};if(D==0){A.locLabel=this.origin.getLabel();this.refreshPanel(Panel.prototype.SEC_ORIGIN,Panel.prototype.OP_LOCATION,A);this.origin.goToStreet(stViewer)}else{A.locLabel=this.destination.getLabel();this.refreshPanel(Panel.prototype.SEC_DESTINATION,Panel.prototype.OP_LOCATION,A);this.destination.goToStreet(stViewer)}this.processPending()}else{if(F.od=="o"){this.refreshPanel(Panel.prototype.SEC_ORIGIN,Panel.prototype.OP_METRO,A)}else{this.refreshPanel(Panel.prototype.SEC_DESTINATION,Panel.prototype.OP_METRO,A)}error(C[this.lng],this.lng)}};Controller.prototype.getRoutesCB=function(C){var A={"en":"Failed to calculate routes","fr":"Erreur de calcul de trajets"};try{this.parseRoutes(C.responseXML);this.adjustRoutesEndPoints();this.geocodeRoutes();this.renderRoutes();this.panel.showRoutesPanel(this.currentRoute,this.route.length)}catch(B){error(A[this.lng],this.lng);this.panel.showParametersForm()}};Controller.prototype.swapCB=function(A){};Controller.prototype.post=function(A){switch(A.type){case"setLocation":this.board["setLocation"].push(A);break;case"getRoutes":this.board["getRoutes"]=A}};Controller.prototype.processPending=function(){var B;if(this.board["setLocation"].length){if(this.id){for(var A=0;A<this.board["setLocation"].length;A++){B=this.board["setLocation"].shift();B.url+="&sid="+this.id;YAHOO.util.Connect.asyncRequest("POST",B.url,this.setLocationCallback)}}}else{if(this.board["getRoutes"]){if(this.id&&this.origin&&this.destination){B=this.board["getRoutes"];B.url+="&sid="+this.id;YAHOO.util.Connect.asyncRequest("POST",B.url,this.getRoutesCallback);this.board["getRoutes"]=null}}}};Controller.prototype.parseHeader=function(C){var E=C.getElementsByTagName("code")[0].firstChild.nodeValue;var F=Utilities.getOptionalElement(C,"id");var D=Utilities.getOptionalElement(C,"count");var B=Utilities.getOptionalElement(C,"routeIndex");var A=Utilities.getOptionalElement(C,"od");if(D!=null){D=parseInt(D)}else{D=-1}if(B!=null){B=parseInt(B)}else{D=-1}return{code:E,id:F,count:D,routeIndex:B,od:A}};Controller.prototype.parseLocation=function(B){var A={"en":"Origin","fr":"Origine"};var C=B.getElementsByTagName("origin");if(C.length!=0){this.origin=new Stop(B);this.origin.setTitle("<center><strong>"+A[this.lng]+"</strong></center>");return 0}this.destination=new Stop(B,this.destinationIcon);this.destination.setTitle("<center><strong>Destination</strong></center>");return 1};Controller.prototype.parseLocations=function(C){var A=new Array();var D=C.getElementsByTagName("location");for(var B=0;B<D.length;B++){A.push(Stop.prototype.factory(D[B]))}return A};Controller.prototype.parseRoutes=function(D){var A=D.getElementsByTagName("route");var B;for(var C=0;C<A.length;C++){B=new Route(A[C]);if(!B.isGeocoded()){this.geocodeRoute(C)}this.route.push(B)}if(this.route.length){this.currentRoute=0;this.route[0].show({ctrl:this.myName,map:this.map,index:0,origin:this.origin,destination:this.destination,color:this.colors[0]})}};Controller.prototype.refreshPanel=function(B,A,C){this.panel.refresh(B,A,C)};Controller.prototype.showNextRoute=function(){if(this.currentRoute==this.route.length-1){return }this.route[this.currentRoute].hide(this.map);this.currentRoute++;this.panel.showRoutesPanel(this.currentRoute,this.route.length);this.route[this.currentRoute].show({ctrl:this.myName,map:this.map,index:this.currentRoute,origin:this.origin,destination:this.destination,color:this.colors[this.currentRoute%this.route.length]})};Controller.prototype.showPreviousRoute=function(){if(!this.currentRoute){return }this.route[this.currentRoute].hide(this.map);this.currentRoute--;this.panel.showRoutesPanel(this.currentRoute,this.route.length);this.route[this.currentRoute].show({ctrl:this.myName,map:this.map,index:this.currentRoute,origin:this.origin,destination:this.destination,color:this.colors[this.currentRoute%this.route.length]})};Controller.prototype.addEventListeners=function(){this.addEventListenersToFormSelectors("o");this.addEventListenersToLocationForms("o");this.addEventListenersToChangeBtn("o");this.addEventListenersToResults("o");this.addEventListenersToFormSelectors("d");this.addEventListenersToLocationForms("d");this.addEventListenersToChangeBtn("d");this.addEventListenersToResults("d");this.addEventListenersToComputeBtn();this.addEventListenersToRouteNav()};Controller.prototype.addEventListenersToFormSelectors=function(A){var C=(A=="o")?"origin_":"destination_";var B=this;YAHOO.util.Event.addListener(C+"type_metro","click",function(){B.panel.showLocationForm(A,"metro")});YAHOO.util.Event.addListener(C+"type_address","click",function(){B.panel.showLocationForm(A,"address")})};Controller.prototype.addEventListenersToLocationForms=function(A){var D=(A=="o")?"origin_":"destination_";var C;var B=this;C=document.getElementById(D+"select_metro");C.onchange=function(){B.setMetro(this.value,A)};C=document.getElementById(D+"search_address");C.onclick=function(){var G=document.getElementById(D+"address_query");if(G.value){var F=new RegExp("^([^/]+)/(.+)$");var E=F.exec(G.value);if(E){B.searchStreetIntersection(E[1],E[2],A)}else{B.search(G.value,A)}}};YAHOO.util.Event.addListener(D+"address_query","keydown",function(H){if(H.keyCode==13){YAHOO.util.Event.preventDefault(H);var G=H.target?H.target:H.srcElement;if(G.value){var F=new RegExp("^([^/]+)/(.+)$");var E=F.exec(G.value);if(E){B.searchStreetIntersection(E[1],E[2],A)}else{B.search(G.value,A)}}}})};Controller.prototype.addEventListenersToChangeBtn=function(A){var D=(A=="o")?"origin_":"destination_";var B=this;var C=document.getElementById(D+"location_change");C.onclick=function(){document.getElementById(D+"forms").style.display="block";document.getElementById(D+"location").style.display="none";document.getElementById(D+"results").style.display="none";B.changeLocation(A)}};Controller.prototype.addEventListenersToResults=function(A){var E=(A=="o")?"origin_":"destination_";var B=this;var D=document.getElementById(E+"results_new");D.onclick=function(){document.getElementById(E+"forms").style.display="block";document.getElementById(E+"location").style.display="none";document.getElementById(E+"results").style.display="none"};for(var C=0;C<4;C++){D=document.getElementById(E+"results_"+C+"_btn");D.onclick=function(){B.selectedSearchResultIndex=parseInt(this.getAttribute("id").replace(E+"results_","").replace("_btn",""))}}var D=document.getElementById(E+"results_select");D.onclick=function(){B.setLocation(B.searchResults[B.selectedSearchResultIndex],A)}};Controller.prototype.addEventListenersToComputeBtn=function(){var A=this;var B=document.getElementById("compute_routes");B.onclick=function(){var C={"en":"Invalid date","fr":"Date invalide"};var D=A.panel.parametersFormData();if(D.day==-1||D.hour==-1||D.min==-1){error(C[A.lng],A.lng);return }A.getRoutes(D.day,D.hour,D.min,D.pwalk,D.ptrans,D.umetro,D.utrain,D.deparr,0,10)}};Controller.prototype.addEventListenersToRouteNav=function(){var A=this;YAHOO.util.Event.addListener("previous_route","click",function(){A.showPreviousRoute()});YAHOO.util.Event.addListener("next_route","click",function(){A.showNextRoute()});YAHOO.util.Event.addListener("recompute_routes","click",function(){A.recompute()})};function Panel(A){var B={"en":0,"fr":1};this.lng=B[A]}Panel.prototype.SEC_ORIGIN=0;Panel.prototype.SEC_DESTINATION=1;Panel.prototype.SEC_ROUTE=2;Panel.prototype.OP_INIT=0;Panel.prototype.OP_UNSPECIFIED=1;Panel.prototype.OP_PROCESSING=2;Panel.prototype.OP_EMPTY=3;Panel.prototype.OP_PARAMETERS=4;Panel.prototype.OP_ROUTE=5;Panel.prototype.OP_LOCATION=6;Panel.prototype.OP_METRO=7;Panel.prototype.OP_ADDRESS=8;Panel.prototype.OP_INTERSECTION=9;Panel.prototype.showLocationForm=function(A,E){var D=(A=="o")?"origin_":"destination_";var B=YAHOO.util.Dom.get(D+"metro");var C=YAHOO.util.Dom.get(D+"address");switch(E){case"metro":YAHOO.util.Dom.setStyle(C,"display","none");YAHOO.util.Dom.setStyle(B,"display","block");YAHOO.util.Dom.setAttribute(D+"type_metro","checked",true);YAHOO.util.Dom.setAttribute(D+"type_address","checked",false);break;case"address":YAHOO.util.Dom.setStyle(B,"display","none");YAHOO.util.Dom.setStyle(C,"display","block");YAHOO.util.Dom.setAttribute(D+"type_metro","checked",false);YAHOO.util.Dom.setAttribute(D+"type_address","checked",true)}};Panel.prototype.showResults=function(B,A){var E=(A=="o")?"origin_":"destination_";var F=Math.min(B.length,4);var D;for(var C=0;C<4;C++){D=YAHOO.util.Dom.get(E+"results_"+C);YAHOO.util.Dom.setStyle(D,"display","none");D=YAHOO.util.Dom.get(E+"results_"+C+"_txt");D.innerHTML=""}for(var C=0;C<F;C++){D=YAHOO.util.Dom.get(E+"results_"+C);YAHOO.util.Dom.setStyle(D,"display","block");D=YAHOO.util.Dom.get(E+"results_"+C+"_txt");D.innerHTML=B[C].getLabel()}YAHOO.util.Dom.setStyle([E+"forms",E+"location"],"display","none");YAHOO.util.Dom.setStyle(E+"results","display","block")};Controller.prototype.renderRoutes=function(){var A={"en":"found","fr":"trouv&#233;s"};var D=Math.min(this.route.length,3);var C;YAHOO.util.Dom.get("routes_count").innerHTML="&#160;("+this.route.length+" "+A[this.lng]+")";for(var B=0;B<3;B++){YAHOO.util.Dom.get("route_"+B).innerHTML=""}for(var B=0;B<D;B++){YAHOO.util.Dom.get("route_"+B).innerHTML=this.route[B].toHTML(B,this.origin,this.destination,this.lng)}};Panel.prototype.showLocation=function(A,B){var C=(A=="o")?"origin_":"destination_";YAHOO.util.Dom.get(C+"location_label").innerHTML=B;YAHOO.util.Dom.setStyle([C+"forms",C+"results"],"display","none");YAHOO.util.Dom.setStyle(C+"location","display","block")};Panel.prototype.showParametersForm=function(){YAHOO.util.Dom.setStyle(["fetching_routes","routes"],"display","none");YAHOO.util.Dom.setStyle("parameters","display","block")};Panel.prototype.showFetchingRoutesPanel=function(){YAHOO.util.Dom.setStyle(["parameters","routes"],"display","none");YAHOO.util.Dom.setStyle("fetching_routes","display","block")};Panel.prototype.showRoutesPanel=function(A,E){var D;var F=Math.min(E,3);if(A>=F){return }YAHOO.util.Dom.setStyle("parameters","display","none");YAHOO.util.Dom.setStyle("fetching_routes","display","none");var C=YAHOO.util.Dom.get("routes");YAHOO.util.Dom.setStyle(C,"display","block");var B=YAHOO.util.Dom.getChildren(C);B.shift();B.shift();YAHOO.util.Dom.setStyle(B,"display","none");YAHOO.util.Dom.setStyle(B[A],"display","block");D=YAHOO.util.Dom.get("previous_route");if(A==0){YAHOO.util.Dom.removeClass(D,"panel_button_en");YAHOO.util.Dom.addClass(D,"panel_button_dis")}else{YAHOO.util.Dom.removeClass(D,"panel_button_dis");YAHOO.util.Dom.addClass(D,"panel_button_en")}D=YAHOO.util.Dom.get("next_route");if(A==F-1){YAHOO.util.Dom.removeClass(D,"panel_button_en");YAHOO.util.Dom.addClass(D,"panel_button_dis")}else{YAHOO.util.Dom.removeClass(D,"panel_button_dis");YAHOO.util.Dom.addClass(D,"panel_button_en")}};Panel.prototype.renderParametersForm=function(){this.renderDays();this.renderHours();this.renderMinutes()};Panel.prototype.renderDays=function(){var L;var B;if(this.lng==1){L=["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"]}else{L=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}var G=document.getElementById("day");var D=new Date();var I=D.getDate();var E=D.getMonth();var A=D.getDay();var M=D.getFullYear();var F;var K,J;var C;for(var H=0;H<10;H++){F=E+1;if(this.lng==1){K=L[(A+H)%7].substr(0,3)+", "+I+"/"+F}else{K=L[(A+H)%7].substr(0,3)+", "+F+"/"+I}J=L[(A+H)%7].substr(0,3)+", "+I+"/"+F+"/"+M;B=document.createElement("option");B.setAttribute("value",J);B.innerHTML=K;if(H==0){B.selected=true}G.appendChild(B);C=this.nextDay(I,E,M);I=C.day;E=C.month;M=C.year}};Panel.prototype.renderHours=function(){var F;var B=document.getElementById("hour");var G;var C=new Date();var E=C.getHours();var A=C.getMinutes();for(var D=0;D<24;D++){G=D;if(D<10){G="0"+G}F=document.createElement("option");F.setAttribute("value",G);F.innerHTML=G;if(A<55){if(D==E){F.selected=true}}else{if(D!=23){if(D==E+1){F.selected=true}}else{if(D==0){F.selected=true}}}B.appendChild(F)}};Panel.prototype.renderMinutes=function(){var C;var F=document.getElementById("minutes");var G;var D=new Date();var B=D.getMinutes();var A=parseInt(B/5)*5;for(var E=0;E<56;E+=5){G=E;if(G<10){G="0"+G}C=document.createElement("option");C.setAttribute("value",G);C.innerHTML=G;if(E==(A+5)%60){C.selected=true}F.appendChild(C)}};Panel.prototype.refreshLocationSec=function(A,G,C){var I;var E=["O","D"];var L=["Origin","Origine"];var M=["Opening a Tous Azimuts session","Ouverture d'une session Tous Azimuts"];var J=["Unspecified","Non sp&#233;cifi&#233;e"];var F=["Working on it, go ahead and fill the other forms if any","En tra&icirc;tement, vous pouvez toujours remplir les autres formulaires"];var K=["Change","Modifier"];var D=["origin","destination"];if(A==0){I=L[this.lng]}else{I="Destination"}var H='<div class="panel_header">'+I+"</div>";switch(G){case this.OP_INIT:H+='<div class="processing"><img src="icones/loading_icon.gif"/>&#160;'+M[this.lng]+"...</div>";break;case this.OP_UNSPECIFIED:H+='<div style="color:red;">&#160;'+J[this.lng]+".</div>";break;case this.OP_METRO:H+=this.metroForm(A,C.ctrl);break;case this.OP_ADDRESS:H+=this.addressForm(A,C.ctrl);break;case this.OP_INTERSECTION:H+=this.intersectionForm(A,C.ctrl);break;case this.OP_PROCESSING:H+='<div class="processing"><img src="icones/loading_icon.gif"/>&#160;'+F[this.lng]+"...</div>";break;case this.OP_LOCATION:var B=C.ctrl+".changeLocation('"+E[A]+"')";H+='<div class="location">'+C.locLabel+"</div>";H+='<center><button name="change" value="Change" class="panel_button_en" onclick="'+B+'">'+K[this.lng]+"</button>";break;default:throw"Invalid panel peration - Location ("+G+")."}document.getElementById(D[A]).innerHTML=H};Panel.prototype.refreshRouteSec=function(B,D){var C;var A=["Getting routes","Calcul des trajets"];switch(B){case this.OP_EMPTY:C="";break;case this.OP_PARAMETERS:C=this.parametersForm(D.ctrl);break;case this.OP_PROCESSING:C='<div class="processing"><img src="icones/loading_icon.gif"/>&#160;'+A[this.lng]+"...</div>";break;case this.OP_ROUTE:C=this.showRoute(D);break;default:throw"Invalid panel peration - Route ("+B+")."}document.getElementById("routes").innerHTML=C};Panel.prototype.showRoute=function(D){var I=["Routes","Trajets"];var H=["found","trouv&#233;s"];var B=["Previous","Pr&#233;c&#233;dent"];var G=["Next","Suivant"];var C=["Recompute","Recalculer"];var A=["en","fr"];var M=D.ctrl+".showPreviousRoute();";var L=D.ctrl+".showNextRoute();";var F=D.ctrl+".recompute();";var J,K;if(D.currentRouteIndex==0){K="panel_button_dis"}else{K="panel_button_en"}if(D.currentRouteIndex==D.routeCount-1){J="panel_button_dis"}else{J="panel_button_en"}var E='<div class="panel_header">'+I[this.lng]+"&#160;("+D.routeCount+" "+H[this.lng]+")</div><br/>";E+='<center><button name="previous" class="'+K+'" onclick="'+M+'">&#171;&#160;'+B[this.lng]+"</button>";E+='<button name="next" class="'+J+'" onclick="'+L+'">'+G[this.lng]+"&#160;&#187;</button>";E+='<button name="recompute" class="panel_button_en" onclick="'+F+'">'+C[this.lng]+"</button></center><br/>";E+="<br/>"+D.currentRoute.toHTML(D.currentRouteIndex+1,D.origin,D.destination,A[this.lng]);return E};Panel.prototype.parametersForm=function(A){var F=["Parameters","Param&#232;tres"];var K=["This is:","Ceci est :"];var M=["Departure time","L'heure de d&#233;part"];var C=["Arrival time","L'heure d'arriv&#233;e"];var L=["Minimize walking distance","Minimiser la marche &agrave; pieds"];var G=["Yes","Oui"];var J=["No","non"];var B=["Minimize transfers","Minimiser les transferts"];var E=["Use metro","Utiliser le m&#233;tro"];var H=["Use train","Utiliser le train"];var I=["Compute","Calculer"];var D='<div class="panel_header">'+F[this.lng]+"</div>";D+='<form  name="set_params">';D+=this.daysElement();D+='<div class="clear"></div><hr/>';D+=this.hoursElement();D+=this.minutesElement();D+='<div class="clear"></div><hr/>'+K[this.lng]+'<br/><input type="radio"  checked name="deparr" value="d">'+M[this.lng]+'<br/><input type="radio"  name="deparr" value="a">'+C[this.lng]+'<div class="clear"></div><hr/>'+L[this.lng]+'?<br/><input type="radio" name="pwalk" value="0">'+J[this.lng]+'</input><input type="radio" name="pwalk" value="1" checked>'+G[this.lng]+'</input><div class="clear"></div><hr/>'+B[this.lng]+'?<br/><input type="radio" name="ptrans" value="0">'+J[this.lng]+'</input>&#160;<input type="radio" name="ptrans" value="1" checked>'+G[this.lng]+'</input><div class="clear"></div><hr/>'+E[this.lng]+'?<br/><input type="radio" name="umetro" value="0">'+J[this.lng]+'</input>&#160;<input type="radio" name="umetro" value="1" checked>'+G[this.lng]+'</input><div class="clear"></div><hr/>'+H[this.lng]+'?<br/><input type="radio" name="utrain" value="0" checked>'+J[this.lng]+'</input>&#160;<input type="radio" name="utrain" value="1" >'+G[this.lng]+"</input>";D+='<center><input type="button" class="panel_button_en"  name="get_routes" value="'+I[this.lng]+'" onclick="r= '+A+".panel.parametersFormData();"+A+'.getRoutes(r.day,r.hour,r.min,r.pwalk,r.ptrans,r.umetro,r.utrain,r.deparr,0,10);" /></center>';D+="</form>";return D};Panel.prototype.daysElement=function(){var A=["Day:","Jour :"];var K;if(this.lng==1){K=["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"]}else{K=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}var H='<label for="day">'+A[this.lng]+'</label><select name="day">';var D=new Date();var I=D.getDate();var E=D.getMonth();var B=D.getDay();var L=D.getFullYear();var J,F;var C;for(var G=0;G<10;G++){F=E+1;J=K[(B+G)%7]+", "+I+"/"+F+"/"+L;H+='<option value="'+J+'">'+J+"</option>";C=this.nextDay(I,E,L);I=C.day;E=C.month;L=C.year}H+="</select>";return H};Panel.prototype.nextDay=function(D,A,B){var C=new Array(31,28,31,30,31,30,31,31,30,31,30,31);if(B%4==0||B%100==0){C[1]++}if(A==11&&D==31){D=1;A=0;B++}else{if(D==C[A]){D=1;A++}else{D++}}return{day:D,month:A,year:B}};Panel.prototype.parametersFormData=function(){var C=document.forms["set_params"].day.value;var A=document.forms["set_params"].hour.value;var E=document.forms["set_params"].minutes.value;var G=this.getRadioButtonsValues(document.forms["set_params"].deparr)[0];var B=this.getRadioButtonsValues(document.forms["set_params"].pwalk)[0];var D=this.getRadioButtonsValues(document.forms["set_params"].ptrans)[0];var H=this.getRadioButtonsValues(document.forms["set_params"].umetro)[0];var F=this.getRadioButtonsValues(document.forms["set_params"].utrain)[0];return{day:C,hour:A,min:E,deparr:G,pwalk:B,ptrans:D,umetro:H,utrain:F}};Panel.prototype.getRadioButtonsValues=function(D){var B=new Array();var A=D.length;for(var C=0;C<A;C++){if(D[C].checked){B.push(D[C].value)}}return B};function StreetViewer(){var A=new GLatLng(45.5020516,-73.5716466);var B={latlng:A};this.panorama=new GStreetviewPanorama(document.getElementById("street_view"),B);this.rotateInterval=null}StreetViewer.prototype.setLocation=function(B){if(!this.panorama){return }var A=B.getLatLng();if(A){if(this.rotateInterval){window.clearInterval(this.rotateInterval);this.rotateInterval=null}this.panorama.setLocationAndPOV(A)}};StreetViewer.prototype.rotate=function(){return ;if(!this.panorama){return }var A=this.panorama.getPOV().yaw;var C=A+10;var B=this;B.rotateInterval=window.setInterval(function(){if(C<A+360){B.panorama.panTo({yaw:C},false);C=C+2}else{window.clearInterval(B.rotateInterval);B.rotateInterval=null}},200)};var Utilities={getOptionalElement:function(B,A){var C=B.getElementsByTagName(A);if(C.length!=0&&C[0].firstChild){return C[0].firstChild.nodeValue}return null}};var ctrl;var stViewer;function init(B){if(GBrowserIsCompatible()){var A={googleBarOptions:{style:"new",adsOptions:{client:"partner-pub-4436967296255282",channel:"busmontreal_map_search",adsafe:"low",language:"en"}}}}var D=new GMap2(document.getElementById("map"));initMarker(D);ctrl=new Controller("ctrl",D,B);ctrl.main();D.addControl(new GLargeMapControl());D.addControl(new GMapTypeControl());var C=new GLatLng(45.50145,-73.570259);D.setCenter(C,14,G_NORMAL_MAP);initDialogs(B);initHelpDialog();stViewer=new StreetViewer();Stop.prototype.streetViewer=stViewer}Controller.prototype.main=function(){this.getMetro();this.loadPreferences();this.renderPanels();this.addEventListeners()}