$(function() {
		   
	$("#nieuwsbrief").validate({
		submitHandler: function(form) {
			$("#shownieuwsbriefresult").html("Bezig...");
			var options = {target: "#shownieuwsbriefresult", success: showNieuwsbriefResponse};
			$(form).ajaxSubmit(options);
		}
	});
	
	$("#nieuwsbrief2").validate({
		submitHandler: function(form) {
			$("#shownieuwsbriefresult").html("Bezig...");
			var options = {target: "#shownieuwsbriefresult2", success: showNieuwsbriefResponse2};
			$(form).ajaxSubmit(options);
		}
	});
	function showNieuwsbriefResponse(responseText, statusText)  { 
		if (statusText == "success" && responseText == "Toegevoegd!") {
			$("#nieuwsbrief input, #nieuwsbrief textarea, #nieuwsbrief button").each(function() {
				this.disabled = "true";
			});
		}
	} 
			       
	function showNieuwsbriefResponse2(responseText, statusText)  { 
		if (statusText == "success" && responseText == "Toegevoegd!") {
			$("#nieuwsbrief2 input, #nieuwsbrief2 textarea, #nieuwsbrief2 button").each(function() {
				this.disabled = "true";
			});
		}
	} 
	$(".popup-button").toggle(
		function() {
			$(".popup-arrow").addClass("over");
			$(".popup-button a").text("Sluiten");
			$(".popup").animate({
				height: "263px"
			});
			$(".popup > .content").animate({
				height: "200px"
			});
		},
		function() {
			$(".popup-arrow").removeClass("over");			
			$(".popup-button a").text("Bekijk project");
			$(".popup").animate({
				height: "22px"
			});
			$(".popup > .content").animate({
				height: "0px"
			});
		}
	);
	
	$("#slideshow .desc").hide();
	$("#slideshow").cycle({ 
		fx:				"fade", 
		speed:			1000, 
		timeout:		5000, 
		before:			function(currSlideElement, nextSlideElement, options, forwardFlag) {
			var next = options.nextSlide + 1;
			var titel = $(nextSlideElement).children(".desc").children("h1").text();
			var desc = $(nextSlideElement).children(".desc").children("span").text();
			$(".slideshow .navigator .description").html($(nextSlideElement).children(".desc").html());
			$(".slideshow .counter").text(next + "/" + options.slideCount);
		},
	    next:   		"#button-right", 
    	prev:   		"#button-left" 
	});

	hideFormLabels("#nieuwsbrief");
	
	$(".background").fadeIn(3000);
	
	$("#wrapper > .body").children().hoverIntent(
		function() {
			$(this).children(".inner").children(".content").children(".index").children(".menu").fadeTo(500, 1);
		}, function() {
			$(this).children(".inner").children(".content").children(".index").children(".menu").fadeTo(500, 0.4);
		}
	);
});