var map = null;
var geocoder = null;
var address = _cGoogleAddress;

function GLoad() {
	if(!GBrowserIsCompatible()) return;
	
	map = new GMap2(document.getElementById("googleMap"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	
	geocoder = new GClientGeocoder();
	
	showAddress(address);
}

function showAddress(address) {
	if(geocoder) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) return alert(address + " not found");
				
				map.setCenter(point, 16, G_HYBRID_MAP);
				
				var icon = new GIcon();
				
				if(typeof(_sPage) == "undefined") _sPage = "default";
				
				if(_sPage == "contact") {
					icon.image = _sRoot + "images/ico-google-pointer-small.png";
					icon.iconSize = new GSize(11, 15);
					icon.iconAnchor = new GPoint(6, 15);
				} else {
					icon.image = _sRoot + "images/ico-google-pointer.png";
					icon.iconSize = new GSize(21, 30);
					icon.iconAnchor = new GPoint(11, 30);
				}

				var marker = new GMarker(point, icon);
				map.addOverlay(marker);
			}
		);
	}
}

window.onload = GLoad;
window.onunload = GUnload;
