$(function() {
	$('#carousel').jcarousel({
		scroll: 1,
		buttonNextHTML: null,
		buttonPrevHTML: null,
		auto: 5,
		wrap: 'last',
		initCallback: function(carousel) {
			$('#tabs li').click(function() {
				carousel.scroll($(this).index() + 1);
			});
			
			// pause autoscrolling if the user moves with the cursor over a tab
			$('#tabs li').hover(function() {
		                carousel.stopAuto();
		            }, function() {
		                carousel.startAuto();
		            });			
			
		    // Pause autoscrolling if the user moves with the cursor over the clip.
		    carousel.clip.hover(function() {
		        carousel.stopAuto();
		    }, function() {
		        carousel.startAuto();
		    });
		},
		itemVisibleInCallback: {
			onAfterAnimation: function(carousel, li, index) {
				$('#tabs li.active').removeClass('active');
				
				$('#tabs li:eq(' + (index - 1) + ')').addClass('active');
			}
		}
	});
});
