$(document).ready(function(){
	// boeken formulier
	$("#nextstep").show ();
	$("#paststep").show ();
	
	$("#nextstep").click(function() {
		$("#stap1").hide();
		$("#stap2").show();
		var currentActive = $("ul#boeken-menu .active");
		$(currentActive).next("#boeken-menu li").addClass("active");
		$(currentActive).removeClass("active");
	});
	
	$("#paststep").click(function() {
		$("#stap2").hide();
		$("#stap1").show();
		var currentActive = $("ul#boeken-menu .active");
	
		$(currentActive).prev("#boeken-menu li").addClass("active");
		
		$(currentActive).removeClass("active");
	});
	
	$("#paststep2").click(function() {
		$("#stap2").show();
		$("#stap3").hide();
		var currentActive = $("ul#boeken-menu .active");
	
		$(currentActive).prev("#boeken-menu li").addClass("active");
		
		$(currentActive).removeClass("active");
	});
	
	// validate boeken form
	$("#boeken").validate({
		errorContainer: $("div.error"),
		invalidHandler: function(e, validator) {
			$("#stap2").hide();
			$("#stap1").show();
			var currentActive = $("ul#boeken-menu .active");
			$(currentActive).prev("#boeken-menu li").addClass("active");
			$(currentActive).removeClass("active");
		}
	});
	
	
	$("#boeken_submit").validate();
	
	
	/*
	$("#boeken").validate({
		invalidHandler: function(e, validator) {
		var errors = validator.numberOfInvalids();
		if (errors) {
			var message = errors == 1
				? 'You missed 1 field. It has been highlighted below'
				: 'You missed ' + errors + ' fields.  They have been highlighted below';
			$("div.error span").html(message);
			$("div.error").show();
		} else {
			$("div.error").hide();
		}
	}
	);*/
	
	
	// initialize tooltip
	var initTooltip = function()
	{
		
		$("a.price").tooltip(
		{
			  position: "bottom right"
			, tooltip: 'a.price .tooltip'
			, // tweak the position
			  offset: [10, 2]
			, // use the "slide" effect
			  effect: 'slide'
		// add dynamic plugin with optional configuration for bottom edge
		}).dynamic({ bottom: { direction: 'down', bounce: true } });
	}
	
	initTooltip();
	
	$("a[rel=external]").each(function(){
			this.target="_blank";
	});
});
