
var map = null;
var geocoder = null;

function initializeGMap() {
	if ( GBrowserIsCompatible() ) {
		map = new GMap2(document.getElementById("map"));
		map.setCenter( new GLatLng(11, 11), 10 );
		map.disableScrollWheelZoom();
		map.addControl(new GSmallMapControl());
		geocoder = new GClientGeocoder();
	}
}

function showGMapAddress(address) {
	if (geocoder) {
		geocoder.getLatLng(address, function(point) {
			if (!point) {
				alert(address + " not found " + point);
			} else {
				map.setCenter(point, 5);
			}
		});
	}
}
	
function createGMapMarker(point, html, contextPath) {
	if (map) {
		var icon = new GIcon( G_DEFAULT_ICON, contextPath + "css/images/flag_yellow.png" );
		icon.iconSize = new GSize(16, 27);
		icon.iconAnchor = new GPoint(8, 25);
		icon.shadow = contextPath + "css/images/flag_shadow.png";
		icon.shadowSize = new GSize(22, 26);

		var marker = new GMarker(point, icon);
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
		});
		return marker;
	}
	return null;
}

$(document).ready(function () {
	initializeGMap();
	populateGMap();
});
