var Site = {
	start: function() {
		var map = $("map");
		if(map) {
			Site.initMap(map);
		}
	},

	initMap: function(element) {
		if(GBrowserIsCompatible()) {
			Site.map = new GMap2(element);
			Site.geocoder = new GClientGeocoder();
			Site.directions = new GDirections(Site.map, $("directions"));

			var directionsForm = $("directions-form");
			directionsForm.addEvent("submit", function() { 
				Site.setDirections($("from-field").get("value"), $("to-field").get("value"));

				return false;
			});

			var center = new GLatLng(53.194166,5.605675);
			var marker = new GMarker(center);

			Site.map.setCenter(center, 8);
			Site.map.addControl(new GSmallMapControl());
			Site.map.addOverlay(marker);

			marker.openInfoWindowHtml("<strong>Sijtsma Groep</strong><br />Rijksstraatweg 7, 8814 JV Zweins");
		}
	},

	setDirections: function(fromAddress, toAddress) {
		Site.directions.load("from: " + fromAddress + " to: " + toAddress,
			{"locale": "nl"});
    }
}

window.addEvent("domready", function() {
	Site.start();
});
