//********************************************//
//** Cross-Browser function to add an event **//
//** handler to an event-generating element **//
//********************************************//
function t3aAddEvent(element, type, useCapture, fn) {
	if (element.addEventListener) {
		// DOM Level 2 Event Model implementation...
		element.addEventListener(type, fn, useCapture);
		return true;
	} else if (element.attachEvent) {
		// Non-standard IE Hack...
		return element.attachEvent('on' + type, fn);
	} else {
		// Catch-all last resort...
		var fnOnload = element['on' + type];
		if (typeof(fnOnload) == "function") {
			element['on' + type] = function() {
				fnOnload();
				fn();
			}
		} else element['on' + type] = fn;
	}
}


//***************************************************//
//** Initialise the GoogleMap in the specified DIV **//
//***************************************************//
function t3aMapInitialise(divID, clear, lat, lng, zoom) {
	var map = null;
	if (GBrowserIsCompatible()) {
		// Clear the map's contents...
		var el = document.getElementById(divID);
		if (clear) {
			while (el.hasChildNodes()) el.removeChild(el.firstChild);
		}
		// Create the map...
		map = new GMap2(el);
		// Add the map's controls...
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(lat, lng), zoom);
	}
	return map;
}


//*************************************************//
//** Add a marker to the specified map, and      **//
//** centre the map if a zoom level is specified **//
//*************************************************//
function t3aAddMarker(map, lat, lng, caption, zoom) {
	// Create the marker...
	var loc = new GLatLng(lat, lng);
	var marker = new GMarker(loc);
	// Center the marker if a zoom level is specified...
	if (!zoom == null) map.setCenter(loc, zoom);
	// Add the marker to the map...
	map.addOverlay(marker);
	// Add the caption to the InfoWindow...
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(caption);
	});
}

