	
function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		$(".jcarousel-control a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active");
        return false;
    });
 
    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
 
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
 
    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
 
	// Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


jQuery(document).ready(function() {

	jQuery("#mycarousel").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
		// Auto scrolling
        auto: 10,
        wrap: 'last',
		itemVisibleInCallback: {
			onAfterAnimation: function(c, o, i, s) {
			//--i;
			i = (i - 1) % $('#mycarousel li').size();
			jQuery('.jcarousel-control a').removeClass('active');
			jQuery('.jcarousel-control a:eq('+i+')').addClass('active');
		}
	  }
 
    });

});

