//<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
//<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" type="text/javascript"></script>
function navigation(div, des)
{
    this.directionsDisplay = new google.maps.DirectionsRenderer();
    this.directionsService = new google.maps.DirectionsService();
    this.map;
	this.des;
	this.marker;
	var _o = {
		zoom:15,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		center: new google.maps.LatLng(0, 0),
		disableDefaultUI: true,
		disableDoubleClickZoom: true,
		scrollwheel: false,
		navigationControl: true,
		keyboardShortcuts : false
	  }
	this.map = new google.maps.Map(dojo.byId(div), _o);
	var coder = new google.maps.Geocoder();
	coder.geocode( { 'address': des }, 
		dojo.hitch(this, function(result, stat) {
			if (stat == google.maps.GeocoderStatus.OK) {
				this.des = new google.maps.LatLng(result[0].geometry.location.lat(), result[0].geometry.location.lng());
				this.map.setCenter(this.des);
				this.marker = new google.maps.Marker({
                    position: this.des
				});
				this.marker.setMap(this.map);
				google.maps.event.addListener(this.marker, 'click', dojo.hitch(this, function(){
					this.route(window.prompt('Bitte geben Sie Ihre Adresse ein, um Ihre Anfahrtsroute berechnen zu lassen',''));
				}));
			}
		})
	);
	this.directionsDisplay.setMap(this.map);
  
    this.route = function(from) {
        var _r = {
            origin:from, 
            destination:this.des,
            travelMode: google.maps.DirectionsTravelMode.DRIVING,
			region: 'de'
        };
        this.directionsService.route(_r, dojo.hitch(this,function(result, status) {
            if (status == google.maps.DirectionsStatus.OK) {
				this.marker.setMap(null);
                this.directionsDisplay.setDirections(result);
            }
        }));
    }	
}
