var geocoder = null;

// There is some hogdex/events specific stuff in here
function showAddress(displayaddress) {
	var map = null;
	var geoaddress = displayaddress;

	if (!GBrowserIsCompatible()) return;

	// Remove extra spaces
	displayaddress = displayaddress.replace(/\s+/g, ' ');

	// Google puts the NFB on the wrong John St.
	geoaddress = geoaddress.replace(/150 John {St|Street}/i, 'John and Richmond');

	if (!GBrowserIsCompatible()) return;

	if (map == null) {
		map = new GMap2(document.getElementById('map_canvas'));
	}

	if (geocoder == null) {
		geocoder = new GClientGeocoder();
		geocoder.setBaseCountryCode('CA'); // Canada
	}

	geocoder.getLatLng(
		geoaddress,
		function(point) {
      			if (!point) {
				var obj = document.getElementById('map_canvas');
				obj.className = 'map_error';
				obj.innerHTML = 'Sorry, could not get a map for ' + geoaddress;
			} else {
				map.setCenter(point, 13);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				map.addControl(new GSmallMapControl());
				marker.openInfoWindowHtml(displayaddress);
			}
		}
	);
}

