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



function createMap(){
	if (!theAddress) {
		var theAddress = "29th & Dune Drive, Avalon, NJ 08202";
		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);
				}
			}
		);
	}
}

function showOfficeAddress(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);
					
					var officeAddress = '<b>Sea Isle Realty</b><br>5906 Landis Ave.<br>Sea Isle City, NJ 08243<br>Phone: (609) 263-5301';
					marker.openInfoWindowHtml(officeAddress);
				}
			}
		);
	}
}