ppl.coffee = {

	init: function() {
	
		$("#top-coffees").tabs();
		
		startIndex = Math.floor(Math.random() * $("#main-carousel > li").size()) + 1;
		jQuery('#main-carousel').jcarousel({
			start: startIndex,
			scroll: 1,
	        auto: 10,
	        wrap: 'last',
	        buttonNextHTML: null,
	        buttonPrevHTML: null,
	        initCallback: ppl.coffee.mainCarouselCallback,
	        itemFirstInCallback: function(carousel, item, index) {
	        	jQuery('#main-carousel-control a').each(function(){
					$(this).toggleClass('current', (jQuery(this).text() == index));
				});
	        }
	    });
	},
	
	mainCarouselCallback: function(carousel) {
		jQuery('#main-carousel-control a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			carousel.startAuto(0);
			return false;
		});
		jQuery('#main-carousel-control').show();
	}

}

jQuery(document).ready(function() {
    ppl.coffee.init();
});
