function initialize(map_id) {
	if (GBrowserIsCompatible()) {
		
		var map = new GMap2(document.getElementById(map_id));
		var customUI = map.getDefaultUI();
		
		customUI.controls.scalecontrol = false;
		/*customUI.maptypes.normal = false;
		customUI.maptypes.satellite = false;
		customUI.maptypes.hybrid = false;
		customUI.maptypes.physical = false;*/
		
		map.setUI(customUI);
		map.setMapType(G_NORMAL_MAP);
		map.setCenter(new GLatLng(35.515464,-78.333552), 16);
		
		return map;
	}
}

function addMarker(address, map, bounds, infoWindow, iconType) {

	// define the custom icons
	var prayIcon = new GIcon(G_DEFAULT_ICON);
	prayIcon.image = "http://pray.atlanticbt.com/images/i_map-marker.png";
	prayIcon.iconSize = new GSize(32,32);
	prayIcon.shadow = "";
	
	var defaultIcon = new GIcon(G_DEFAULT_ICON);
	defaultIcon.image = "http://pray.atlanticbt.com/images/i_map-pin.png";
	defaultIcon.iconSize = new GSize(48,48);
	defaultIcon.shadow = "";
	
	
	
	var geocoder = new GClientGeocoder(); 
	geocoder.getLatLng(address,
    	function(point) {
			if (!point) {
			  	alert(address + " not found!");
			} else {
				
				if (iconType == "prayIcon") {
					markerOptions = { icon:prayIcon };
				} else {
					markerOptions = { icon:defaultIcon };
				}
				var marker = new GMarker(point, markerOptions);
				if (infoWindow != '') {
					//marker.openInfoWindow(infoWindow);
					GEvent.addListener(marker, 'click', function() { 
						marker.openInfoWindow(infoWindow);
					});
				}
				map.addOverlay(marker);
				bounds.extend(point);
				
				map.setCenter(bounds.getCenter());	
				
				var maxZoom = map.getBoundsZoomLevel(bounds);
				if (maxZoom > 16) {
					maxZoom = 16;
				}
				
				map.setZoom(maxZoom);
					
            }
     	});
	
}

function showLocation(thisAddress, thisTitle, markerType) {
	map = initialize('map_canvas');
	
	//markerType = 'default';
	
	var infoWindow = '<div class="info-window">' + thisTitle + '<br />' + thisAddress + '</div>'
	
	var bounds = new GLatLngBounds();
	addMarker(thisAddress, map, bounds, infoWindow, markerType);
	
	map.setZoom(16);
	map.setCenter(bounds.getCenter());
	
}
