function activateMap() {
	var map = new google.maps.Map2(document.getElementById("mp_map"));
	var point = new GLatLng(52.45,5.5);
	map.setCenter(point, 7);

	gdir = new GDirections(map, document.getElementById("directions"));

	map.addControl(new google.maps.LargeMapControl());
	map.addControl(new google.maps.ScaleControl());
	map.addControl(new google.maps.MapTypeControl());
}

function setDirections() {
	setTimeout(function() {
		jQuery('#directions').html('');
		var fromAddress = jQuery('#map_search_address').val();
		gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": 'nl_NL' });
	}, 500);
}


jQuery(function() {
	jQuery('#plan').click(function() {
		jQuery('#directions').html('');
		jQuery('#mp').css('display', 'block');
		jQuery('.main select').fadeOut(1);
		activateMap();
	});
		
	jQuery("#mp .close").click(function() {
		jQuery('#mp').css('display', 'none');
		jQuery('#directions').html('');
		jQuery('.main select').fadeIn(1);
	});
		
	jQuery('#map_search_submit').click(function() {
		jQuery('#directions').html('');
		activateMap();
		setDirections();
	});
	
});