﻿jQuery(document).ready(function() {
    jQuery('#first-carousel').jcarousel({ auto: 4, wrap: 'last', initCallback: carousel_initCallback, itemVisibleInCallback: { onAfterAnimation: carousel1_InAfterAnimation }, itemVisibleOutCallback: { onAfterAnimation: carousel1_OutAfterAnimation} });
});

function carousel1_InAfterAnimation(carousel, item, idx, state) {
    $('#bm_s_' + idx).addClass('thumbborder set');
}

function carousel1_OutAfterAnimation(carousel, item, idx, state) {
    $('#bm_s_' + idx).removeClass();
    $('#bm_s_' + idx).addClass('thumbborder');
}

function carousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);o
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function MoveCarousel(index) {
    var carousel = jQuery('#first-carousel').data('jcarousel');
    carousel.scroll(index, true);
    carousel.startAuto(0);
}
