var map = null;
var geocoder = new GClientGeocoder();
/* Temporary usage only */

function createMap(){
	if (!theAddress) {
		var theAddress = "3209 New Jersey Avenue, Wildwood, NJ 08260";
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			//map.addControl(new GOverviewMapControl()); 
			//map.setCenter(new GLatLng(37.4419, -122.1419), 16);
			geocoder = new GClientGeocoder();
			showAddress(theAddress);
			//map.setMapType(G_HYBRID_MAP); 
		}
	}
}

function showAddress(address) {
	if (geocoder) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert("Map unable to be generated for " + address + ": Address not found");
					//map.innerHtml = "<p>Map unable to be generated for " + address + ": Address not found</p>"
				} else {
					map.setCenter(point, 15);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					marker.openInfoWindowHtml(address);
				}
			}
		);
	}
}

/* Store Pickup Page Versions */

function createStoreMap(){
	if (!theAddress) {
		var theAddress = "3209 New Jersey Avenue, Wildwood, NJ 08260";
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map"));
			//map.addControl(new GLargeMapControl());
			//map.addControl(new GMapTypeControl());
			//map.addControl(new GOverviewMapControl()); 
			//map.setCenter(new GLatLng(37.4419, -122.1419), 16);
			geocoder = new GClientGeocoder();
			showStoreAddress(theAddress);
			//map.setMapType(G_HYBRID_MAP); 
		}
	}
}

function showStoreAddress(address) {
	if (geocoder) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert("Map unable to be generated for " + address + ": Address not found");
					//map.innerHtml = "<p>Map unable to be generated for " + address + ": Address not found</p>"
				} else {
					map.setCenter(point, 16);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					//marker.openInfoWindowHtml(address);
				}
			}
		);
	}
}