function TabCarousel()
{
    this.initCallback = tabcarousel_initCallback;
    this.transition = tabcarousel_transition;
}

function tabcarousel_removeActiveFromControls(except)
{
    jQuery('#prod-info-tabs .jcarousel-control a').each(function(i) {
    	if (jQuery(this).is('.active')) {
    	    jQuery(this).removeClass('active');
    	}
    });
}

function tabcarousel_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

    jQuery('#prod-info-tabs .jcarousel-control a').bind('click', function() {
        carousel.startAuto(0);
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('title')));
        tabcarousel_removeActiveFromControls(jQuery(this));
        jQuery(this).addClass('active');
        return false;
    });
		
		jQuery('.mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
		
};

function tabcarousel_transition(carousel, li, pos)
{
    tabcarousel_removeActiveFromControls();
    
    jQuery('#prod-info-tabs .jcarousel-control a').each(function(i) {
        if (jQuery(this).attr('title') == pos) {
            jQuery(this).addClass('active');
        }
    });
};
