$.easing.easeInOutQuint = function (x, t, b, c, d) {
    if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
    return c/2*((t-=2)*t*t*t*t + 2) + b;
}

$(document).ready(function(){
    $("#horizontalScrollerBody").scrollable({
        size: 3,
        circular: true,
        speed: 700,
        clickable: false,
        easing: 'easeInOutQuint',
        keyboard : false
    }).autoscroll({
        autoplay: false,
        interval: 5000
    }).circular();

    $("#verticalScrollerBody").scrollable({
        size: 2,
        circular: true,
        vertical: true,
        speed: 700,
        clickable: false,
        easing: 'easeInOutQuint',
        keyboard : false
    }).autoscroll({
        autoplay: false,
        interval: 5000
    }).circular();

    /* Слайдер на главной странице */
    $("#contentMain #slideScrollerBody").scrollable({
        size: 1,
        circular: true,
        speed: 1700,
        clickable: false,
        easing: 'easeInOutQuint',
        keyboard : false
    }).autoscroll({
        autoplay: true,
        interval: 5000
    }).circular().navigator({
        navi:'ul#pagesNumbers'
    });

    /* Слайдер в фотогалерее */
    $("#__photos #slideScrollerBody").scrollable({
        size: 1,
        circular: true,
        speed: 1700,
        clickable: false,
        easing: 'easeInOutQuint',
        keyboard : false
    }).circular().navigator({
        navi:'ul#pagesNumbers'
    });

    /*$(".description-scroller").scrollable({
        size: 1,
        circular: true,
        speed: 1700,
        clickable: false,
        easing: 'easeInOutQuint',
        keyboard : false
    }).circular().navigator({
        navi:'.pages-numbers'
    });*/

    var api = $("#slideScrollerBody").data("scrollable");

    if (api) {
        // Исправление бага с ресайзом
        var fixByResize = function(){
            var index = api.getIndex();
            var item = api.getItems().eq(index + 1);
            $("#slideScrollerBody .items").css({
                left: -item.position().left
            });
        }
        $(window).resize(fixByResize);
        api.onSeek(fixByResize);
    }

    // Если пользователь начал листать вручную
    // то отключить автопрокрутку
    $('#slideScrollerBody #pagesNumbers li a').click(function(){
        api.stop();
    });



});
