var curr_no = 1;
var timer_no = 1;
var rotate_timer = "";
var jc_timer = 10000;
if(typeof(max_no) == "undefined"){
	alert("Voor de carousel dien je nog een maximaal aantal items in te stellen.");
}
//
function showItem(no){
	if(curr_no!=no){
		resetItems();
		//var current = ($('#slide_afb a.show') ? $('#slide_afb a.show') : $('#slide_afb a:first'));
		//var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#slide_afb a:first') : current.next()) : $('#slide_afb a:first'));
		var current = $("#news_image_"+curr_no);
		var next = $("#news_image_"+no);
		next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
		current.animate({opacity: 0.0}, 1000).removeClass('show');
		$("#news_text_"+no).animate({
			opacity: 'toggle'
		}, 1000, 'linear');
		$("a#ss"+no).addClass("aan");
		curr_no=no;
	}
}
//
function resetItems(){
	$("#news_text_"+curr_no).hide();
	$("a#ss"+curr_no).removeClass("aan");
}
//
function autoRotate(){
	$('#slide_afb a').css({opacity: 0.0});
	$('#slide_afb a.show').css({opacity: 1.0});
	showItem(timer_no);
	timer_no++;
	if(timer_no>max_no){
		timer_no=1;
	}
	rotate_timer=setTimeout("autoRotate()",jc_timer);
}
//
function stopRotate(){
	if(typeof rotate_timer != 'undefined'){
		clearTimeout(rotate_timer);
	}
}
