var map;var counter;var cityId;function load(){cityId=1;map=new GMap2(document.getElementById("map"));map.setCenter(new GLatLng(cityLatMapper[cityId],cityLngMapper[cityId]),12);map.addControl(new GLargeMapControl());counter=0;setDestinationDetails();map.openInfoWindow(map.getCenter(),"Click on the map to select your start location.");GEvent.addDomListener(document.getElementById("searchLocButton"),"click",function(){var locName=document.getElementById("searchLocName").value;if(locName=="Area name")alert("Please enter the area name you are searching for and click search");else geoCodeLocName(locName);});GEvent.addDomListener(document.getElementById("resetMap"),"click",function(){resetMap();setDestinationDetails();});GEvent.addDomListener(document.getElementById("cityId"),"change",function(){cityId=this.value;getOfficeList(this.value);});GEvent.addDomListener(document.getElementById("officeId"),"change",function(){var officeId=document.getElementById("officeId");resetMap();setDestinationDetails();});GEvent.addDomListener(document.getElementById("moveToCentre"),"click",moveToCityCenter);GEvent.addListener(map,"click",function(marker,point){if(point){if(counter<1){var tempMarker;var infoWindowHtml;if(counter==0){tempMarker=new GMarker(point,{draggable:true,icon:fromIcon});tempMarker.value="fromLocation";infoWindowHtml="This is your start location";}
map.addOverlay(tempMarker);tempMarker.enableDragging();tempMarker.bindInfoWindow(infoWindowHtml);GEvent.addListener(tempMarker,"dragend",updateLatLngOfMarker);counter++;document.getElementById(tempMarker.value).value=point.lat()+","+point.lng()+","+cityId;getLocationName(point.lat(),point.lng(),tempMarker.value);}else{map.openInfoWindowHtml(point,"You can click and drag the markers to reposition them");}}});}
function updateLatLngOfMarker(){var lat=this.getLatLng().lat();var lng=this.getLatLng().lng();document.getElementById(this.value).value=lat+","+lng+","+cityId;getLocationName(lat,lng,this.value);}
