
//<![CDATA[

var gMap = null;
var gMapMarkerManager = null;
var gMap_Geocoder = new GClientGeocoder();
var gMapLoadInterval = null;
var gMapActivePolylines = new Array();

if (typeof(gMapOption_useMarkerManager) == "undefined") gMapOption_useMarkerManager = false;
if (typeof(gMapOption_hideMarkers) == "undefined") gMapOption_hideMarkers = false;
if (typeof(gMapOption_hideRoutes) == "undefined") gMapOption_hideRoutes = false;

if (typeof(gMap_startLat) == "undefined") gMap_startLat = false;
if (typeof(gMap_startLng) == "undefined") gMap_startLng = false;

function gMap_Init() {
	if (GBrowserIsCompatible()) {
		gMap = new GMap2(document.getElementById("gMap"), {draggableCursor:'crosshair',draggingCursor:'hand'});
		if (gMap) {
			gMap.enableScrollWheelZoom();

			if (gMap_startLat && gMap_startLng) {
				startPoint = new GLatLng(gMap_startLat, gMap_startLng);
				gMap.setCenter(startPoint, gMap_startZoom);
			} else {
				gMap_centreOnAddress("Shrewsbury, UK");
			}

			gMapLoadInterval = setInterval('gMap_Load()', 250);

		} else {
			alert('Unable to initialise Google Map');
		}
	}
}

function gMap_Load() {
	if (gMap.isLoaded()) {
		gMap.addControl(new GMapTypeControl());
		gMap.addControl(new GLargeMapControl());
		gMap.addControl(new GScaleControl());

		if (gMapOption_useMarkerManager) {
			gMapMarkerManager = new MarkerManager(gMap);
		}

		if (!gMapOption_hideMarkers && !gMapOption_hideRoutes) {
			gMap_loadMarkersAndRoutes();
		} else {
			if (!gMapOption_hideMarkers) gMap_loadMarkers();
			if (!gMapOption_hideRoutes) gMap_loadRoutes();
		}

		clearInterval(gMapLoadInterval);
	}
}

function gMap_Wait(ms) {
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); }
	while(curDate-date < ms);
}

window.onload = gMap_Init;
window.onunload = GUnload;

//]]>

