// JavaScript Document

/**
 * Google Maps API.
 *
 * @access 	public
 * @link	http://code.google.com/apis/maps/documentation/services.html#Geocoding
 */
var googleMap = function(){
	
	// private variables
	var map = null;
	var geocoder = null;
	
	/**
	 * Initializes the Google Maps API classes.
	 *
	 * @access 	private
	 */
	function initialize() {
	  if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
		geocoder = new GClientGeocoder();					
	  }
	}

	return  {
		/**
		 * Geocode an address, add a marker at that point, and 
		 * open an info window displaying the address.
		 *
		 * @access 	public
		 */
		showAddress: function (address) {				
		  
		  initialize();
		  
		  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(address);
				}
			  }
			);
		  }
		  
		}// end method showAddress
	};

}(); // the parens here cause the anonymous function to execute and return

