﻿function mycarousel_itemLoadCallback(carousel, state) {
    if (state != 'init')
        return;
};

function mycarousel_itemAddCallback(carousel, first, last, data) {
    var items = data.split('|');

    for (i = 0; i < items.length; i++) {
        carousel.add(i + 1, mycarousel_getItemHTML(items[i]));
    }

    carousel.size(items.length);
};

function func1(carousel, item, idx, state) {
    $('.jcarousel-control div').attr('class', 'none');
    jQuery('img', item).fadeTo('slow', 1);
    $('#jcarousel-image-' + idx).attr('class', 'selected');
};
function func2(carousel, item, idx, state) {
    jQuery('#mycarousel img').css({ 'opacity': '0', 'filter': 'alpha(opacity=0)' });
};

function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control div').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 10, // seconds between change
        wrap: 'both',
        animation: 0,
        initCallback: mycarousel_initCallback,
        itemVisibleInCallback: {
            onAfterAnimation: func1
        },
        itemVisibleOutCallback: {
            onAfterAnimation: func2
        }
    });
    jQuery('.int-carousels').jcarousel({
        wrap: 'both',
        animation: 'normal',
        buttonNextHTML: '<div></div>',
        buttonPrevHTML: '<div></div>'
    });
    jQuery('#related-products-carousel-vertical').jcarousel({
        wrap: 'both',
        vertical: true,
        buttonNextHTML: '<div></div>',
        buttonPrevHTML: '<div></div>'
    });
    jQuery('#related-products-carousel-horizontal').jcarousel({
        wrap: 'both'
    });
});


