var CORIO = new google.maps.LatLng(50.889145, 5.97652);
var CORIO_ADDRESS = "Corio Center, 6411 Heerlen, The Netherlands";

onSectionLoad.push
(
	function()
	{
		// Corio+Center,Heerlen,Nederland
		if (!$("#route_map").length)
			return;
			
		var mapDiv = document.getElementById("route_map");
		var mapOptions = 
		{
			zoom: 17, 
			center: CORIO, 
			mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(mapDiv, mapOptions);
		var directionsDisplay = new google.maps.DirectionsRenderer();
		directionsDisplay.setMap(map);

		$("#route_input").keyup(function(e)
		{
			if (e.keyCode == 13)
				$("#route_submit").click();
		});
	
		$("#route_submit").click(function(e)
		{
			var directionsService = new google.maps.DirectionsService();
			var request = 
			{
				origin: $("#route_input").val(),
				destination: CORIO_ADDRESS,
				travelMode: google.maps.DirectionsTravelMode.DRIVING
			};
			directionsService.route(request, function (result, status)
			{
				if (status == google.maps.DirectionsStatus.OK)
					directionsDisplay.setDirections(result);
				else
					alert("De route kan niet worden berekend");
			});
		});
	}
);

$(function() { onSectionLoad[onSectionLoad.length - 1](); });

