var map=null;
var selector=null;
var overarchingArea=null;
var iconId=null;
function initaliseMap(_1,_2,_3,_4,_5,_6,_7,id){
iconId=id;
if(!DynamicMap.isSupported()){
document.getElementById("mapControlsTable").style.display="none";
document.getElementById("map").innerHTML="<p>The maps are not available.</p><p>Please use the tabs above to access specific travel information.</p>";
}else{
document.getElementById("map").innerHTML="<p>Loading maps. Please wait.</p>";
map=new DynamicMap(document.getElementById("map"),_1,function(){
selector.reset();
},refreshBusFeedIfRequired,function(){
map.refresh(true,"BUS_STOP");
});
if(_4==9&&getCookie("lat")!=null){
map.setCentre(getCookie("lat"),getCookie("lng"),parseInt(getCookie("zoomLevel")));
}else{
map.setCentre(_2,_3,_4);
}
map.addBoundry("WS Boundary.txt");
map.useStandardControls();
map.showProgressControl();
map.restrictToArea(50,-1.5,53,0.25,9);
selector=new SelectAreaControl();
map.addControl(selector);
map.setIsToBeVisibleFn(doFilter);
map.focusOnMarker(id);
map.addMarkerFeed({name:"PARKANDRIDE",urlFn:function(){
return "feed/parkAndRideFeed.xml?";
},icons:[{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"180",minZoom:"2",maxZoom:"17",icon:"images/mapicons/parkandride.gif"}]});
map.addMarkerFeed({name:"AIRPORTS",urlFn:function(){
return "feed/airportFeed.xml?";
},icons:[{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"120",minZoom:"2",maxZoom:"17",icon:"images/mapicons/aeroplane.gif"},{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"250",minZoom:"2",maxZoom:"17",icon:"images/mapicons/aeroplane.gif"}]});
map.addMarkerFeed({name:"TRAINS",urlFn:function(){
return "feed/trainFeed.xml?";
},icons:[{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"240",minZoom:"2",maxZoom:"17",icon:"images/mapicons/railway.gif"}]});
map.addMarkerFeed({name:"CARPARKS",urlFn:function(){
return "feed/carParkFeed.xml?";
},icons:[{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"270",minZoom:"2",maxZoom:"17",icon:"images/mapicons/carpark-grey.gif"},{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"270",minZoom:"2",maxZoom:"17",icon:"images/mapicons/carpark-red.gif"},{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"270",minZoom:"2",maxZoom:"17",icon:"images/mapicons/carpark.gif"}]});
map.addMarkerFeed({name:"LOCAL_AUTHORITY",urlFn:function(){
return "feed/localAuthoritiesFeed.xml?";
},icons:[{iconAnchorWidth:"30",iconAnchorHeight:"15",hasShadow:"false",iconWidth:"23",iconHeight:"42",tooltipSize:"90",minZoom:"2",maxZoom:"17",icon:"images/neighbouringCounty.gif"},{iconAnchorWidth:"30",iconAnchorHeight:"15",hasShadow:"false",iconWidth:"23",iconHeight:"42",tooltipSize:"140",minZoom:"2",maxZoom:"17",icon:"images/neighbouringCounty.gif"},{iconAnchorWidth:"30",iconAnchorHeight:"15",hasShadow:"false",iconWidth:"23",iconHeight:"42",tooltipSize:"80",minZoom:"2",maxZoom:"17",icon:"images/neighbouringCounty.gif"},{iconAnchorWidth:"30",iconAnchorHeight:"15",hasShadow:"false",iconWidth:"23",iconHeight:"42",tooltipSize:"50",minZoom:"2",maxZoom:"17",icon:"images/neighbouringCounty.gif"}]});
if(document.getElementById("routeId")!=null){
map.addMarkerFeed({name:"BUS_STOP",urlFn:getBusFeed,icons:[{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"300",minZoom:"2",maxZoom:"17",icon:"images/mapicons/busCluster.gif"},{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"300",minZoom:"2",maxZoom:"17",icon:"images/mapicons/bus.gif"}]});
}
map.addMarkerFeed({name:"VMS",urlFn:function(){
return "feed/vmsFeed.xml?";
},icons:[{iconWidth:"23",iconHeight:"23",iconAnchorWidth:"11.5",iconAnchorHeight:"11.5",hasShadow:"false",tooltipSize:"240",minZoom:"2",maxZoom:"17",icon:"images/mapicons/vms.gif"}]});
map.addMarkerFeed({name:"TRAFFICEVENTS",urlFn:getTrafficEventFeed,icons:[{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/road-closed-red.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/road-closed-yellow.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/road-closed-green.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/road-closed-grey.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/roadworks-red.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/roadworks-yellow.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/roadworks-green.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/roadworks-grey.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/streetworks-red.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/streetworks-yellow.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/streetworks-green.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/streetworks-grey.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/unplanned-red.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/unplanned-yellow.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/unplanned-green.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/unplanned-grey.gif"},{iconWidth:"23",iconHeight:"42",iconAnchorWidth:"11.5",iconAnchorHeight:"42",tooltipSize:"300",hasShadow:"true",minZoom:"2",maxZoom:"17",icon:"images/mapicons/event-grey.gif"}]});
map.addDistrict({name:"Adur District",url:"Adur.txt"});
map.addDistrict({name:"Arun District",url:"Arun.txt"});
map.addDistrict({name:"Chichester District",url:"Chichester.txt"});
map.addDistrict({name:"Crawley Borough",url:"Crawley.txt"});
map.addDistrict({name:"Horsham District",url:"Horsham.txt"});
map.addDistrict({name:"Mid Sussex District",url:"Mid Sussex.txt"});
map.addDistrict({name:"Worthing Borough",url:"Worthing.txt"});
map.setAirQualityFeed({name:"WS",urlFn:getAirQualityFeed});
refresh(true);
}
}
function refresh(_9,_a){
if(map!=null){
map.refresh(_9,_a);
}
}
function refreshBusFeedIfRequired(){
if(map!=null){
if(overarchingArea===null){
map.refresh(true,"BUS_STOP");
}else{
if(!overarchingArea.containsBounds(map.getBounds())){
map.refresh(true,"BUS_STOP");
}
}
}
}
function resetAreaSelector(){
selector.reset();
}
function isZoomedOut(){
if(map.getZoom()==9){
return true;
}
return false;
}
function centreOnBus(_b){
if(map!=null){
GDownloadUrl("feed/busRouteExtent.xml?busRoute="+_b,function(_c,_d){
if(_d==DataFeed._HTTP_OK){
var _e=GXml.parse(_c);
var _f=_e.documentElement.getElementsByTagName("extent");
var _10=GLatLng.fromUrlValue(_f[0].getAttribute("swLatLng"));
var _11=GLatLng.fromUrlValue(_f[0].getAttribute("neLatLng"));
map.setCentreForBounds(new GLatLngBounds(_10,_11));
refresh(true,"BUS_STOPS");
}
});
}
}
function getTrafficEventFeed(){
var _12=document.getElementById("timescaleValue");
var _13=_12.options[_12.selectedIndex].value;
var url="feed/trafficEventFeed.xml?timescale="+_13;
return url;
}
function getAirQualityFeed(){
var _15=document.getElementById("timescaleValue");
var _16=_15.options[_15.selectedIndex].value;
var url="feed/airQualityFeed.xml?timescale="+_16;
return url;
}
function getBusFeed(){
var url=null;
var _19=document.getElementById("routeId");
if((document.getElementById("busStopButton")!=null)&&(document.getElementById("busStopButton").value=="on")){
var ne=map.getBounds().getNorthEast();
var sw=map.getBounds().getSouthWest();
var _1c=Math.abs(ne.lng()-sw.lng())*0.25;
var _1d=Math.abs(ne.lat()-sw.lat())*0.25;
var _1e=new GLatLng(sw.lat()-_1d,sw.lng()-_1c);
var _1f=new GLatLng(ne.lat()+_1d,ne.lng()+_1c);
overarchingArea=new GLatLngBounds(_1e,_1f);
if(_19!=null&&_19.value=="all"){
url="feed/busFeed.xml?"+"&swLat="+overarchingArea.getSouthWest().lat()+"&swLng="+overarchingArea.getSouthWest().lng()+"&neLat="+overarchingArea.getNorthEast().lat()+"&neLng="+overarchingArea.getNorthEast().lng()+"&zoom="+map.getZoom();
}else{
url="feed/busFeed.xml?id="+iconId+"&busRoute="+_19.value+"&swLat="+overarchingArea.getSouthWest().lat()+"&swLng="+overarchingArea.getSouthWest().lng()+"&neLat="+overarchingArea.getNorthEast().lat()+"&neLng="+overarchingArea.getNorthEast().lng()+"&zoom="+map.getZoom();
}
}else{
url="feed/busFeed.xml?id="+iconId+"&busRoute="+_19.value+"&";
}
return url;
}
function displayBusSelector(_20,e){
var _22=document.getElementById("busStopSelector");
if(_22==null){
return;
}
if(_20){
var _23=0;
var _24=0;
if(!e){
var e=window.event;
}
if(e){
if(e.pageX||e.pageY){
_23=e.pageX;
_24=e.pageY;
}else{
if(e.clientX||e.clientY){
_23=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
_24=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
}
}
_23=_23-100;
_22.style.left=_23+"px";
_22.style.top=_24+"px";
}
document.getElementById("searchResult").innerHTML="";
}
_22.style.display=_20?"block":"none";
}
function doFilter(_25){
if((_25.type=="ROADWORKS")&&(document.getElementById("roadworksMapButton").value=="on")){
return true;
}
if(_25.type=="CONFIRM"&&document.getElementById("confirmMapButton")!=null&&document.getElementById("confirmMapButton").value=="on"){
return true;
}else{
if((_25.type=="INCIDENT")&&(document.getElementById("incidentMapButton").value=="on")){
return true;
}else{
if((_25.type=="EVENT")&&(document.getElementById("eventMapButton").value=="on")){
return true;
}else{
if((_25.type=="BUS_STOP")&&(document.getElementById("busStopButton")!=null)&&(document.getElementById("busStopButton").value=="on")){
return true;
}else{
if((_25.type=="AIRPORT")&&(document.getElementById("airportButton")!=null)&&(document.getElementById("airportButton").value=="on")){
return true;
}else{
if((_25.type=="TRAIN")&&(document.getElementById("trainButton")!=null)&&(document.getElementById("trainButton").value=="on")){
return true;
}else{
if((_25.type=="PARKANDRIDE")&&(document.getElementById("parkAndRideButton")!=null)&&(document.getElementById("parkAndRideButton").value=="on")){
return true;
}else{
if((_25.type=="CAR_PARK")&&(document.getElementById("carParkButton")!=null)&&(document.getElementById("carParkButton").value=="on")){
return true;
}else{
if((_25.type=="VMS")&&(document.getElementById("vmsButton")!=null)&&(document.getElementById("vmsButton").value=="on")){
return true;
}else{
if((_25.type=="LOCAL_AUTHORITY")){
return true;
}
}
}
}
}
}
}
}
}
}
return false;
}
function zoomOut(_26){
if(map!=null){
map.setZoom(parseInt(_26));
}
}
function zoomInTwoLevels(){
if(map!=null){
if(map.getZoom()<16){
map.setZoom(parseInt(map.getZoom())+2);
}else{
if(map.getZoom()==16){
map.setZoom(17);
}
}
}
}
function zoom(lat,lng,_29){
if(map!=null){
map.setCentre(parseFloat(lat),parseFloat(lng),parseInt(_29));
}
}
function saveMapPositionToCookies(){
if(map!=null){
setCookie("lat",map.getCentre().lat());
setCookie("lng",map.getCentre().lng());
setCookie("zoomLevel",map.getZoom());
}
}
function applyCascadingDropdown(_2a,_2b){
var _2c=document.getElementById(_2a);
var _2d=document.getElementById(_2b);
if(_2c&&_2d){
_2c.onchange=function(){
displayOptionItemsByClass(_2d,_2c.value);
};
displayOptionItemsByClass(_2d,_2c.value);
}
}
function displayOptionItemsByClass(_2e,_2f){
if(!_2e.backup){
_2e.backup=_2e.cloneNode(true);
}
var _30=_2e.getElementsByTagName("option");
for(var i=0,_32=_30.length;i<_32;i++){
_2e.removeChild(_30[0]);
}
var _30=_2e.backup.getElementsByTagName("option");
for(var i=0,_32=_30.length;i<_32;i++){
var _33=_30[i].className;
if(_30[i].className==_2f){
_2e.appendChild(_30[i].cloneNode(true));
}
}
var _2e=document.getElementById("routeId");
var _30=_2e.getElementsByTagName("option");
for(var i=0,_32=_30.length;i<_32;i++){
if(_30[i].selected){
_2e.selectedIndex=i;
return;
}
}
}
function applyCascadingDropdowns(){
applyCascadingDropdown("routes","routeId");
}

