var vehicles=[];var routes=[];var stops=[];var selected_routes=[];var selected_route_before_all_vehicles=[];var visible_stops=[];var visible_arrows=[];var local_areas=[];var arrivals=[];var trip_planner_visible_stops=[];var trip_planner_visible_lines=[];var selected_vehicle_id="-1";var rezoom=false;var timer;var stop_updating=false;var current_zoom_level=0;var previous_zoom_level=0;var force_image_update=false;var ignore_all_vehicles_toggle_at_route_click=false;var last_vehicle_zoom_level=0;var last_user_activity=new Date();var content_buttons_visible=false;var content_buttons_collapsed=false;var last_visible_label_stop_id="";var last_visible_label_vehicle_id="";var last_sticky_stop_id="";var last_sticky_vehicle_id="";var stops_visible=false;var update_cookie=false;var is_public=true;var domain="";var all_vehicles_on=false;var initial_routes="";var current_day="";var querystring_manual_routes=false;var all_vehicles=[];var find_vehicle_id=null;var xml_update_period=1500;var max_arrivals_on_vehicle_label=0;var max_arrivals_per_route_on_stop_label=0;var trip_planner_line_width=0;var trip_planner_walking_line_color="";var small_vehicle_image_stopped="";var small_vehicle_image_moving="";var door_open_image="";var small_stop_image="";var map_timeout=0;var vehicle_labels_visible=true;var sv_container_width=0;var sv_container_height=0;var speed_cutoff=0;var zoom_limit_vehicle_icons=0;var zoom_limit_arrows=0;var zoom_limit_stops=0;var zoom_limit_no_stops=0;var zoom_level_follow_vehicle=0;var zoom_level_findyourstop=0;var route_text_color_when_on="";var route_text_color_when_off="";var all_vehicles_on_box_color="";var trip_planner_enabled=true;var traffic_overlays_enabled=true;var always_default_to_route_select=false;var route_line_width=0;var enable_google_streetview=true;var allow_user_to_toggle_vehicle_labels=true;var int_override_arrivals_on_vehicle_label=false;var int_override_arrivals_on_stop_label=false;var max_route_name_length_nowrap=0;var vehicle_label_forecolor_offroute="";var vehicle_label_backcolor_offroute="";var disable_route_arrows=false;function Initialize(){var load_url="";domain=QueryString("domain");load_url=xml_base_url+"?mode=routes";if(domain!="")load_url+="&domain="+domain;if(QueryString("id")!="")find_vehicle_id=QueryString("id");RequestXML(load_url,Initialize_Reply);};function Initialize_Reply(){if(xml_request.readyState==4&&xml_request.status==200){response=xml_request.responseXML.documentElement;is_public=(response.getAttribute("external")=="1");xml_params=response.getElementsByTagName("param");all_vehicles=response.getElementsByTagName("vehicle");for(y=0;y<xml_params.length;y++){var one_param=xml_params[y];var p_name=one_param.getAttribute("name");var p_value=one_param.getAttribute("value");eval(p_name+" = "+p_value+";");}if(!is_public){if(int_override_arrivals_on_stop_label)max_arrivals_per_route_on_stop_label=0;if(int_override_arrivals_on_vehicle_label)max_arrivals_on_vehicle_label=0;trip_planner_enabled=false;}if(QueryString("route")!=""){initial_routes=QueryString("route");querystring_manual_routes=true;}if(QueryString("silent_disable_timeout")=="1")map_timeout=0;if(QueryString("disable_timeout")=="1"){map_timeout=0;window.alert("map timeout disabled");}xml_routes=response.getElementsByTagName("stop_set");LoadRoutes(xml_routes);var tokens=initial_routes.split(",");for(ab=0;ab<tokens.length;ab++){var aRouteObj=FindRouteObject(tokens[ab]);if(aRouteObj!=null)selected_routes.push(tokens[ab]);}var vObj=FindVehicleObject(find_vehicle_id);if(vObj!=null){StickyLabelOn("vehicle",vObj);map.setCenter(vObj.position,zoom_level_findyourstop);}else if(QueryString("route")==""){selected_routes=[];var selected_veh;for(i=0;i<all_vehicles.length;i++){if(all_vehicles[i].getAttribute("id")==find_vehicle_id){selected_veh=all_vehicles[i];break;}}if(selected_veh!=null){var aRouteObj=FindRouteObject(selected_veh.getAttribute("stop_set_id"));if(aRouteObj!=null)selected_routes.push(selected_veh.getAttribute("stop_set_id"));find_vehicle_id=selected_veh.getAttribute("id");querystring_manual_routes=true;}}xml_local_areas=response.getElementsByTagName("local_area");LoadLocalAreas(xml_local_areas);Content_DrawNavigationButtons();markers=response.getElementsByTagName("stop_set_point");SetInitialZoom(markers);if(selected_routes.length>0){RefreshRoutes(true);Content_MessageBox_Hide();if(querystring_manual_routes)HideControls();else{if(always_default_to_route_select)Content_DrawRoutesBox();}}else{Content_StartMessage();Content_DrawRoutesBox();}}};function RouteClick(stop_set_id,is_float_label,floating_label_id){if(trip_planner_on)return;if(all_vehicles_on&& !ignore_all_vehicles_toggle_at_route_click)ToggleAllVehicles(false);stop_updating=false;Content_MessageBox_Hide();var routeobj=FindRouteObject(stop_set_id);var color=routeobj.color;var on=routeobj.visible;var routelink1=document.getElementById("route_text_"+stop_set_id);if(floating_label_id)var routelink2=document.getElementById(floating_label_id);var link_color=(on)?route_text_color_when_off:route_text_color_when_on;if(routelink1)routelink1.style.color=link_color;if(floating_label_id)routelink2.style.color=link_color;var colorbox_color=(on)?'':color;var colorbox1=document.getElementById("route_color_box_"+stop_set_id);if(floating_label_id)var colorbox2=document.getElementById("color_box_"+floating_label_id);if(colorbox1)colorbox1.style.backgroundColor=colorbox_color;if(floating_label_id)colorbox2.style.backgroundColor=colorbox_color;if(on){for(g=0;g<selected_routes.length;g++){if(selected_routes[g]==stop_set_id){selected_routes.splice(g,1);break;}}}else selected_routes.push(stop_set_id);if(!is_float_label){ClearLabel('stop',last_sticky_stop_id);last_sticky_stop_id="";ClearLabel('stop',last_visible_label_stop_id);last_visible_label_stop_id="";}//-->
update_cookie=true;RefreshRoutes(!is_float_label);};function LoadRoutes(xml_routes){for(k=0;k<xml_routes.length;k++){route=xml_routes[k];route_obj=new Object();route_obj.stop_set_id=route.getAttribute("stop_set_id");route_obj.color=route.getAttribute("color");route_obj.text_color=route.getAttribute("text_color");route_obj.name=route.getAttribute("name");route_obj.arrow_direction=route.getAttribute("direction");route_obj.show_line=(route.getAttribute("show_line")=="1");route_obj.show_names=(route.getAttribute("show_names")=="1");route_obj.type=route.getAttribute("type");route_obj.visible=false;route_obj.forward_direction_name=route.getAttribute("forward_direction");route_obj.backward_direction_name=route.getAttribute("backward_direction");route_obj.out_of_service=false;if(is_public){var tokens=route.getAttribute("exclude_days").split(",");var exclude_route=false;for(b=0;b<tokens.length;b++){if(tokens[b]==current_day&&tokens[b]!="")exclude_route=true;}if(exclude_route)route_obj.out_of_service=true;}route_obj.arrows=[];route_obj.stops=[];route_obj.array=[];line_array=[];xml_stops=route.getElementsByTagName("stop_set_point");var arrow_variable_name=(route_obj.arrow_direction&&route_obj.arrow_direction=="-1")?"backward_arrow":"forward_arrow";for(j=0;j<xml_stops.length;j++){point=xml_stops[j];latitude=parseFloat(point.getAttribute("latitude"));longitude=parseFloat(point.getAttribute("longitude"));is_stop=(point.getAttribute("is_stop")=="1");if(route_obj.arrow_direction&&point.getAttribute(arrow_variable_name)&& !disable_route_arrows){var arrow_object=new Object();arrow_object.location=new GLatLng(latitude,longitude);arrow_image="images/"+point.getAttribute(arrow_variable_name);arrow_m=new Marker();arrow_m.pane=PANE_STOP;arrow_m.position=arrow_object.location;arrow_m.id="arrow_"+route_obj.stop_set_id+"_"+j;arrow_m.image=arrow_image;arrow_object.arrow_marker=arrow_m;route_obj.arrows.push(arrow_object);}loc=new GLatLng(latitude,longitude);if(is_stop)loc.stop_id=point.getAttribute("stop_id");route_obj.array.push(loc);line_loc=new GLatLng(latitude,longitude);line_array.push(line_loc);if(is_stop){obj=new Object();obj.stop_id=point.getAttribute("stop_id");obj.routes=[];obj.arrivals=[];obj.name=point.getAttribute("name");obj.image=point.getAttribute("image");obj.location=new GLatLng(latitude,longitude);obj.show_label=(parseInt(point.getAttribute("show_label"))==1);obj.label_position=parseInt(point.getAttribute("label_position"));obj.schedule=[];stop_schedule=point.getElementsByTagName("schedule_entry");for(q=0;q<stop_schedule.length;q++){route_obj.has_schedule_stop_entries=true;one=stop_schedule[q];obj1=new Object();obj1.day=parseInt(one.getAttribute("day"));switch(obj1.day){case 1:obj1.day_name="Weekday";break;case 6:obj1.day_name="Saturday";break;case 0:obj1.day_name="Sunday";break;}obj1.at_time=one.getAttribute("at_time");obj.schedule.push(obj1);}pin=new Marker();pin.stop_id=obj.stop_id;pin.original_image=stop_image_dir+obj.image;pin.image=stop_image_dir+obj.image;pin.pane=PANE_STOP;pin.position=obj.location;pin.id="stop_"+obj.stop_id;pin.FloatLabelPane=PANE_FLOAT_LABEL;pin.FloatLabelAnchor='topRight';pin.FloatLabelClassName="stop_label_parent";pin.FloatLabelOpacity=90;var handlers="onmouseout='MouseHandler(\"stop\",\"out\",FindStopObject(\""+pin.stop_id+"\").pin);' "+"onmouseover='MouseHandler(\"stop\",\"in\",FindStopObject(\""+pin.stop_id+"\").pin);'";pin.FloatLabelExtraProperties=handlers;if(obj.show_label){var l=new Label();l.id="stop_label_"+obj.stop_id;l.pane=PANE_STOP_LABEL;l.visible=true;l.anchorLatLng=pin.position;l.classname="stop_fixed_label";l.percentOpacity=90;l.content="<nobr>"+obj.name+"</nobr>";switch(obj.label_position){case 1:l.anchorPoint='bottomLeft';break;case 2:l.anchorPoint='bottomRight';break;case 3:l.anchorPoint='topLeft';break;}pin.label=l;}pin.point_object=obj;obj.pin=pin;if(FindStopObject(obj.stop_id)==null){obj.routes.push(route_obj.stop_set_id);route_obj.stops.push(obj);stops.push(obj);}else{existing_stop_obj=FindStopObject(obj.stop_id);existing_stop_obj.routes.push(route_obj.stop_set_id);route_obj.stops.push(existing_stop_obj);}}}route_obj.line=GetPolyline(line_array,route_obj.color,route_line_width);routes.push(route_obj);}for(m=0;m<stops.length;m++){stops[m].pin.content+="<arrival></arrival>";stops[m].pin.original_content=stops[m].pin.content;}};function LoadLocalAreas(xml_local_areas){for(k=0;k<xml_local_areas.length;k++){local_area=xml_local_areas[k];local_area_obj=new Object();local_area_obj.stop_set_id=local_area.getAttribute("stop_set_id");local_area_obj.name=local_area.getAttribute("name");local_area_obj.bounds=new GLatLngBounds();xml_stops=local_area.getElementsByTagName("local_area_point");for(j=0;j<xml_stops.length;j++){point=xml_stops[j];latitude=parseFloat(point.getAttribute("latitude"));longitude=parseFloat(point.getAttribute("longitude"));loc=new GLatLng(latitude,longitude);local_area_obj.bounds.extend(loc);}local_areas.push(local_area_obj);}};var sv_on_flag=false;function StreetviewControlsToggle(on){if(sv_on_flag==on)return;if(on){map.disableDragging();map.disableDoubleClickZoom();map.disableScrollWheelZoom();}else{map.enableDragging();map.enableDoubleClickZoom();map.enableScrollWheelZoom();}sv_on_flag=on;};function UpdateStopContent(obj){var html="";if(obj.pin.sticky){html+="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='CloseStickyStopLabel("+obj.stop_id+");'><img border='0' src='/images/x-big.gif'></a>"+"</div>";}html+=""+"<table class='stop_label_main_table'>"+"<tr>"+"<td class='stop_name'><b>Stop</b>: "+((obj.name.length<max_route_name_length_nowrap)?"<span style='white-space:nowrap'>":"")+obj.name+((obj.name.length<max_route_name_length_nowrap)?"</span>":"")+"</span></td>"+"</tr>";if(enable_google_streetview){html+="<tr>"+"<td class='stop_label_streetview_link'>"+"<a href='#' id='sv_link_"+obj.stop_id+"' onclick='ToggleStreetView(\""+obj.stop_id+"\");'>"+"street view of this stop"+"</a><div class='stop_label_streetview_container' id='sv_container_"+obj.stop_id+"' "+"onmouseover='StreetviewControlsToggle(true)' onmouseout='StreetviewControlsToggle(false)'></div>"+"</td>"+"</tr>";}html+="<tr>"+"<td class='servedby_heading'>Served By:</td>"+"</tr>"+"<tr>"+"<td id='arrival_table_"+obj.stop_id+"'>"+UpdateStopContent_GetArrivalTableHTML(obj)+"</td>"+"</tr>";if(trip_planner_on&&trip_planner_stop2==""){html+="<tr>"+"<td align='center'>"+"<a href='#' class='trip_planner_stop_link' onclick='TripPlanner_SelectStopFromMap(\""+obj.stop_id+"\");'>"+"Trip Planner:<br>&nbsp; ";if(trip_planner_stop1=="")html+="Depart from this stop";else html+="Make this my destination stop";html+=""+"</td>"+"</tr>";}html+=""+"</table>";var changed=false;if(obj.pin.content!=html){obj.pin.content=html;changed=true;}if(changed&&obj.pin.FloatLabel&&obj.pin.FloatLabel.visible)obj.pin.FloatLabel.setHTML(html);};function UpdateStopContent_GetArrivalTableHTML(obj){var arrival_table_html=""+"<table class='stop_label_routes_table'>";for(y=0;y<obj.routes.length;y++){var route=FindRouteObject(obj.routes[y]);var sid=route.stop_set_id;var floating_label_route_id="stop_route_text_"+sid+"_"+obj.stop_id;arrival_table_html+="<tr><td><div class='RouteColorBlock' id='color_box_"+floating_label_route_id+"' onclick='RouteClick(\""+sid+"\",true,\""+floating_label_route_id+"\");'"+" style='background-color:"+((route.visible)?route.color:"inherit")+"'/></td>"+"<td><a id='"+floating_label_route_id+"' class='RouteLink' "+" style='color:"+((route.visible)?"#000000":"#777777")+"' "+"href='#' onclick='RouteClick(\""+sid+"\",true,\""+floating_label_route_id+"\");'>"+((route.name.length<max_route_name_length_nowrap)?"<span style='white-space:nowrap'>":"")+route.name+((route.name.length<max_route_name_length_nowrap)?"</span>":"")+"</a></td>";var count=0;var arr_html="";if(route.visible&&max_arrivals_per_route_on_stop_label>0){arr_html+="<td><table class='arrival_prediction_table'>";var s_arrivals=Arrivals_TruncateToRouteAndStop(obj.arrivals,route);var has_fwd=false;var has_bkwd=false;for(i=0;i<s_arrivals.length;i++){var onearrp=s_arrivals[i];if(onearrp.direction&&onearrp.direction=="1")has_fwd=true;if(onearrp.direction&&onearrp.direction=="-1")has_bkwd=true;}var both=(has_bkwd&&has_fwd);if(both){var fwd_arr=Arrivals_TruncateToDirection(s_arrivals,"1");fwd_arr=fwd_arr.sort(Arrivals_SortByPrediction);var bkwd_arr=Arrivals_TruncateToDirection(s_arrivals,"-1");bkwd_arr=bkwd_arr.sort(Arrivals_SortByPrediction);for(loop=0;loop<2;loop++){var the_arr=(loop==0)?fwd_arr:bkwd_arr;var dir_name=(loop==0)?route.forward_direction_name:route.backward_direction_name;arr_html+="<tr><td colspan='2'><span style='color:black'>"+dir_name+"</span></td></tr>";for(g=0;g<the_arr.length;g++){count++;var pred=the_arr[g];var arr_text=CalculatePrediction(pred);arr_html+="<tr>"+"<td"+((pred.route.show_names)?">"+pred.vehicle.name+"</td><td>&nbsp;":" colspan='2'>")+arr_text+"</td>";"</tr>";}}}else{s_arrivals=s_arrivals.sort(Arrivals_SortByPrediction);for(i=0;i<s_arrivals.length&&i<max_arrivals_per_route_on_stop_label;i++){count++;var pred=s_arrivals[i];var arr_text=CalculatePrediction(pred);arr_html+="<tr>"+"<td"+((pred.route.show_names)?">"+pred.vehicle.name+"</td><td>&nbsp;":" colspan='2'>")+arr_text+"</td>";"</tr>";}}arr_html+="</table></td>"}if(count>0)arrival_table_html+=arr_html;else arrival_table_html+="<td></td>";arrival_table_html+="</tr>";}arrival_table_html+="</table>";return(arrival_table_html);};function Arrivals_SortByPrediction(a,b){return(a.time-b.time);};function Arrivals_TruncateToRouteAndStop(arr,route){var new_arr=[];for(c=0;c<arr.length;c++){if(arr[c].route==route)new_arr.push(arr[c]);}return(new_arr);};function Arrivals_TruncateToDirection(arr,direction){var new_arr=[];for(c=0;c<arr.length;c++){if(arr[c].direction==direction)new_arr.push(arr[c]);}return(new_arr);};var last_stop_for_streetview="";function ToggleStreetView(stop_id){var stop=FindStopObject(stop_id);var on=(stop.sv_object==null);if(on&& !stop.sticky)StickyLabelOn('stop',stop.pin);var container=document.getElementById("sv_container_"+stop_id);var link=document.getElementById("sv_link_"+stop_id);if(!on){if(stop.sv_object){stop.sv_object.remove();stop.sv_object=null;link.innerHTML="street view of this stop";container.innerHTML="";container.style.width="";container.style.height="";stop.pin.FloatLabel.setPosition(stop.pin.position);stop.pin.FloatLabel.setOpacity(stop.pin.labelOpacity);}}else{last_stop_for_streetview=stop_id;link.innerHTML="close street view";stop.pin.FloatLabel.setOpacity(100);container.style.width=sv_container_width+"px";container.style.height=sv_container_height+"px";var sv_object=new GStreetviewPanorama(container);stop.sv_object=sv_object;GEvent.addListener(sv_object,"error",StreetView_Error);stop.sv_object.setLocationAndPOV(stop.location);stop.pin.FloatLabel.setPosition(stop.pin.position);}};function StreetView_Error(error_code){var error="";if(error_code==GStreetviewPanorama.ErrorValues.NO_NEARBY_PANO)error="Sorry, but there is no street view available for this stop.";if(error_code==GStreetviewPanorama.ErrorValues.FLASH_UNAVAILABLE){error="You must have Adobe Flash Player to use the Street View. Click "+"<a target='_blank' href='http://get.adobe.com/flashplayer/'>here</a> to get it.";}error="<BR>"+error;var div=document.getElementById("sv_container_"+last_stop_for_streetview);div.style.width="auto";div.style.height="auto";div.innerHTML=error;stop.pin.FloatLabel.setPosition(stop.pin.position);};function CalculatePrediction(one_prediction){var secs=one_prediction.time;var arrival_text="";if(secs<=30)arrival_text="arriving";else{var mins=Math.round(secs/60);arrival_text="in "+mins+" min";}return(arrival_text);};function UpdateVehicleContent(pin){var html="";if(pin.sticky){html+="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='CloseStickyVehicleLabel("+pin.vehicle_id+");'><img border='0' src='/images/x-big.gif'></a>"+"</div>";}html+=""+"<table class='vehicle_popup_label_main_table'>"+"<tr>"+"<td class='";if(pin.route!=""){var theroute=FindRouteObject(pin.route);html+="vehicle_popup_label_vehicle_name_onroute' style='background-color:"+theroute.color+"; "+"color:"+theroute.text_color+";'";var route=FindRouteObject(pin.route);}else html+="vehicle_popup_label_vehicle_name_offroute'";html+="><b>Vehicle</b>: "+pin.name+"</td>"+"</tr>";if(pin.route!=""){html+="<tr>"+"<td align='center'>"+"<table class='vehicle_popup_label_routes_table'>"+"<tr>"+"<td valign='middle' align='center'>";var sid=route.stop_set_id;var floating_label_route_id="vehicle_route_text_"+sid+"_"+obj.stop_id;html+="<table><tr><td><div class='RouteColorBlock' id='color_box_"+floating_label_route_id+"' onclick='RouteClick(\""+sid+"\",true,\""+floating_label_route_id+"\");'"+" style='background-color:"+((route.visible)?route.color:"inherit")+"'/></td><td>"+"&nbsp;<a id='"+floating_label_route_id+"' class='RouteLink' "+" style='color:"+((route.visible)?"#000000":"#777777")+"' "+"href='#' onclick='RouteClick(\""+sid+"\",true,\""+floating_label_route_id+"\");'>"+route.name+"</a></td></tr></table>"+"</td>"+"</tr>"+"</table>"+"</td>"+"</tr>";}html+="<tr>"+"<td class='vehicle_popup_label_details'>";if(pin.door_open)html+="<b style='color:#ea321b'>Door: OPEN</b><BR>";if(pin.route!=""&&DoesRouteHaveVehiclesInBothDirections(route)&&pin.direction)html+="Direction: "+((pin.direction=="1")?route.forward_direction_name:route.backward_direction_name)+"<BR>";if(!is_public&&pin.driver!="")html+="<b>Operator:</b><br>"+pin.driver+"&nbsp;<BR><br>";if(!is_public&&pin.ignition!=""){if(pin.ignition=="1")html+="<img style='vertical-align:middle' src='"+vehicle_image_dir+"/green_dot.gif'>&nbsp;Ignition ON&nbsp;<BR>";else if(pin.ignition=="0")html+="<img style='vertical-align:middle' src='"+vehicle_image_dir+"/red_dot.gif'>&nbsp;Ignition OFF&nbsp;<BR>";else if(pin.ignition=="2"||pin.ignition=="3")html+="<img style='vertical-align:middle' src='"+vehicle_image_dir+"/battery.gif'>&nbsp;POWER LOSS&nbsp;<BR>";else if(pin.ignition=="4")html+="<img style='vertical-align:middle' src='"+vehicle_image_dir+"/low_power.gif'>&nbsp;Ignition SLEEP&nbsp;<BR>";}html+=((pin.route=="")?"<br><b>":"")+"Updated: "+((pin.route=="")?"</b><br>":"")+pin.time_label+"&nbsp;<BR>"+((pin.route=="")?"<br>":"");if(!is_public)html+="Speed: "+pin.speed+" MPH<br>";if(pin.speed>speed_cutoff)html+="Moving: "+pin.heading;else html+="Stopped";if(pin.apc_image)html+="<BR>Percent Full:&nbsp;<img style='vertical-align:middle' src='"+pin.apc_image+"'>";html+=""+"</td>"+"</tr>";if(max_arrivals_on_vehicle_label>0&&pin.route!=""){html+="<tr>"+"<td>"+"<span class='vehicle_popup_label_next_stops_heading'>Next Stops:</span>"+"<table class='vehicle_popup_label_next_stops_table'>";if(pin.arrivals&&pin.arrivals.length>0){pin.arrivals.sort(Arrivals_SortByPrediction);for(m=0;m<pin.arrivals.length&&m<max_arrivals_on_vehicle_label;m++){var arrp1=pin.arrivals[m];var arr_text=CalculatePrediction(arrp1);html+="<tr><td>"+arrp1.stop.name+"&nbsp;</td><td>"+arr_text+"</td></tr>";}}else html+="<tr><td align='center'>Not available</td></tr>";html+="</table>"+"</td>"+"</tr>";}html+="</table>";var changed=false;if(pin.content!=html){pin.content=html;changed=true;}if(changed&&pin.FloatLabel&&pin.FloatLabel.visible)pin.FloatLabel.setHTML(html);};function DoesRouteHaveVehiclesInBothDirections(route){var has_fwd=false;var has_bkwd=false;for(z=0;z<vehicles.length;z++){var oneveh=vehicles[z];if(oneveh.route==route.stop_set_id){if(oneveh.direction&&oneveh.direction=="1")has_fwd=true;if(oneveh.direction&&oneveh.direction=="-1")has_bkwd=true;}}return(has_fwd&&has_bkwd);};function RequestUpdate(){if(timer!=null){window.clearTimeout(timer);timer=null;}if(stop_updating){for(i=0;i<vehicles.length;i++)vehicles[i].Remove();vehicles=[];stop_updating=false;return;}url=xml_base_url+"?mode=";if(!is_public&&all_vehicles_on)url+="track_all";else{url+="track";url+="&route=";url+=GetSelectedRoutes();}if(is_public)url+="&domain="+domain;if(update_cookie){url+="&changed=1";update_cookie=false;}RequestXML(url,RequestUpdate_Reply);};function RequestUpdate_Reply(){if(xml_request&&xml_request.readyState==4&&xml_request.status==200){response=xml_request.responseXML.documentElement;route_markers=response.getElementsByTagName("route");all_markers=response.getElementsByTagName("vehicle");if(!map_loaded)SetInitialZoom(all_markers);UpdateTrackingData(route_markers,all_markers);UpdateArrivals(route_markers);if(rezoom){rezoom=false;ZoomOnVehicles();}if(map_timeout>0&&is_public){var now=new Date();var elapsed=(now.valueOf()-last_user_activity.valueOf());if(elapsed>map_timeout){Content_MapTimeout();return;}}if(selected_routes.length==0&& !all_vehicles_on)return;timer=window.setTimeout(RequestUpdate,xml_update_period);if(find_vehicle_id!=null){var vObj=FindVehicleObject(find_vehicle_id);if(vObj!=null){StickyLabelOn("vehicle",vObj);map.setCenter(vObj.position,zoom_level_findyourstop);}else{selected_routes=[];var selected_veh;for(i=0;i<all_vehicles.length;i++){if(all_vehicles[i].getAttribute("id")==selvalue){selected_veh=all_vehicles[i];break;}}var aRouteObj=FindRouteObject(selected_veh.getAttribute("stop_set_id"));if(aRouteObj!=null)selected_routes.push(selected_veh.getAttribute("stop_set_id"));find_vehicle_id=selected_veh.getAttribute("id");querystring_manual_routes=true;RefreshRoutes(false);}find_vehicle_id=null;}}};function UpdateTrackingData(route_markers,all_markers){for(n=0;n<route_markers.length;n++){current_route_marker=route_markers[n];current_route_id=current_route_marker.getAttribute("id");current_route_object=FindRouteObject(current_route_id);markers=current_route_marker.getElementsByTagName("vehicle");arrival_stops=current_route_marker.getElementsByTagName("stop_arrival");for(m=0;m<markers.length;m++){var marker=markers[m];var index=FindVehicleIndex(marker.getAttribute("id"));if(index== -1){pin=CreateNewVehicle(marker,current_route_object);pin.Add();SetMouseHandlers('vehicle',pin);vehicles.push(pin);}else UpdateVehicle(index,marker,current_route_object);marker=null;}}if(all_vehicles_on){response=xml_request.responseXML.documentElement;unassigned_xml_object=response.getElementsByTagName("unassigned")[0];unassigned_vehicles=unassigned_xml_object.getElementsByTagName("vehicle");for(m=0;m<unassigned_vehicles.length;m++){var marker=unassigned_vehicles[m];var index=FindVehicleIndex(marker.getAttribute("id"));if(index== -1){pin=CreateNewVehicle(marker,null);pin.Add();SetMouseHandlers('vehicle',pin);vehicles.push(pin);}else UpdateVehicle(index,marker,null);marker=null;}}var length=vehicles.length;for(s=0;s<length;s++){var found=false;for(j=0;j<all_markers.length;j++){if(all_markers[j].getAttribute("id")==vehicles[s].vehicle_id){found=true;break;}}if(!found){vehicles[s].Remove();vehicles.splice(s,1);length=length-1;s=s-1;}}last_vehicle_zoom_level=current_zoom_level;force_image_update=false;};function UpdateVehicle(index,marker,route_object){var latitude=marker.getAttribute("latitude");var longitude=marker.getAttribute("longitude");var speed_text=marker.getAttribute("speed")+" MPH";var heading=marker.getAttribute("heading");var updated=marker.getAttribute("last_update");var speed=parseFloat(marker.getAttribute("speed"));var name=marker.getAttribute("name");var apc_image=marker.getAttribute("apc_image");var door_open=(marker.getAttribute("door_status")=="1");var direction=marker.getAttribute("dir");var driver=((marker.getAttribute("driver")!=null)?marker.getAttribute("driver"):"");var ignition=((marker.getAttribute("ignition")!=null)?marker.getAttribute("ignition"):"");var route=((route_object!=null)?route_object.stop_set_id:"");var pin=vehicles[index];var lat,lng;lat=pin.position.lat();lng=pin.position.lng();var pin_changed=false;if(pin.route!=route){pin_changed=true;pin.route=route;var new_route_object=FindRouteObject(pin.route);if(pin.route!=""){pin.label.setColor(new_route_object.color);pin.label.setTextColor(new_route_object.text_color);pin.label.setOpacity(80);}else{pin.label.setColor(vehicle_label_backcolor_offroute);pin.label.setTextColor(vehicle_label_forecolor_offroute);pin.label.setOpacity(100);}}if(pin.driver!=driver){pin_changed=true;pin.driver=driver;}if(pin.ignition!=ignition){pin_changed=true;pin.ignition=ignition;}var current_door=pin.door_open;if(lat!=latitude||lng!=longitude||current_door!=door_open){pin_changed=true;if(apc_image)pin.apc_image=apc_image;if(direction)pin.direction=direction;else pin.direction=null;pin.time_label=updated;pin.heading=heading;pin.speed=speed;var loc=new GLatLng(latitude,longitude);var new_image;new_image=GetIconImage(speed,heading,door_open,pin.icon_prefix);if(last_sticky_vehicle_id==pin.vehicle_id||last_visible_label_vehicle_id==pin.vehicle_id)UpdateVehicleContent(pin);pin.door_open=door_open;pin.position=loc;pin.Move(loc);if(new_image!=pin.image)pin.ChangeImage(new_image);if(last_sticky_vehicle_id==pin.vehicle_id)map.panTo(loc);}if(pin_changed&&pin.FloatLabelVisible())UpdateVehicleContent(pin);if((last_vehicle_zoom_level!=current_zoom_level)||force_image_update){new_image=GetIconImage(speed,heading,door_open,pin.icon_prefix);if(new_image!=pin.image)pin.ChangeImage(new_image);}};function CreateNewVehicle(marker,route_object){var lat=marker.getAttribute("latitude");var lng=marker.getAttribute("longitude");var loc,pin;var image="vehicle_icons/";var time=marker.getAttribute("last_update");var speed=parseFloat(marker.getAttribute("speed"));var heading=marker.getAttribute("heading");var name=marker.getAttribute("name");var id=marker.getAttribute("id");var apc_image=marker.getAttribute("apc_image");var door_open=(marker.getAttribute("door_status")=="1");var icon_prefix=marker.getAttribute("icon_prefix");var direction=marker.getAttribute("dir");var driver=((marker.getAttribute("driver")!=null)?marker.getAttribute("driver"):"");var ignition=((marker.getAttribute("ignition")!=null)?marker.getAttribute("ignition"):"");var route=((route_object!=null)?route_object.stop_set_id:"");if(!icon_prefix)icon_prefix="";image=GetIconImage(speed,heading,door_open,icon_prefix);loc=new GLatLng(lat,lng);pin=new Marker();pin.name=name;pin.speed=speed;pin.time_label=time;pin.heading=heading;pin.route=route;pin.driver=driver;pin.ignition=ignition;if(direction)pin.direction=direction;if(apc_image)pin.apc_image=apc_image;pin.icon_prefix=icon_prefix;pin.is_vehicle=true;pin.image=image;pin.door_open=door_open;pin.position=loc;pin.id="vehicle_"+id;pin.vehicle_id=id;pin.pane=PANE_VEHICLE;pin.sticky=false;pin.FloatLabelPane=PANE_FLOAT_LABEL;pin.FloatLabelAnchor='topRight';pin.FloatLabelClassName="vehicle_popup_label";pin.FloatLabelOpacity=90;var handlers="onmouseout='MouseHandler(\"vehicle\",\"out\",FindVehicleObject(\""+pin.vehicle_id+"\"));' "+"onmouseover='MouseHandler(\"vehicle\",\"in\",FindVehicleObject(\""+pin.vehicle_id+"\"));' ";pin.FloatLabelExtraProperties=handlers;pin.content="";var label=new Label(pin);label.pane=PANE_VEHICLE_LABEL;label.visible=true;label.id=id+"_label";label.classname="vehicle_name_label";if(pin.route!=""){label.color=route_object.color;label.text_color=route_object.text_color;label.percentOpacity=80;}else{label.percentOpactity=100;label.text_color=vehicle_label_forecolor_offroute;label.color=vehicle_label_backcolor_offroute;}label.anchorPoint='bottomLeft';label.content=name;pin.label=label;return(pin);};function GetSelectedRoutes(){var ret="";if(selected_routes.length>0){for(h=0;h<selected_routes.length;h++){if(h>0)ret+=",";ret+=selected_routes[h];}}return(ret);};function SelectAllRoutes(){selected_routes=[];for(h=0;h<routes.length;h++){selected_routes.push(routes[h].stop_set_id);}};function ResumeUpdates(){last_user_activity=new Date();RequestUpdate();};function SetInitialZoom(markers){var a_bounds=new GLatLngBounds;for(k=0;k<markers.length;k++){m=markers[k];if(m.getAttribute("is_stop")=="1"){var a_lat=parseFloat(m.getAttribute("latitude"));var a_lng=parseFloat(m.getAttribute("longitude"));var a_pos=new GLatLng(a_lat,a_lng);a_bounds.extend(a_pos);}}LoadMap(a_bounds,AfterMapLoaded);};function AfterMapLoaded(){current_zoom_level=map.getZoom();GEvent.addListener(map,"zoomend",function(old_zoom,new_zoom){last_vehicle_zoom_level=old_zoom;previous_zoom_level=old_zoom;current_zoom_level=new_zoom;UpdateOnRezoom();});GEvent.addListener(map,"mousemove",function(){last_user_activity=new Date();});};function UpdateOnRezoom(){for(h=0;h<selected_routes.length;h++){var cur_route=selected_routes[h];if(current_zoom_level>=zoom_limit_arrows){route=FindRouteObject(cur_route);if(!route.arrows_visible){for(u=0;u<route.arrows.length;u++){arrow_object=route.arrows[u];arrow_object.arrow_marker.Add();visible_arrows.push(arrow_object.arrow_marker);}route.arrows_visible=true;}}else if(current_zoom_level<zoom_limit_arrows&&previous_zoom_level>=zoom_limit_arrows){for(u=0;u<selected_routes.length;u++)FindRouteObject(selected_routes[u]).arrows_visible=false;for(u=0;u<visible_arrows.length;u++)visible_arrows[u].Remove();visible_arrows=[];}}var prev_stops_visible=stops_visible;var prev_large_icons=(previous_zoom_level>=zoom_limit_stops);var cur_stops_visible=(current_zoom_level>=zoom_limit_no_stops||trip_planner_on);var large_icons=(current_zoom_level>=zoom_limit_stops);var change=((prev_stops_visible!=cur_stops_visible)||(prev_large_icons!=large_icons));if(change){for(m=0;m<visible_stops.length;m++){var stop=visible_stops[m];if(!stop.pin.visible&&cur_stops_visible){stop.pin.Add();SetMouseHandlers('stop',stop.pin);}if(stop.pin.visible&& !cur_stops_visible){stop.pin.Remove();}if(stop.pin.visible){var new_image=(large_icons)?stop.pin.original_image:small_stop_image;stop.pin.ChangeImage(new_image);}}}stops_visible=cur_stops_visible;};function ZoomOnRoutes(single_route_id){var route_zoom_arr=[];for(p=0;p<selected_routes.length;p++){if(single_route_id){if(selected_routes[p]!=single_route_id)continue;}var routeObj=FindRouteObject(selected_routes[p]);for(b=0;b<route.array.length;b++)route_zoom_arr.push(route.array[b]);}SetGoogleZoom(route_zoom_arr);};function RefreshRoutes(rezoom,override_stop){last_user_activity=new Date();var route_zoom_arr=[];for(p=0;p<selected_routes.length;p++){var routeObj=FindRouteObject(selected_routes[p]);if(rezoom){for(b=0;b<route.array.length;b++)route_zoom_arr.push(route.array[b]);}if(!routeObj.visible)ShowRoute(routeObj);}for(p=0;p<routes.length;p++){var routeObj=routes[p];if(routeObj.visible){var route_found=false;for(m=0;m<selected_routes.length;m++){if(selected_routes[m]==routeObj.stop_set_id){route_found=true;break;}}if(!route_found)HideRoute(routeObj);}}var new_visible_stops=[];if(!trip_planner_on){for(q=0;q<selected_routes.length;q++){var a_route=FindRouteObject(selected_routes[q]);for(g=0;g<a_route.stops.length;g++){var stop_found=false;for(h=0;h<new_visible_stops.length;h++){if(new_visible_stops[h]==a_route.stops[g]){stop_found=true;break;}}if(!stop_found)new_visible_stops.push(a_route.stops[g]);}}}else{new_visible_stops=trip_planner_visible_stops;for(b=0;b<new_visible_stops.length;b++)route_zoom_arr.push(new_visible_stops[b].location);}for(p=0;p<visible_stops.length;p++){var stop_found=false;for(e=0;e<new_visible_stops.length;e++){if(visible_stops[p]==new_visible_stops[e]){stop_found=true;break;}}if(!stop_found){stop=visible_stops[p];stop.pin.Remove();if(last_sticky_stop_id==stop.stop_id)last_sticky_stop_id="";if(last_visible_label_stop_id==stop.stop_id)last_visible_label_stop_id="";}}var should_stops_visible=(current_zoom_level>=zoom_limit_no_stops||trip_planner_on);for(p=0;p<new_visible_stops.length;p++){var stop_found=false;for(e=0;e<visible_stops.length;e++){if(new_visible_stops[p]==visible_stops[e]){stop_found=true;break;}}if(!stop_found){stop=new_visible_stops[p];var use_small_icons=(current_zoom_level<zoom_limit_stops);stop.pin.image=(use_small_icons)?small_stop_image:stop.pin.original_image;UpdateStopContent(stop);if(should_stops_visible){stop.pin.Add();SetMouseHandlers('stop',stop.pin);ToggleStepNumberLabel(stop,true);}}}stops_visible=should_stops_visible;visible_stops=new_visible_stops;if(rezoom&& !ignore_all_vehicles_toggle_at_route_click){SetGoogleZoom(route_zoom_arr,false);}if(selected_routes.length==0&& !override_stop){stop_updating=true;return;}RequestUpdate();};function ToggleStepNumberLabel(stop,on_or_off){if(on_or_off){if(stop.trip_planner_step_number){if(stop.step_label)return;if(!stop.step_label){var l=new Label();l.id="stop_number_"+stop.stop_id+"_"+stop.trip_planner_step_number;l.pane=PANE_STOP_LABEL;l.visible=true;l.anchorLatLng=stop.location;l.classname="stop_fixed_label_step_number";l.percentOpacity=90;l.content=stop.trip_planner_step_number+".";l.anchorPoint='bottomLeft';stop.step_label=l;}if(stop.pin.label){map.removeLabel(stop.pin.label);stop.pin.old_label=stop.pin.label;}stop.pin.label=stop.step_label;if(stop.pin.visible)map.addLabel(stop.step_label);}}else{if(stop.trip_planner_step_number){stop.trip_planner_step_number=null;if(stop.step_label)map.removeLabel(stop.step_label);stop.step_label=null;if(stop.pin.old_label)stop.pin.label=stop.pin.old_label;else stop.pin.label=null;}}};function ShowRoute(route_obj){route_obj.visible=true;if(route.show_line)map.addOverlay(route.line);if(current_zoom_level>=zoom_limit_arrows&& !route_obj.arrows_visible){route.arrows_visible=true;for(u=0;u<route_obj.arrows.length;u++){arrow_object=route_obj.arrows[u];arrow_object.arrow_marker.Add();visible_arrows.push(arrow_object.arrow_marker);}}};function HideRoute(route_obj){route_obj.visible=false;if(route.show_line)map.removeOverlay(route_obj.line);if(route_obj.arrows_visible){route_obj.arrows_visible=false;for(u=0;u<route_obj.arrows.length;u++){arrow_object=route_obj.arrows[u];arrow_object.arrow_marker.Remove();}visible_arrows=[];for(h=0;h<selected_routes.length;h++){var obj=FindRouteObject(selected_routes[h]);for(j=0;j<obj.arrows.length;j++)visible_arrows.push(obj.arrows[j].arrow_marker);}}};function SetMouseHandlers(type,pin,callback){SetEvent(pin.element,"onmouseover","MouseHandler('"+type+"','in',this.parentMarker);");SetEvent(pin.element,"onmouseout","MouseHandler('"+type+"','out',this.parentMarker);");SetEvent(pin.element,"onclick","MouseHandler('"+type+"','click',this.parentMarker);");};function ClearLabel(type,the_id){if(the_id!=""){var vis_obj=null;if(type=="stop")vis_obj=FindStopObject(the_id);if(type=="vehicle")vis_obj=FindVehicleObject(the_id);var pin=(type=="stop")?vis_obj.pin:vis_obj;if(!pin)return;if(pin.hide_label_timer)window.clearTimeout(pin.hide_label_timer);pin.sticky=false;if(pin.visible)pin.HideFloatingLabel();}};function CloseStickyStopLabel(id){var obj=FindStopObject(id);if(obj.sv_object){obj.sv_object.remove();obj.sv_object=null;}obj.pin.sticky=false;obj.pin.HideFloatingLabel();last_sticky_stop_id="";};function CloseStickyVehicleLabel(id){var obj=FindVehicleObject(id);obj.sticky=false;obj.HideFloatingLabel();last_sticky_vehicle_id="";if(obj.route!="")ZoomOnRoutes(obj.route);else ZoomOnRoutes();};function MouseHandler(type,action,pin1){if(action=="in"){if(pin1.hide_label_timer){window.clearTimeout(pin1.hide_label_timer);pin1.hide_label_timer=null;}if(type=='stop'){if(!pin1.show_label_timer){if(pin1.FloatLabelVisible())return;pin1.show_label_timer=window.setTimeout(ShowPinLabelFunctionPointer(type,pin1),150);}}else{if(!pin1.FloatLabelVisible())ShowPinLabel(type,pin1);}}else if(action=="out"){if(pin1.show_label_timer){window.clearTimeout(pin1.show_label_timer);pin1.show_label_timer=null;}if(pin1.FloatLabelVisible()){if(!pin1.sticky){if(!pin1.hide_label_timer)pin1.hide_label_timer=window.setTimeout(HidePinLabelFunctionPointer(type,pin1),750);}}}else if(action=="click"){if(trip_planner_on){TripPlanner_SelectStopFromMap(pin1.stop_id);return;}if(!pin1.sticky){StickyLabelOn(type,pin1);}else{if(type=='stop')CloseStickyStopLabel(pin1.stop_id);else CloseStickyVehicleLabel(pin1.vehicle_id);}}};function StickyLabelOn(type,pin1){var clear=(type=='stop')?(last_sticky_stop_id!=pin1.stop_id):(last_sticky_vehicle_id!=pin1.vehicle_id);var id_to_clear=(type=='stop')?last_sticky_stop_id:last_sticky_vehicle_id;if(clear)ClearLabel(type,id_to_clear);pin1.sticky=true;if(type=='stop')last_sticky_stop_id=pin1.stop_id;else last_sticky_vehicle_id=pin1.vehicle_id;ShowPinLabel(type,pin1);};function HidePinLabel(type,pin_for_hiding){if(pin_for_hiding.hide_label_timer){window.clearTimeout(pin_for_hiding.hide_label_timer);pin_for_hiding.hide_label_timer=null;}if(pin_for_hiding.show_label_timer){window.clearTimeout(pin_for_hiding.show_label_timer);pin_for_hiding.hide_label_timer=null;}pin_for_hiding.HideFloatingLabel();pin_for_hiding.sticky=false;if(type=='stop'){last_visible_label_stop_id="";if(pin_for_hiding.stop_id==last_sticky_stop_id)last_sticky_stop_id="";}else{last_visible_vehicle_id="";if(pin_for_hiding.vehicle_id==last_sticky_vehicle_id)last_sticky_vehicle_id="";}};function ShowPinLabel(type,pin_for_showing){if(pin_for_showing.hide_label_timer){window.clearTimeout(pin_for_showing.hide_label_timer);pin_for_showing.hide_label_timer=null;}if(pin_for_showing.show_label_timer){window.clearTimeout(pin_for_showing.show_label_timer);pin_for_showing.show_label_timer=null;}if(!pin_for_showing.sticky&&pin_for_showing.FloatLabelVisible())return;if(type=='stop'){if(pin_for_showing.stop_id!=last_visible_label_stop_id&&last_sticky_stop_id!=last_visible_label_stop_id)ClearLabel(type,last_visible_label_stop_id);last_visible_label_stop_id=pin_for_showing.stop_id;UpdateStopContent(pin_for_showing.point_object);}else{if(pin_for_showing.vehicle_id!=last_visible_label_vehicle_id&&last_sticky_vehicle_id!=last_visible_label_vehicle_id)ClearLabel(type,last_visible_label_vehicle_id);last_visible_label_vehicle_id=pin_for_showing.vehicle_id;UpdateVehicleContent(pin_for_showing);}pin_for_showing.ShowFloatingLabel();};function ShowPinLabelFunctionPointer(type,pin_to_show){return(function(){ShowPinLabel(type,pin_to_show);});};function HidePinLabelFunctionPointer(type,pin_to_hide){return(function(){HidePinLabel(type,pin_to_hide);});};function UpdateArrivals(route_markers){for(u=0;u<vehicles.length;u++)vehicles[u].arrivals=[];for(u=0;u<stops.length;u++)stops[u].arrivals=[];var veh=null;var stop=null;for(u=0;u<route_markers.length;u++){var aroute=route_markers[u];var arouteObj=FindRouteObject(aroute.getAttribute("id"));var xml_arrivals=aroute.getElementsByTagName("arrival");for(y=0;y<xml_arrivals.length;y++){var veh_id=xml_arrivals[y].getAttribute("vehicle");var stop_id=xml_arrivals[y].getAttribute("stop");var direction=xml_arrivals[y].getAttribute("dir");var time=parseInt(xml_arrivals[y].getAttribute("time"));if(!veh||veh.vehicle_id!=veh_id)veh=FindVehicleObject(veh_id);if(!stop||stop.stop_id!=stop_id)stop=FindStopObject(stop_id);if(!veh|| !stop)continue;var arrp=new Object();arrp.vehicle=veh;arrp.time=time;arrp.route=arouteObj;if(direction)arrp.direction=direction;arrp.stop=stop;veh.arrivals.push(arrp);stop.arrivals.push(arrp);}}if(last_sticky_stop_id!=""){var new_html=UpdateStopContent_GetArrivalTableHTML(FindStopObject(last_sticky_stop_id));var html_object=document.getElementById("arrival_table_"+last_sticky_stop_id);if(html_object!=null&&html_object.innerHTML!=new_html)html_object.innerHTML=new_html;}if(last_visible_label_stop_id!=""&&last_visible_label_stop_id!=last_sticky_stop_id){var new_html=UpdateStopContent_GetArrivalTableHTML(FindStopObject(last_visible_label_stop_id));var html_object=document.getElementById("arrival_table_"+last_visible_label_stop_id);if(html_object!=null&&html_object.innerHTML!=new_html)html_object.innerHTML=new_html;}};function ZoomOnVehicles(){var coords=[];for(i=0;i<vehicles.length;i++)coords.push(vehicles[i].position);var remove_outliers_from_route=true;SetGoogleZoom(coords,remove_outliers_from_route);};function GetIconImage(speed,heading,door,prefix){if(door){return(door_open_image);}else{if(speed<speed_cutoff){if(current_zoom_level>=zoom_limit_vehicle_icons)return(vehicle_image_dir+prefix+heading.toLowerCase()+"_1.gif");else return(small_vehicle_image_stopped);}else{if(current_zoom_level>=zoom_limit_vehicle_icons)return(vehicle_image_dir+prefix+heading.toLowerCase()+"_2.gif");else return(small_vehicle_image_moving);}}};function ToggleLabels(){for(g=0;g<vehicles.length;g++){if(vehicle_labels_visible)map.removeLabel(vehicles[g].label);else map.addLabel(vehicles[g].label);}var button=document.getElementById("LabelsButton");if(vehicle_labels_visible)button.innerHTML="Show Labels";else button.innerHTML="Hide Labels";vehicle_labels_visible= !vehicle_labels_visible;};function ToggleTraffic(){var button=document.getElementById("TrafficButton");if(traffic_visible){button.innerHTML="Show Traffic";traffic_overlay.hide();}else{button.innerHTML="Hide Traffic";traffic_overlay.show();}traffic_visible= !traffic_visible;};function ToggleControls(){content_buttons_collapsed= !content_buttons_collapsed;Content_DrawNavigationButtons();};function HideControls(){content_buttons_collapsed=true;Content_DrawNavigationButtons();};function Content_MapTimeout(){var html="<table>"+"<tr>"+"<td align='center'>"+"<div class='displaybox_default'>"+"<table>"+"<tr>"+"<td align='center' class='content_displaybox_title'>"+"Are you still there?"+"</td>"+"</tr>"+"<tr>"+"<td style='padding:10px;'>If you're still using the map, click the OK button to let us know.</td>"+"</tr>"+"</table>"+"</div>"+"</td>"+"</tr>"+"<tr>"+"<td align='center'>"+"<div style='width:60px'>"+"<div class='content_small_button' onclick='Content_MapTimeout_Resume();'>OK</div>"+"</div>"+"</td>"+"</tr>"+"</table>";Content_MessageBox(html);};function Content_MapTimeout_Resume(){Content_MessageBox_Hide();ResumeUpdates();};function Content_StartMessage(){var html="<table>"+"<tr>"+"<td align='center'>"+"<div class='displaybox_start'>"+"<table>"+"<tr>"+"<td align='center' class='content_start_title'>"+"Welcome."+"</td>"+"</tr>"+"<tr>"+"<td style='padding:10px;'>";if(is_public)html+="Select a route on the right to see buses.";else html+="Use the pane on the right to turn routes and vehicles on or off.";html+="</td>"+"</tr>"+"</table>"+"</div>"+"</td>"+"</tr>"+"<tr>"+"<td align='center'>"+"<div style='width:60px'>"+"<div class='content_small_button' onclick='Content_MessageBox_Hide();'>OK</div>"+"</div>"+"</td>"+"</tr>"+"</table>";Content_MessageBox(html);};function Content_MessageBox(message_html){var content_parent=document.getElementById("message_parent");content_parent.className="content_parent_message";var pane=document.getElementById("message");pane.innerHTML=message_html;pane.className="content_message";var pane_w=pane.offsetWidth;var pane_h=pane.offsetHeight;var size=BrowserSize();var browser_w=size[0];var browser_h=size[1];var left=(browser_w/2)-(pane_w/2);var top=(browser_h/2)-(pane_h/2);content_parent.style.top=top+"px";content_parent.style.left=left+"px";};function Content_MessageBox_Hide(){var content_parent=document.getElementById("message_parent");if(content_parent.className!="content_parent_message")return;content_parent.style.top="";content_parent.style.left="";content_parent.className="content_message_hidden";var pane=document.getElementById("message");pane.innerHTML="";pane.className="";pane.className="message_hidden";};function Content_DrawNavigationButtons(){last_user_activity=new Date();if(trip_planner_on){TripPlanner_Finished();trip_planner_on=false;}content_buttons_visible=true;var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_navigation_buttons";var pane=document.getElementById("content");var html="";if(!content_buttons_collapsed){html="<div onclick='ToggleControls();' class='content_map_collapse_controls'>Hide Controls</div>"+"<div onclick='Content_DrawRoutesBox();' class='content_map_button'>Routes</div>"+"<div onclick='Content_DrawLegend();' class='content_map_button'>Legend</div>"+((is_public)?"":"<div onclick='Content_FindVehicle();' class='content_map_button'>Find Vehicle</div>")+"<div onclick='Content_FindYourStop()' class='content_map_button'>Find "+((is_public)?"Your ":"")+"Stop</div>";if(trip_planner_enabled)html+="<div onclick='Content_TripPlanner()' class='content_map_button'>Trip Planner</div>";if(traffic_overlays_enabled){html+="<div onclick='ToggleTraffic()' id='TrafficButton' class='content_map_button'>"+((traffic_visible)?"Hide Traffic":"Show Traffic")+"</div>";}if(allow_user_to_toggle_vehicle_labels){html+="<div onclick='ToggleLabels()' id='LabelsButton' class='content_map_button'>"+((vehicle_labels_visible)?"Hide Labels":"Show Labels")+"</div>";}}else html="<div onclick='ToggleControls();' class='content_map_collapse_controls'>Show Controls</div>";pane.innerHTML=html;if(controls_on)content_parent.style.visibility="visible";else content_parent.style.visibility="hidden";};function Content_DrawRoutesBox(){last_user_activity=new Date();if(!content_buttons_visible){Content_DrawNavigationButtons();return;}content_buttons_visible=false;var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_routes";var pane=document.getElementById("content");pane.className="content_routes";var html="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='Content_DrawNavigationButtons()'><img border='0' src='/images/x-big.gif'></a>"+"</div>"+"<table style='margin:10px;'>"+"<tr><td colspan='2' align='center' valign='top' style='height:30px'>"+"<span class='routes_box_title'>"+((is_public)?"Routes":"Routes &amp; Vehicles")+"</span><br>"+((is_public)?"<br><span class='routes_box_title_instructions'>Click boxes to show routes</span><br>":"")+"<br>"+"</td></tr>";if(!is_public){html+="<tr>"+"<td valign='top' height='35' width='20'>"+"<div class='RouteColorBlock' id='all_vehicles_box' "+"onclick='ToggleAllVehicles(true);' "+"style='background-color:"+((all_vehicles_on)?all_vehicles_on_box_color:"inherit")+"' />"+"</td>"+"<td valign='top' height='35' width='20'>"+"<a id='all_vehicles_text' class='RouteLink' "+"style='color:"+((all_vehicles_on)?route_text_color_when_on:route_text_color_when_off)+"' "+"href='#' onclick='ToggleAllVehicles(true);'>"+"<span style='white-space:nowrap'>ALL VEHICLES</span>"+"</a>"+"</td>"+"</tr>";}var contains_in_service=false;var contains_out_service=false;for(w=0;w<routes.length;w++){var route=routes[w];var has_vehicles=false;for(x=0;x<vehicles.length;x++){if(vehicles[x].route==route.stop_set_id)has_vehicles=true;}route.currently_in_service=(has_vehicles|| !route.out_of_service);if(route.currently_in_service)contains_in_service=true;else contains_out_service=true;}var show_service_headers=(contains_in_service&&contains_out_service&&is_public);var loop_count=1;if(show_service_headers)loop_count++;for(loop=0;loop<loop_count;loop++){if(show_service_headers){html+=""+"<tr><td align='center' colspan='2'><u><i style='font-size:10pt;'>"+((loop==0)?"In Service Today":"<br>Out of Service Today")+"</i></u></td></tr>";}for(w=0;w<routes.length;w++){var route=routes[w];var sid=route.stop_set_id;var render=true;if(show_service_headers&&loop==0&& !route.currently_in_service)render=false;if(show_service_headers&&loop==1&&route.currently_in_service)render=false;if(render){html+="<tr><td width='20'><div class='RouteColorBlock' id='route_color_box_"+sid+"' onclick='RouteClick("+sid+",false);'"+" style='background-color:"+((route.visible)?route.color:"inherit")+"'/></td>"+"<td><a id='route_text_"+sid+"' class='RouteLink' "+" style='color:"+((route.visible)?route_text_color_when_on:route_text_color_when_off)+"' "+"href='#' onclick='RouteClick("+sid+",false);'>"+((route.name.length<max_route_name_length_nowrap)?"<span style='white-space:nowrap'>":"")+route.name+((route.name.length<max_route_name_length_nowrap)?"</span>":"")+"</a></td></tr>";}}}html+="</table>";pane.innerHTML=html;};function ToggleAllVehicles(restore_previous_routes){all_vehicles_on= !all_vehicles_on;var avo_block=document.getElementById("all_vehicles_box");var avo_text=document.getElementById("all_vehicles_text");if(avo_block)avo_block.style.backgroundColor=(all_vehicles_on)?all_vehicles_on_box_color:"inherit";if(avo_text)avo_text.style.color=(all_vehicles_on)?route_text_color_when_on:route_text_color_when_off;ignore_all_vehicles_toggle_at_route_click=true;if(all_vehicles_on){selected_route_before_all_vehicles=[];while(selected_routes.length>0){selected_route_before_all_vehicles.push(selected_routes[0]);RouteClick(selected_routes[0],false,"");}stop_updating=false;rezoom=true;RequestUpdate();}else{if(restore_previous_routes){rezoom=false;for(iter=0;iter<selected_route_before_all_vehicles.length;iter++)RouteClick(selected_route_before_all_vehicles[iter],false,"");selected_route_before_all_vehicles=[];RequestUpdate();}}ignore_all_vehicles_toggle_at_route_click=false;};function Content_DrawLegend(){if(!content_buttons_visible){Content_DrawNavigationButtons();return;}content_buttons_visible=false;var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_legend";var content=document.getElementById("content");content.className="content_legend";var html="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='Content_DrawNavigationButtons()'><img border='0' src='/images/x-big.gif'></a>"+"</div>"+"<center>"+"<span style='font-size:10pt; font-weight:bold'><u>Legend</u></span>"+"<table class='legend_table' style='margin-top:4px;'>"+"<tr>"+"<td align='center'><nowrap>"+"<img style='vertical-align:middle' src='/images/vehicle_label_sample.gif'>"+"</nowrap></td>";if(domain=="dtdash.com")html+="<td align='left'>Vehicle Number</td>";else html+="<td align='left'>Bus Number</td>";html+="</tr>"+"<tr>"+"<td NOWRAP>"+"<img style='vertical-align:middle' src='/vehicle_icons/red_dot.gif'>&nbsp;<img style='vertical-align:middle' src='/vehicle_icons/e_1.gif'>&nbsp;";if(domain!="dtdash.com")html+="<img style='vertical-align:middle' src='/vehicle_icons/bus_e_1.gif'>";html+="</td>"+"<td align='left'>";if(domain=="dtdash.com")html+="Stopped DASH Bus";else html+="Stopped Bus";html+="</td>"+"</tr>"+"<tr>"+"<td NOWRAP>"+"<img style='vertical-align:middle' src='/vehicle_icons/green_dot.gif'>&nbsp;<img style='vertical-align:middle' src='/vehicle_icons/e_2.gif'>&nbsp;";if(domain!="dtdash.com")html+="<img style='vertical-align:middle' src='/vehicle_icons/bus_e_2.gif'>";html+="</td>"+"<td align='left'>";if(domain=="dtdash.com")html+="Moving DASH Bus";else html+="Moving Bus";html+="</td>"+"</tr>"+"<tr>"+"<td align='center'>"+"<img style='vertical-align:middle' src='/stop_icons/minimarker.gif'>"+"</td>";if(domain=="dtdash.com")html+="<td align='left'>DASH Downtown<br/> Bus Stops</td>";else html+="<td align='left'>Bus Stops for this Agency</td>";html+="</tr>"+"<tr>"+"<td align='center'>"+"<img style='vertical-align:middle' src='/images/other_transit.png'>"+"</td>"+"<td align='left'>Other Transit Agency<br/> Bus Stops</td>"+"</tr>"+"<tr><td colspan='2'><HR></td></tr>"+"<tr><td colspan='2'><center><span style='font-size:10pt; font-weight:bold'><u>Traffic Conditions</u></span></center></td></tr>"+"<tr>"+"<td align='center'>"+"<img style='vertical-align:middle' src='/images/good_traffic.png'>"+"</td>"+"<td align='left' NOWRAP>More than 50 mph</td>"+"</tr>"+"<tr>"+"<td align='center'>"+"<img style='vertical-align:middle' src='/images/medium_traffic.png'>"+"</td>"+"<td align='left' NOWRAP>25 - 50 mph</td>"+"</tr>"+"<tr>"+"<td align='center'>"+"<img style='vertical-align:middle' src='/images/bad_traffic.png'>"+"</td>"+"<td align='left' NOWRAP>Less than 25 mph</td>"+"</tr>";html+="</table>"+"</center>";content.innerHTML=html;};function Content_DrawOptions(){if(!content_buttons_visible){Content_DrawNavigationButtons();return;}content_buttons_visible=false;var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_legend";var content=document.getElementById("content");content.className="content_legend";var html="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='Content_DrawNavigationButtons()'><img border='0' src='/images/x-big.gif'></a>"+"</div>"+"<center>"+"<span style='font-size:10pt; font-weight:bold'><u>Legend</u></span>"+"<table class='legend_table' style='margin-top:4px;'>"+"<tr>"+"<td align='center'>"+"<img style='vertical-align:middle' src='/images/vehicle_label_sample.gif'>"+"</td>"+"<td align='left'>Vehicle Number</td>"+"</tr>"+"<tr>"+"<td>"+"<img style='vertical-align:middle' src='/vehicle_icons/red_dot.gif'>&nbsp;<img style='vertical-align:middle' src='/vehicle_icons/e_1.gif'>&nbsp;<img style='vertical-align:middle' src='/vehicle_icons/bus_e_1.gif'>"+"</td>"+"<td align='left'>"+"Stopped Vehicle"+"</td>"+"</tr>"+"<tr>"+"<td>"+"<img style='vertical-align:middle' src='/vehicle_icons/green_dot.gif'>&nbsp;<img style='vertical-align:middle' src='/vehicle_icons/e_2.gif'>&nbsp;<img style='vertical-align:middle' src='/vehicle_icons/bus_e_2.gif'>"+"</td>"+"<td align='left'>Moving Vehicle</td>"+"</tr>"+"<tr>"+"<td align='center'>"+"<img style='vertical-align:middle' src='/stop_icons/stop_sign_medium.gif'>"+"</td>"+"<td align='left'>Bus Stop</td>"+"</tr>"+"<tr>"+"<td colspan='2' align='center'>"+"<br>Bus Route<br>Direction of Travel<br><img src='/images/route_path_sample.gif'>"+"</td>"+"</tr>"+"</table>"+"</center>";content.innerHTML=html;};var trip_planner_on=false;var trip_planner_area="";var trip_planner_stop1="";var trip_planner_stop2="";var trip_planner_stop_list_width="";var trip_planner_routes_prior=null;function Content_TripPlanner(dont_toggle){if(!content_buttons_visible&& !dont_toggle){trip_planner_on=false;Content_DrawNavigationButtons();return;}trip_planner_on=true;content_buttons_visible=false;var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_trip_planner";var content=document.getElementById("content");content.className="content_trip_planner";var html="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='Content_DrawNavigationButtons()'><img border='0' src='/images/x-big.gif'></a>"+"</div>"+"<center>"+"<table class='trip_planner_table' style='margin-top:4px;'>"+"<tr>"+"<td align='center' colspan='2'>"+"<b>Choose a stop you "+((trip_planner_stop1!="")?"want to go to":"want to depart from")+" below or on the map...</b>"+"</td>"+"</tr>"+"<tr>"+"<td>"+"<select id='list_trip_planner_areas' size='15' onchange='Content_TripPlanner_AreaChanged();'>"+"<option value='-1'";if(!trip_planner_area)html+="selected";html+=">[All Areas]</option>";for(t=0;t<local_areas.length;t++){area=local_areas[t];html+="<option value='"+area.stop_set_id+"'";if(area==trip_planner_area)html+=" selected";html+=">"+area.name+"</option>";}html+="</select>"+"</td>"+"<td>"+"<select id='list_trip_planner_stops' size='15' onchange='Content_TripPlanner_StopChanged();'";if(trip_planner_stop_list_width!="")html+=" style='width:"+trip_planner_stop_list_width+"'";html+=">";trip_planner_visible_stops=[];for(y=0;y<stops.length;y++){if(trip_planner_area){if(!trip_planner_area.bounds.containsLatLng(stops[y].location))continue;}trip_planner_visible_stops.push(stops[y]);}var sorted=trip_planner_visible_stops.sort(SortByName);for(q=0;q<sorted.length;q++){html+="<option value='"+sorted[q].stop_id+"'>"+sorted[q].name+"</option>";}html+="</select>"+"</td>"+"</tr>"+"<tr>"+"<td class='trip_planner_list_labels'>"+"Areas"+"</td>"+"<td class='trip_planner_list_labels'>"+"Stops"+"</td>"+"</tr>"+"<tr>"+"<td align='center' colspan='2'>";if(trip_planner_area)html+="Stops in the <b>"+trip_planner_area.name+"</b> area only are shown.";else html+="All stops on all routes are shown. Choose an area to filter stops.";html+=""+"</td>"+"</tr>";if(trip_planner_stop1!=""){html+=""+"<tr>"+"<td align='center' colspan='2'>"+"<br><span class='trip_planner_list_labels'>Departing from:<BR></span>"+"<div class='trip_planner_departing_stop'>"+FindStopObject(trip_planner_stop1).name+"<br>"+"<a href='#' class='trip_planner_mini_link' onclick='TripPlanner_CancelDepart();'>change</a>"+"</div>"+"</td>"+"</tr>";}+"</table>"+"</center>";content.innerHTML=html;if(!trip_planner_routes_prior)trip_planner_routes_prior=selected_routes;selected_routes=[];RefreshRoutes(true);if(trip_planner_stop_list_width=="")trip_planner_stop_list_width=document.getElementById("list_trip_planner_stops").offsetWidth+"px";};function SortByName(a,b){var x=a.name.toLowerCase();var y=b.name.toLowerCase();return((x<y)? -1:((x>y)?1:0));};function TripPlanner_CancelDepart(){trip_planner_stop1="";Content_TripPlanner(true);};function Content_TripPlanner_AreaChanged(){var list=document.getElementById("list_trip_planner_areas");var selected=list.options[list.selectedIndex].value;if(selected=="-1")trip_planner_area=null;else trip_planner_area=FindLocalAreaObject(selected);Content_TripPlanner(true);};function Content_TripPlanner_StopChanged(){var list=document.getElementById("list_trip_planner_stops");var selected=list.options[list.selectedIndex].value;var is_final=(trip_planner_stop1!="");if(!is_final){trip_planner_stop1=selected;Content_TripPlanner(true);}else{trip_planner_stop2=selected;TripPlanner_ServerCalculate();}};function TripPlanner_ServerCalculate(){var load_url=xml_base_url+"?mode=tp_calculate&start="+trip_planner_stop1+"&stop="+trip_planner_stop2;RequestXML(load_url,TripPlanner_ServerCalculate_Reply);};function TripPlanner_ServerCalculate_Reply(){if(!xml_request||(xml_request.readyState!=4)||(xml_request.status!=200))return;var oPath=new Object();var path_xml=xml_request.responseXML.documentElement;var valid=path_xml.getAttribute("valid");if(valid&&valid=="0"){TripPlanner_DisplayPath(null);return;}var steps_xml=path_xml.getElementsByTagName("step");oPath.distance=path_xml.getAttribute("distance");oPath.steps=[];oPath.visible_stops=[];oPath.visible_lines=[];oPath.zoom_array=[];var step_count=1;for(r=0;r<steps_xml.length;r++){var step=steps_xml[r];oStep=new Object();oStep.start=FindStopObject(step.getAttribute("start"));oStep.end=FindStopObject(step.getAttribute("end"));oStep.type=step.getAttribute("type");if(oStep.type=="Transfer")oStep.route=FindRouteObject(step.getAttribute("route"));oStep.distance=step.getAttribute("distance");var points=[];var points_xml=step.getElementsByTagName("point");for(t=0;t<points_xml.length;t++){var ll=new GLatLng(points_xml[t].getAttribute("latitude"),points_xml[t].getAttribute("longitude"));var ll2=new GLatLng(points_xml[t].getAttribute("latitude"),points_xml[t].getAttribute("longitude"));points.push(ll);oPath.zoom_array.push(ll2);}var color=((oStep.route)?oStep.route.color:trip_planner_walking_line_color);oStep.line=GetPolyline(points,color,trip_planner_line_width);oPath.visible_lines.push(oStep.line);oPath.visible_stops.push(oStep.start);if(r==(steps_xml.length-1))oPath.visible_stops.push(oStep.end);oPath.steps.push(oStep);}TripPlanner_DisplayPath(oPath);};function TripPlanner_DisplayPath(path){var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_trip_planner_results";var content=document.getElementById("content");content.className="content_trip_planner_results";var html="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='Content_DrawNavigationButtons()'><img border='0' src='/images/x-big.gif'></a>"+"</div>"+"<center>"+"<table>"+"<tr>"+"<td align='center' class='trip_planner_list_labels'>Suggested Route</td>"+"</tr>";if(path){trip_planner_visible_stops=path.visible_stops;trip_planner_visible_lines=path.visible_lines;html+="<table>";var step_count=1;var curstep=step_count;for(h=0;h<path.steps.length;h++){var step=path.steps[h];var oStep=step;map.addOverlay(step.line);if(oStep.route){var verb=(h==path.steps.length-1)?"Arrive at":"Get off at";html+="<tr>"+"<td class='trip_planner_results_number'>"+(step_count)+".</td>"+"<td>"+"Board <b>"+oStep.route.name+"</b> at <u>"+oStep.start.name+"</u>."+"</td>"+"</tr>";oStep.start.trip_planner_step_number=step_count;ToggleStepNumberLabel(oStep.start,true);step_count++;html+="<tr>"+"<td class='trip_planner_results_number'>"+step_count+".</td>"+"<td>"+verb+" <u>"+oStep.end.name+"</u>"+"</td>"+"</tr>";if(verb=="Arrive at"){oStep.end.trip_planner_step_number=step_count;ToggleStepNumberLabel(oStep.end,true);}}else{html+="<tr>"+"<td class='trip_planner_results_number'>"+step_count+".</td>"+"<td>"+"Walk from <u>"+oStep.start.name+"</u> to <u>"+oStep.end.name+"</u>"+"</td>"+"</tr>";oStep.start.trip_planner_step_number=step_count;ToggleStepNumberLabel(oStep.start,true);step_count++;if(h==(path.steps.length-1)){html+="<tr>"+"<td class='trip_planner_results_number'>"+step_count+".</td>"+"<td>"+"Arrive at <u>"+oStep.end.name+"</u>"+"</td>"+"</tr>";oStep.end.trip_planner_step_number=step_count;ToggleStepNumberLabel(oStep.end,true);}}}html+="</table>";RefreshRoutes(false,true);SetGoogleZoom(path.zoom_array);}else{html+="<tr><td>"+"None found!"+"</tr></td>";}html+="</table>"+"<BR><input type='button' value='Done' class='content_small_button' onclick='TripPlanner_Finished();'>";content.innerHTML=html;};function TripPlanner_Finished(){trip_planner_area=null;trip_planner_stop1="";trip_planner_stop2="";trip_planner_on=false;for(m=0;m<trip_planner_visible_lines.length;m++)map.removeOverlay(trip_planner_visible_lines[m]);trip_planner_visible_lines=[];for(m=0;m<trip_planner_visible_stops.length;m++){var onestop=trip_planner_visible_stops[m];ToggleStepNumberLabel(onestop,false);}trip_planner_visible_stops=[];Content_TripPlanner(false);selected_routes=trip_planner_routes_prior;RefreshRoutes(false);trip_planner_routes_prior=null;};function TripPlanner_SelectStopFromMap(stop_id){var list=document.getElementById("list_trip_planner_stops");for(m=0;m<list.options.length;m++){if(list.options[m].value==stop_id){list.selectedIndex=m;Content_TripPlanner_StopChanged();break;}}ClearLabel('stop',last_sticky_stop_id);ClearLabel('stop',last_visible_label_stop_id);};var findyourstop_route="";function Content_FindYourStop(dont_toggle){if(!dont_toggle){if(!content_buttons_visible){Content_DrawNavigationButtons();return;}content_buttons_visible=false;}var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_findyourstop";var content=document.getElementById("content");content.className="content_findyourstop";var html="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='Content_DrawNavigationButtons()'><img border='0' src='/images/x-big.gif'></a>"+"</div>"+"<span style='font-size:9pt; font-weight:bold'>";if(findyourstop_route=="")html+="Choose a route...";else html+="Choose a stop...";html+="</span>"+"<center>"+"<table class='findyourstop_table' style='margin-top:4px;'>"+"<tr>"+"<td align='center'>"+"<select id='list_findyourstop' size='10' onchange='Content_FindYourStop_IndexChanged();'>";if(findyourstop_route==""){for(r=0;r<routes.length;r++){var routeObj=routes[r];html+="<option value='"+routeObj.stop_set_id+"'>"+routeObj.name+"</option>";}}else{var routeObj=FindRouteObject(findyourstop_route);var sorted=routeObj.stops.sort(SortByName);for(r=0;r<sorted.length;r++){var stopObj=sorted[r];html+="<option value='"+stopObj.stop_id+"'>"+stopObj.name+"</option>";}}html+="</select>"+"</td>"+"</tr>"+"</table>"+"</center>";content.innerHTML=html;};function Content_FindYourStop_IndexChanged(){var list=document.getElementById("list_findyourstop");var selvalue=list.options[list.selectedIndex].value;if(findyourstop_route==""){findyourstop_route=selvalue;Content_FindYourStop(true);}else{if(!IsRouteSelected(findyourstop_route)){selected_routes.push(findyourstop_route);RefreshRoutes(false);}var stopObj=FindStopObject(selvalue);StickyLabelOn('stop',stopObj.pin);map.setCenter(stopObj.location,zoom_level_findyourstop);findyourstop_route="";Content_FindYourStop(false);}};function Content_FindVehicle(){if(!content_buttons_visible){Content_DrawNavigationButtons();return;}content_buttons_visible=false;var content_parent=document.getElementById("content_parent");content_parent.className="content_parent_findyourstop";var content=document.getElementById("content");content.className="content_findyourstop";var html="<div style='position:absolute; top:0px; right:0px; cursor:pointer;'>"+"<a href='#' onclick='Content_DrawNavigationButtons()'><img border='0' src='/images/x-big.gif'></a>"+"</div>"+"<span style='font-size:9pt; font-weight:bold'>"+"Choose a vehicle...."+"</span>"+"<center>"+"<table class='findyourstop_table' style='margin-top:4px;'>"+"<tr>"+"<td align='center'>"+"<select id='list_findyourstop' size='10' onchange='Content_FindVehicle_IndexChanged();'>";for(r=0;r<all_vehicles.length;r++){var vehObj=all_vehicles[r];html+="<option value='"+vehObj.getAttribute("id")+"'>"+vehObj.getAttribute("name")+"</option>";}html+="</select>"+"</td>"+"</tr>"+"</table>"+"</center>";content.innerHTML=html;};function Content_FindVehicle_IndexChanged(){var list=document.getElementById("list_findyourstop");var selvalue=list.options[list.selectedIndex].value;var vObj=FindVehicleObject(selvalue);if(vObj!=null){StickyLabelOn("vehicle",vObj);map.setCenter(vObj.position,zoom_level_findyourstop);}else{selected_routes=[];var selected_veh;for(i=0;i<all_vehicles.length;i++){if(all_vehicles[i].getAttribute("id")==selvalue){selected_veh=all_vehicles[i];break;}}var aRouteObj=FindRouteObject(selected_veh.getAttribute("stop_set_id"));if(aRouteObj!=null)selected_routes.push(selected_veh.getAttribute("stop_set_id"));find_vehicle_id=selected_veh.getAttribute("id");querystring_manual_routes=true;RefreshRoutes(false);}Content_FindVehicle();};function FindStopObject(id){for(i=0;i<stops.length;i++){stop=stops[i];if(stop.stop_id==id)return(stop);}return(null);};function FindStopIndexInRoute(a_route,stop_id){for(b=0;b<a_route.stops.length;b++){if(a_route.stops[b].stop_id==stop_id)return(b);}return(-1);};function FindRouteObject(id){for(i=0;i<routes.length;i++){route=routes[i];if(route.stop_set_id==id)return(route);}};function FindLocalAreaObject(id){for(i=0;i<local_areas.length;i++){var area_obj=local_areas[i];if(area_obj.stop_set_id==id)return(area_obj);}};function IsRouteSelected(selected_id){for(r=0;r<selected_routes.length;r++){if(selected_routes[r]==selected_id)return(true);}return(false);};function FindVehicleIndex(pin_unique_id){for(rz=0;rz<vehicles.length;rz++){pin=vehicles[rz];if(pin.vehicle_id==pin_unique_id)return(rz);}return(-1);};function FindVehicleObject(id){for(i=0;i<vehicles.length;i++){vehicle=vehicles[i];if(vehicle.vehicle_id==id)return(vehicle);}return(null);};function IsStopVisible(given_stop_id){for(b=0;b<visible_stops.length;b++){a_stop_id=visible_stops[b].stop_id;if(a_stop_id==given_stop_id)return(true);}return(false);}