$(document).ready(function(){
    $('#map').jmap('init', {
				mapType:'hybrid',
				mapCenter:[51.1625092,7.0861769 ],
				mapEnableType: true,
				mapEnableOverview: true,
				mapEnableScrollZoom: false,
				mapEnableSmoothZoom: true,
				mapEnableGoogleBar: false,
				mapEnableScaleControl: true,
				mapShowMapifiesIcon: false
});


var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.image = "./img/garrow.gif";
        //baseIcon.shadow = "http://www.pixelproduction.eu/images/pixelproduction_logo2.gif";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

		jQuery('#map').jmap('AddMarker', {
			'pointLatLng': [51.1625092,7.0861769],
			'pointHTML': '<strong>Robert Thaler</strong><br />Brühler Str. 63<br />42657 Solingen',
			'pointIcon': baseIcon
		
		});
	
 
    $('#submit').click(function(){
        fromAddress = $('#from').val();
		$('#map').jmap('SearchDirections', {
            
			//toAddress: $('#to').val(),'query': $('#query').val(),
			query : 'from:'+ fromAddress +' to:Bruehler Straße 63, 42657 Solingen',
            panel:'#directions',
			locale:'de_DE'
        }, function(result, options) {
             //console.log(result);
			 $('#directions').html('');
			 var valid = Mapifies.SearchCode(result.getStatus());
             if (valid.success) {
               $.each(result.Placemark, function(i, point){
                 $('#map').jmap('AddMarker',{
                   'pointLatLng':[point.Point.coordinates[1], point.Point.coordinates[0]],
                   'pointHTML':point.address
                 });
               });
             } else {
               $('#address').html();
             }
       });
       return false;	
    });
});


