﻿function initLinks() {
    maxWidth = 500;
    minWidth = 40;

    $("#ribbon_left_zone a.image").click(
                function () {
                    animateUL($(this).parent());
                }
            );
}

function animateUL(a) {
    activeItem = $("#ribbon_left_zone ul li div.activeRibbonItem");
    if (!a) {
        nextli = activeItem.parent().next();
        if (nextli.length != 0) {
            itemToShow = nextli.children().first();
        } else {
            itemToShow = $("#ribbon_left_zone ul li div").first();
        }

    } else {
        itemToShow = $(a);
    }
    $(activeItem).animate({ width: minWidth + "px" }, { queue: false, duration: 200 });
    $(itemToShow).animate({ width: maxWidth + "px" }, { queue: false, duration: 200 });
    itemToShow.toggleClass("activeRibbonItem");
    activeItem.toggleClass("activeRibbonItem");
}

function initAnimation() {
    maxWidth = 500;
    minWidth = 40;
    intervalID = null;

    $("#ribbon_left_zone a.image").click(
                 function () {
                     animateUL($(this).parent());
                     clearInterval(intervalID);
                 }
            );

    intervalID = setInterval(animateUL, 6000);
}
