$(function(){

	// Create the carousel
	carousel = $('#spotlight-carousel ul.images').jcarousel({
		scroll: 1,
		auto: 4,
		wrap: "both",
		animation: 1000,
		buttonNextHTML: null,
		buttonPrevHTML: null,
		initCallback: function(carousel){
			// Create the carousel index
			var index_container = $('#spotlight-carousel .index');
			
			$('#spotlight-carousel .jcarousel-item').each(function(index){
				var dot = $(document.createElement('span'))
					.appendTo(index_container)
					.click(function(){
						carousel.options.auto = 0;
						carousel.stopAuto();
						carousel.scroll(index+1);
					});
			});
		},
		itemFirstInCallback: function(obj, domnode, index){
			// Activate the blue dot
			$('#spotlight-carousel .index span').removeClass('active');
			$('#spotlight-carousel .index span').eq(index-1).addClass('active');
		}

	});
	
	$('#spotlight-carousel ul.images img').click(function(){
		carousel.next();
	});
	
	
	
});
