$(document).ready(function(){

		if($('#googlemap').length){
		
		
		lang = 'de';
		$('#googlemap').jmap('init', {
				language: 'en',
				mapType:'map',
				mapZoom: 15,
				mapCenter:[51.2356252, 7.1582268],
				mapEnableType: true,
				mapEnableOverview: true,
				mapEnableScrollZoom: true,
				mapEnableSmoothZoom: true,
				mapEnableGoogleBar: true,
				mapEnableScaleControl: true,
				mapShowjMapsIcon: false,
				mapControl: 'large'
				
		});


		var baseIcon = new GIcon(G_DEFAULT_ICON);
		//baseIcon.image = "../images/garrow.gif";
       // baseIcon.shadow = "../images/shadow.png";
        //baseIcon.iconSize = new GSize(63, 72);
        //baseIcon.shadowSize = new GSize(37, 34);
        //baseIcon.iconAnchor = new GPoint(9, 34);
        //baseIcon.infoWindowAnchor = new GPoint(9, 2);

		$('#googlemap').jmap('AddMarker', {
			'pointLatLng': [51.2356252, 7.1582268],
			'pointHTML': '<strong>PixelProduction</strong><br />Lise-Meitner-Straße 5-9<br />42119 Wuppertal',
			'pointIcon': baseIcon
		});

		$('#submit').click(function(){
			fromAddress = $('#from').val();
			if(fromAddress){
			$('#googlemap').animate({'width': '50%'}, function(){
				$(this).jmap('CheckResize');
			});


			$('#googlemap').jmap('SearchDirections', {
				
				//toAddress: $('#to').val(),'query': $('#query').val(),
				query : 'from:'+ fromAddress +' to:51.2356252, 7.1582268',
				panel:'#directions',
				locale:lang,
				getSteps: true,
				getPolyline: true,
				preserveViewport: false
			}, function(result, options) {
				 $('#directions').html('');

				 var valid = Mapifies.SearchCode(result.getStatus());
				 
				 if (valid.success) {
				   $.each(result.Placemark, function(i, point){
					 $('#googlemap').jmap('AddMarker',{
					   'pointLatLng':[point.Point.coordinates[1], point.Point.coordinates[0]],
					   'pointHTML':point.address
					 });
				   });
				 } else {
				   $('#address').html();
				 }
		   });
			}
		   return false;	
			
		});
		}

});
