function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-scroll a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('name')));
        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();
    });
		
		//Tom 17th Jan 2011. bind click of a video to stop the auto scroll.
		jQuery('a.pauseauto').bind('click', function(){		
			carousel.stopAuto(0);															
		});
	
};

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel").jcarousel({
        scroll: 1,
		visible: 1,
//		wrap: 'circular',
		wrap: 'both',
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,
		auto: 12,
		itemVisibleInCallback: function(c,li,ind){
			jQuery(".jcarousel-scroll a[name="+ind+"]").addClass('active');			
		},
		itemVisibleOutCallback: function(c,li,ind){
			jQuery(".jcarousel-scroll a[name="+ind+"]").removeClass('active');			
		}	
});

});

