var map = null;
var geocoder = null;

function initialize(DOMelement, title, address) {
	if (GBrowserIsCompatible()) {
		if (typeof document.getElementById(DOMelement) !== 'undefined') {
			map = new GMap2(document.getElementById(DOMelement));
			//map.setCenter(new GLatLng(37.4419, -122.1419), 1);
			geocoder = new GClientGeocoder();
			//GEvent.addListener(map, "click", function);
			showAddress(title, address);
			
			setTimeout('map.setZoom(15);', 750);
		}
	}
}

function showAddress(name, address) {
	if (geocoder) {
			geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert(address + " not found");
				} else {
					map.setCenter(point, 13);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					marker.openInfoWindowHtml('<strong>' + name + '</strong> <br />' + 
						address + '<br />' +
						'<a href="http://maps.google.com/maps?daddr=' + address + '">Get Directions</a>'
					);
				}
			}
		);
	}
}
