$(document).ready(function () { 
	
	/**
	 * Home slider navigation
	 */	
	var xoffset = 215;
	var duration = 500;
	var easing = "easeOutQuad"; 
	var items = $("#scroll_container .content_block_home");
	var margin = parseInt($("#scroll_container").css("marginLeft"));
	var max = 0 - (xoffset * items.length) + (2 * xoffset);
	var interval = 7000;
	
	function showNext() {
		if (margin > max) {
			margin = margin - xoffset;
			$("#scroll_container").animate({marginLeft: margin}, duration, easing);
		}
	}
	
	function showPrev() {
		if (margin < 0) {
			margin = margin + xoffset;
			$("#scroll_container").animate({marginLeft: margin}, duration, easing);
		}
	}
	
	var slider = setInterval(showNext, interval);
	
	// Previous btn
	$("a#prev").click(function () {
		clearTimeout (slider);
		showPrev();
	});	

	// Next btn
	$("a#next").click(function () {
		clearTimeout (slider);
		showNext();
	});	
	
	/**
	 * Action slider navigation
	 */	
	var action_xoffset = 306;
	var action_items = $("#slide_content .slide_content_block");
	var action_margin = parseInt($("#slide_content").css("marginLeft"));
	var action_max = 0 - (action_xoffset * action_items.length) + (2  * action_xoffset);
	
	
	function showNextAction() {
		if (action_margin > action_max) {
			action_margin = action_margin - action_xoffset;
			$("#slide_content").animate({marginLeft: action_margin}, duration, easing);
		}
	}
	
	function showPrevAction() {
		if (action_margin < 0) {
			action_margin = action_margin + action_xoffset;
			$("#slide_content").animate({marginLeft: action_margin}, duration, easing);
		}
	}	
	
	var actionSlider = setInterval(showNextAction, interval);
	
	// Previous btn
	$("div#prev").click(function () {
		clearTimeout (actionSlider);
		showPrevAction();
	});

	// Next btn
	$("div#next").click(function () {
		clearTimeout (actionSlider);
		showNextAction();
	});
	
	/**
	 * Uitklapbanner
	 */
	var banner_height = parseInt($("#banner_item_container").css("height"));
	var banner_max_height = parseInt($(".banner_item").length) * (
								parseInt($(".banner_item").css("height"))  + 
								parseInt($(".banner_item").css("paddingBottom"))
								) - 20; 
	var expanded = 0;
	
	$("a#banner_expand").unbind('click').click(function () {
		
		if (expanded == 0) {	
			$("#banner_item_container").animate({height: banner_max_height}, duration, easing);
			$("a#banner_expand").html('KLIK hier om te sluiten');
			expanded = 1;
		} else {
			
			$("#banner_item_container").animate({height: banner_height}, duration, easing);
			$("a#banner_expand").html("<strong>KLIK hier voor alle opties</strong><br />Overhoff staat voor gemak");
					
			expanded = 0;
		}
		
	});
	
	/**
	 * Hovermenu
	 */
	$(".submenu_item").each( function () {
		
		$(this).mouseenter(function () {
			$(".submenu_label", this).stop().animate(
				{height: 200},
				duration, 
				easing);
		});
		
		$(this).mouseleave(function () {
			$(".submenu_label", this).stop().animate(
				{height: 0},
				duration,
				easing
				);
		});
	});
});
