$(document).ready(function() {

	$(function() {
		$('a.lightbox').prettyPhoto({
				animationSpeed: 'normal', /* fast/slow/normal */
				padding: 40, /* padding for each side of the picture */
				opacity: 0.35, /* Value betwee 0 and 1 */
				showTitle: true, /* true/false */
				allowresize: true, /* true/false */
				counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				theme: 'light_rounded'
			});

		$("a[rel^='lightbox']").prettyPhoto({
				animationSpeed: 'normal', /* fast/slow/normal */
				padding: 40, /* padding for each side of the picture */
				opacity: 0.35, /* Value betwee 0 and 1 */
				showTitle: true, /* true/false */
				allowresize: true, /* true/false */
				counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				theme: 'dark_rounded'
			});
		$("a[rel^='flashbox']").prettyPhoto({
				animationSpeed: 'normal', /* fast/slow/normal */
				padding: 40, /* padding for each side of the picture */
				hideflash: true,
				opacity: 0.9, /* Value betwee 0 and 1 */
				showTitle: true, /* true/false */
				allowresize: true, /* true/false */
				counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				theme: 'dark_rounded'
			});

		
	});
	
	

		if($('#googlemap').length){
		
		
		lang = 'de';
		$('#googlemap').jmap('init', {
				language: 'en',
				mapType:'map',
				mapZoom: 13,
				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>W-tec</strong><br />Lise-Meitner-Straße 1-13<br />42119 Wuppertal',
			'pointIcon': baseIcon
		});

		$('#googlemap').jmap('AddMarker', {
			'pointLatLng': [51.243401, 7.192290],
			'pointHTML': '<strong>W-tec</strong><br />Lise-Meitner-Straße 1-13<br />42119 Wuppertal',
			'pointIcon': baseIcon
		});



	
		$('#submit').click(function(){
			fromAddress = $('#from').val();
			toAddress = $('input[@name=to]:checked').val();
			if(fromAddress){


				if (toAddress == 1) {
					tt = '51.2356252, 7.1582268';
				}
				if (toAddress == 2) {
					tt = '51.243401, 7.192290';
				}
				
			$('#googlemap').jmap('SearchDirections', {
				
				//

				//toAddress: $('#to').val(),'query': $('#query').val(),
				query : 'from:'+ fromAddress +' to:'+tt+'',
				panel:'#directions',
				locale:lang,
				getSteps: true,
				getPolyline: true,
				preserveViewport: false
			}, function(result, options) {
				 $('#directions').html('');
				
				 var valid = Mapifies.SearchCode(result.getStatus());
				 
				 if (valid.success) {
					 $(this).jmap('CheckResize');
				   $.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;	
			
		});
		}

		var container = $('div.error');
		if($('#kontakt').length){
			$("#kontakt").validate({
				errorContainer: container,
				errorLabelContainer: $("ul", container),
				wrapper: 'li',
				rules: {
					Name: "required",
					Nachricht: "required",
					Email: {
						required: true,
						email: true
					}
				},
				messages: {
					Name: "Bitte geben Sie Ihren Namen an",
					Nachricht: "Was möchten Sie uns mitteilen",
					Email: "Bitte eine gültige Email-Adresse angeben"
				}
			});
		}

});


