jQuery(function( $ ){
	$("a[href*='burodebrug.nl/index.php']").prop("href", function(i, val){return '#'+this.href.replace(/^.*(\\|\/|\:)/, '')+'_bdb';});
	if(window.location.href.indexOf('#')==-1) {$('.home').addClass('selected');}
	//Onze hoofden
	$('#map li a').mouseover(function(){
		$('#map li a').removeClass('active');
		$('#map li a').parent().find("span").fadeOut(100);
		$(this).addClass('active');
		$(this).parent().find("span").fadeIn(500);
	});

	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'x';

// Scroll initially if there's a hash (#something) in the url 

	$(window).hashchange( function(){
		$.localScroll.hash({
			target: '#content', // Could be a selector or a jQuery object too.
			queue:true,
			duration:500,
			easing: 'easeInOutCirc',
			//onBefore: function(anchor, settings){
			//	$('.contenttext').removeClass('activecontent');
			//},
			onAfter: function(anchor, settings){
				var hash = window.location.hash.substring(1).replace( /_bdb/, '');
				$('li a').removeClass('selected');
				$('.'+hash).addClass('selected');
			//	$(anchor).stop(true).addClass('activecontent', 300);
			}
		});
	});
		
	$(window).hashchange();

	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */ 
	
	$.localScroll({
		target: '#content', // could be a selector or a jQuery object too.
		queue:true,
		duration:1000,
		hash:true,
		easing: 'easeInOutCirc',
		//onBefore:function( e, anchor, $target ){
		//	$('.contenttext').stop(true).removeClass('activecontent', 300);// The 'this' is the settings object, can be modified
		//	$('.contenttexthome').stop(true).removeClass('activecontent', 300);
		//},
		onAfter:function( anchor, settings ){
		//	$(anchor).stop(true).addClass('activecontent', 300);// The 'this' contains the scrolled element (#content)
			var hash = window.location.hash.substring(1).replace( /_bdb/, '');
			$('li a').removeClass('selected');
			$('.'+hash).addClass('selected');
		}
	});
	
	jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
		return this.animate({opacity: 'toggle', height:'toggle'}, speed, easing, callback);
	};
	
	$(".klaptekst").hide();
	$(".klapkop").click(function(){
		$(this).parent().nextAll(".klaptekst:eq(0)").slideFadeToggle().siblings('div.klaptekst:visible').slideFadeToggle();
	});
	
	$('.contenttext').jScrollPane({showArrows: true});
			
	$.validator.setDefaults({
	submitHandler: function() { 
		$('#sendingform').fadeIn();
		$('#mbef4emoduleform_1').ajaxSubmit(function() { 
		   $('#sendingform').fadeOut();
           $('#mbef4emoduleform_1').clearForm();
		   $('#formsucces').fadeIn();
		   return false; 
        });
	}
	});
	
		$("#mbef4emoduleform_1").validate({
		rules: {
			mbef4efbrp__34: {
				required: true,
				minlength: 2
			},
			mbef4efbrp__35: {
				required: true,
				email: true
			},
			mbef4efbrp__32: {
				required: true,
				minlength: 2
			}
		},
		messages: {
			mbef4efbrp__34: "<img src='images/icon_cross.png'>",
			mbef4efbrp__35: "<img src='images/icon_cross.png'>",
			mbef4efbrp__32: "<img src='images/icon_cross.png'>"
		}
	});
	
/*
    var latlng = new google.maps.LatLng(52.379005, 4.871728);
    var myOptions = {
      zoom: 13,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
	
	var contentString = 'Buro de Brug<br>Donker Curtiusstraat 7-325<br>1051 JL Amsterdam <br>Tel: 020 486 66 85';

	var infowindow = new google.maps.InfoWindow({
		content: contentString
	});

	var marker = new google.maps.Marker({
      position: latlng,
      map: map,
      title:"Buro de Brug"
  	});
	google.maps.event.addListener(marker, 'click', function() {
	  infowindow.open(map,marker);
	});
	*/
 	
});
