	(function () {
		var directionsService = new google.maps.DirectionsService(),
			directionsDisplay = new google.maps.DirectionsRenderer(),
			createMap = function (start) {
				var travel = {
						origin : (start.coords)? new google.maps.LatLng(start.lat, start.lng) : start.address,
						destination : "Pakhuisplein 42J, Wormer",
						travelMode : google.maps.DirectionsTravelMode.DRIVING
						// Exchanging DRIVING to WALKING above can prove quite amusing :-)
					},
					mapOptions = {
						zoom: 10,
						// Default view:Pakhuisplein 42J, Wormer
						center : new google.maps.LatLng(52.4950087 , 4.7736891),
						mapTypeId: google.maps.MapTypeId.ROADMAP
					};

				map = new google.maps.Map(document.getElementById("map"), mapOptions);
				directionsDisplay.setMap(map);
				directionsDisplay.setPanel(document.getElementById("map-directions"));
				directionsService.route(travel, function(result, status) {
					if (status === google.maps.DirectionsStatus.OK) {
						directionsDisplay.setDirections(result);
					}
				});
			};

			// Check for geolocation support	
			if (navigator.geolocation) {
				navigator.geolocation.getCurrentPosition(function (position) {
						// Success!
						createMap({
							coords : true,
							lat : position.coords.latitude,
							lng : position.coords.longitude
						});
					}, 
					function () {
						// Gelocation fallback: Defaults to Wormer, Netherlands
						createMap({
							coords : false,
							address : "Pakhuisplein 42J, Wormer"
						});
					}
				);
			}
			else {
				// No geolocation fallback: Defaults to Amsterdam, Netherlands
				createMap({
					coords : false,
					address : "Pakhuisplein 42J, Wormer"
				});
			}
	})();


