var map;var counter;var cityId;var markerInfo;function load(){counter=0;markerInfo="<br>Drag the marker to reposition the location";cityId=1;map=new GMap2(document.getElementById("map"));map.setCenter(new GLatLng(cityLatMapper[cityId],cityLngMapper[cityId]),12);map.addControl(new GLargeMapControl());map.enableScrollWheelZoom();setDestinationDetails();map.openInfoWindow(map.getCenter(),helpWindow);GEvent.addDomListener(document.getElementById("resetMap"),"click",function(){initializeMapForCity();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");initializeMapForCity();setDestinationDetails();});GEvent.addDomListener(document.getElementById("moveToCentre"),"click",moveToCityCenter);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);});var tempMarker;var infoWindowHtml;GEvent.bind(map,"click",this,function(marker,point){if(point){if(counter<5){if(counter==0){tempMarker=new GMarker(point,{draggable:true,icon:fromIcon});tempMarker.value="fromLocation";infoWindowHtml="This is your start location.";map.openInfoWindow(map.getCenter(),"Now select upto 4 places en route");}else{tempMarker=new GMarker(point,{draggable:true,icon:enrouteIcon});tempMarker.value="enroute"+counter;infoWindowHtml="This is a location you pass by";}
counter++;map.addOverlay(tempMarker);tempMarker.enableDragging();tempMarker.bindInfoWindow(infoWindowHtml+markerInfo);GEvent.addListener(tempMarker,"dragend",updateLatLngOfMarker);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");}}});}
