var googleDirections = window.googleDirections = {
	_map: null,
	_geocoder: null,
	_directions: null,
	_location: null,

	show: function( geoLat, geoLong ) {
		if ( !$('#map_canvas').length ) {
			return false;
		}
		if (GBrowserIsCompatible()) {
			var zknIcon=new GIcon(G_DEFAULT_ICON);
			zknIcon.image="/images/icon/map-icon.gif";
			zknIcon.iconSize=new GSize(22,26);
			zknIcon.iconAnchor=new GPoint(-5,22);
			zknIcon.shadowSize=new GSize(0,0);

			map = new GMap2(document.getElementById("map_canvas"));
			map.addControl(new GLargeMapControl());
			this._location = point = new GLatLng(geoLat,geoLong);
			map.setCenter(point, 14);
			map.addOverlay(new GMarker(point, {icon:zknIcon}));
			map.enableDoubleClickZoom();
			this._map = map;
			this._geocoder = new GClientGeocoder();
			this._directions = new GDirections(map, document.getElementById("route"));
		}
	},
	calcRoute: function (address) {
		var directions = this._directions;
		var location = this._location;
		this._geocoder.getLatLng(address + ", Nederland", function(point) {
			if (!point) {
     	  	 	alert('Locatie niet in gevonden');
			} else {
				directions.load ("from: " + point + " to: " + location);
			}
		});
	}
};
(function($){
	$(document).ready(function() {
		$('body').unload(function() {
			GUnload();
		});
	});
})(jQuery);
