	$(function() {
		var map;
		var latlng;
		var dp_con;

		var geocoder = new google.maps.Geocoder();
		geocoder.geocode( { 'address': "Noordereinde 47, 's Graveland, Nederland"}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
				latlng = new google.maps.LatLng(results[0].geometry.location);
				var marker = new google.maps.Marker({
					map: map, 
					position: results[0].geometry.location
				});
			} else {
				var latlng = new google.maps.LatLng(52.2401059, 5.1215876);
			}
		});
		var myOptions = {
			zoom: 12,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		map = new google.maps.Map(document.getElementById("project_visual"), myOptions);
		
		$('#postcode').focusin(function() {
			$(this).val('');
		}).focusout(function() {
			if($(this).val() == '') {
				$(this).val('uw postcode');
			}
		});
		$('#route').submit(function() {
			ps = $.trim($(this).find('#postcode').val());
			ps = ps.replace(' ', '+');
			url = "http://maps.google.nl/maps?f=q&hl=nl&geocode=&q=from:+"+ps+",+The+Netherlands+to:+Noordereinde+47,+'s+Graveland,+Nederland&ie=UTF8&z=11&pw=2";

			var directionsService = new google.maps.DirectionsService();
			var directionsDisplay = new google.maps.DirectionsRenderer();

			directionsDisplay.setMap(map);
			directionsDisplay.setPanel(document.getElementById("directionsPanel"));
			var request = {
				origin: $(this).find('#postcode').val()+", Nederland", 
				destination: "Noordereinde 47, 's Graveland, Nederland",
				travelMode: google.maps.DirectionsTravelMode.DRIVING
			};
			directionsService.route(request, function(response, status) {
				if (status == google.maps.DirectionsStatus.OK) {
					if(jQuery.browser.msie && jQuery.browser.version == 6) {
						window.open( url );
					} else {
						dp_con = $('#directionsPanel').html();
						$('#directionsPanel').empty().css({'overflow':'auto','overflow-x':'hidden !important','overflow-y':'scroll !important'});
						$('#directionsPanel').append('<strong><a href="'+url+'" target="_blank">print route</a>&nbsp;&nbsp;<a href="/contact/" id="tadres">toon adres</a></strong>');
						directionsDisplay.setDirections(response);
					}
				} else {
					$('#postcode').css({'color':'#CC0000'}).delay(1000).animate({'color':'#000000'}, 1000);
				}
			});
			return false;
		});
		
		$('#tadres').live('click', function() {
			$('#directionsPanel').html(dp_con);
		});
	});
