var headline_count		= 5;
var current_headline	= 0;
var theId = "#tab-nieuws";


function headline_rotate() {
  old_headline = current_headline % headline_count;
  new_headline = ++current_headline % headline_count;
  
  // verwijder class + afbeelding
  $(".featured ").find("li.active").removeClass("active");
  
  // voeg class en afbeelding weer toe
  $(".featured li:eq("+new_headline+")").addClass("active");
  
}


$(document).ready(function(){
	// CH JB UITGEZET
	//$(".panel:last-child").css("margin-bottom", "0");

	// labels in inputvelden tonen
	$("input").labelify({
	  text: "label",
	  labelledClass: "labelHighlight"
	});

	// functionaliteit voor flexblokken
	$("#flexblokken div.block").hover(
		function() {$(this).find(".text").animate({	top: '0'}, 200);},
		function() {$(this).find(".text").animate({	top: '125'}, 500);}
	);

	// iconen voor downloads/bijlages
	$("#attachment").iconsFilesType();

	// start featured slideshow	
	$(".featured li:last-child").css("border-bottom", "none");

	$(".featured li:eq("+current_headline+")").addClass("active");
	// JB z-index toegevoegd + top 
	// $(".featured li").append("<img class='arrow' src='img/featured-arrow-left.png' style='z-index: 1; top: 5px;'/>");
	$(".featured li").append("<img class='arrow' src='img/featured-arrow-left.png'/>");
	headline_interval = setInterval(headline_rotate,5000);


	// mouse-over
	/*
	$(".featured li").hover(function() {
		clearInterval(headline_interval);
		$(this).parent().find("li.active").removeClass("active");
		$(this).addClass("active");
		current_headline = $(this).prevAll().length;
	}, function() {
		headline_interval = setInterval(headline_rotate,5000);
		headline_rotate;
	});
*/
	// klik op tabs + start slideshow
	//CH VERWIJDERD
	//$(".featured li").bind('click', function(event){
	$(".featured li").hover(function() {
			clearInterval(headline_interval);
			$(this).parent().find("li.active").removeClass('active');
			$(this).addClass('active');
			theId = "#"+$(this).attr('id');
//			current_headline = 0;
			current_headline = $(this).prevAll().length;
			$(".featured li"+theId+" li:eq("+current_headline+")").addClass("active");
			headline_interval = setInterval(headline_rotate,5000);
			headline_rotate;
			event.preventDefault();
	});
	
	$(".featured li").bind('click', function(event){
		event.stopPropagation();
	})

});
