var schedule;var scheduleSelect=document.getElementById('schedule');var minAfter=240;var maxAfter=1440;var incAfter=10;var after;var afterSelect=document.getElementById('after');var minInterval=15;var maxInterval=120;var incInterval=15;var defaultInterval=45;var interval;var intervalSelect=document.getElementById('interval');var timeFormat;var timeFormatSelect=document.getElementById('timeformat');var mapDiv=document.getElementById('map');var om;var map;var stations;var dirColors;var schedules=[];var scheduleStatus=[];var ss_no=0,ss_fetching=1,ss_ok=2;var noBikesColor='#66ffff';var instructionsDiv=document.getElementById('instructions');var stationIcon=new GIcon();stationIcon.image='station.png';stationIcon.iconSize=new GSize(11,11);stationIcon.iconAnchor=new GPoint(5,5);stationIcon.infoWindowAnchor=new GPoint(3,7);var transferIcon=new GIcon();transferIcon.image='transfer.png';transferIcon.iconSize=new GSize(15,15);transferIcon.iconAnchor=new GPoint(7,7);transferIcon.infoWindowAnchor=new GPoint(6,7);function Setup()
{try
{if(!GBrowserIsCompatible())
{mapDiv.innerHTML='Sorry, your browser is not compatible with Google Maps.';return;}
SetLanguage(LANG_ENGLISH);instructionsDiv.innerHTML=''+_mInstructions+'';om=new OverlayMessage(mapDiv);map=new GMap2(mapDiv,{draggableCursor:'default'});map.addControl(new GLargeMapControl());map.addMapType(WMS_TOPO_MAP);map.addMapType(WMS_DOQ_MAP);map.addControl(new GMapTypeControl());map.addControl(new GScaleControl());map.setCenter(new GLatLng(37.80,-122.20),10);GEvent.addListener(map,'infowindowclose',PopDown);for(var hour=0;hour<=48;++hour)
scheduleStatus[hour]=ss_no;om.Set('Loading...');HttpGet('bart.xml',InitialRequestChecker);}
catch(e)
{GLog.write('Setup:\n'+Props(e));}}
function InitialRequestChecker(request)
{try
{var xmlDoc=request.responseXML.documentElement;var idLookup;var stationElements=xmlDoc.getElementsByTagName('station');stations=[];idLookup=[];for(var i=0;i=25&&dow==1)
return true;if(month==6&&day==4)
return true;if(month==8&&day<=7&&dow==1)
return true;if(month==10&&day>=22&&day<=28&&dow==4)
return true;if(month==11&&day==25)
return true;return false;}
function MakeSelects()
{scheduleSelect[0]=new Option('Weekday','WD');scheduleSelect[1]=new Option('Saturday','SA');scheduleSelect[2]=new Option('Sunday/Holiday','SU');for(var i=0;i=after)
{afterSelect.selectedIndex=i;break;}
for(var i=minInterval,j=0;i<=maxInterval;i+=incInterval,++j)
intervalSelect[j]=new Option(i,i);for(var i=0;i=interval)
{intervalSelect.selectedIndex=i;break;}
timeFormatSelect[0]=new Option('am/pm','t12');timeFormatSelect[1]=new Option('24hr','t24');for(var i=0;imaxAfter)after=maxAfter;interval=parseInt(intervalSelect[intervalSelect.selectedIndex].value);if(intervalmaxInterval)interval=maxInterval;timeFormat=timeFormatSelect[timeFormatSelect.selectedIndex].value;if(timeFormat!='t12'&&timeFormat!='t24')
timeFormat='t24';RePop();}
catch(e)
{GLog.write('ParamsChanged:\n'+Props(e));}}
var lastStation=-1;function PopUp(i)
{try
{var firstHour=Math.floor(after/60);var lastHour=Math.floor((after+interval)/60);for(var hour=firstHour;hour<=lastHour;++hour)
{if(scheduleStatus[hour]==undefined||scheduleStatus[hour]==ss_no)
{FetchHour(hour);map.closeInfoWindow();stations[i].openInfoWindowHtml('Loading...');lastStation=i;return;}
else if(scheduleStatus[hour]==ss_fetching)
{map.closeInfoWindow();stations[i].openInfoWindowHtml('Still loading...');lastStation=i;return;}}
var html;var someAntiBikes=false;var name=stations[i].name;html=''+name+'';if(stations[i].xfer=='y')
html+=' (transfer station)';html+='
';var firstBoundElements=schedules[firstHour][i].getElementsByTagName('bound');for(var j=0;j'+bound+'bound: ';var nTimes=0;for(var hour=firstHour;hour<=lastHour;++hour)
{var thisBoundElements=schedules[hour][i].getElementsByTagName('bound');var timeElements=thisBoundElements[j].getElementsByTagName('time');for(var k=0;k=after&&mins<=after+interval)
{var dir=timeElements[k].getAttribute('dr');var time12=timeElements[k].getAttribute('t12');var time24=timeElements[k].getAttribute('t24');var bikes=timeElements[k].getAttribute('bk');html+=''+(timeFormat=='t24'?time24:time12)+' ';++nTimes;if(nTimes>=8)
{html+='
';nTimes=0;}}}}
html+='
';}
if(someAntiBikes)
html+='Bikes not allowed.';map.closeInfoWindow();stations[i].openInfoWindowHtml(html,{maxWidth:300});lastStation=i;}
catch(e)
{GLog.write('PopUp:\n'+Props(e));}}
function FetchHour(hour)
{scheduleStatus[hour]=ss_fetching;HttpGet('schedule'+hour+'.xml',ScheduleRequestChecker);}
function RePop()
{if(lastStation!=-1)
PopUp(lastStation);}
function PopDown()
{lastStation=-1;}