<!-- map_functions.js -->

var objMap;
var objGeoXml;

function initRidingMap(lngRiding, strLang) {

	////////////////////////////////////////////////////////////////////////////////////////////
	//
	//	Called once the div is created
	//
	////////////////////////////////////////////////////////////////////////////////////////////

	window.status = "attempting to initialize Google Map ...";

	var mapDiv = document.getElementById('map');	// will be a DIV with this ID

	if (!GBrowserIsCompatible()) {

		mapDiv.innerHTML = 'Sorry, your browser isn\'t compatible with Google Maps.';

	} else{

		objMap = new GMap2(mapDiv, {mapTypes: [G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP]});

		objMap.addControl(new GSmallMapControl());
		objMap.addControl(new GMapTypeControl());	//  {mapTypes: [G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP]}
		objMap.addControl(new GOverviewMapControl());

		objGeoXml = new GGeoXml('http://www.punditsguide.ca/inc/make_riding_kml.php?riding=' + lngRiding + '&amp;lang=' + strLang);

		GEvent.addListener(objGeoXml, 'load', function () { objGeoXml.gotoDefaultViewport(objMap); });

		objMap.addOverlay(objGeoXml);

	}

	window.status = "";
}

function init() {

	////////////////////////////////////////////////////////////////////////////////////////////
	//
	//	Called once the page is loaded (see line below: "window.onload = init;")
	//
	////////////////////////////////////////////////////////////////////////////////////////////

	window.status = "attempting to initialize Google Map ...";

	var mapDiv = document.getElementById('map');	// will be a DIV with this ID

	if (!GBrowserIsCompatible()) {

		mapDiv.innerHTML = 'Sorry, your browser isn\'t compatible with Google Maps.';

	} else{

		objMap = new GMap2(mapDiv, {mapTypes: [G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP]});

		objMap.addControl(new GSmallMapControl());
		objMap.addControl(new GMapTypeControl());	//  {mapTypes: [G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP]}
		objMap.addControl(new GOverviewMapControl());

		objGeoXml = new GGeoXml('http://www.punditsguide.ca/inc/make_riding_kml.php?riding=1109&amp;lang=e');

		GEvent.addListener(objGeoXml, 'load',
			function () {
				objGeoXml.gotoDefaultViewport(objMap);
				// objMap.zoomIn();	// zooms in one level
			}
		);

		objMap.addOverlay(objGeoXml);

	}

	window.status = "";

	// return true; 	// do we need this???
}


window.onunload = GUnload;