

$(document).ready(function(){


	//---{ carousel  }---------------------------------------------------------------------------------
	

	
	// totaal aantal berichten in carousel ophalen
	var nL = 0
	$('ul#mycarousel li').each(function(i){
		nL += 1
	});
	$('#carouselTotal').html(nL);
	
	
	
	function mycarousel_initCallback(carousel){
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
	
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});
	
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};
	
	
	
	var nScroll=0
	jQuery('#mycarousel').jcarousel({
		
		auto: 3,
        wrap: "last",
		scroll: 1,
		itemVisibleInCallback: {
			onAfterAnimation: function(carousel, item, idx, state){
				$("#retangleCarousel > .curSlide  > li").removeClass("active");
				
				$('#carouselCount').html(idx);
				if (idx==1){
					nScroll +=1
				}
				if (nScroll==2){
					//stoppen van carousel
					//carousel.stopAuto();
				}
			}
		},
		initCallback: mycarousel_initCallback

	});
	

	//--- achtergrond div toevoegen ---
	$('.jcarousel-container').prepend('<div id="carouselControls"></div>');
	
		
	$('ul#mycarousel li').css({
		'visibility':'visible',
		'height':'auto'
	});
});



