jQuery (function ($)
{
    var totalWidth = 0;
    var positions = [];
    var itemContainer = $ (".item-container");

    itemContainer.find (".item").each (function () {
        positions.push (totalWidth);
        totalWidth += $ (this).width ();
    });

    itemContainer.width (totalWidth);

    $ (".navbar li a").click (function (e) {
        $.stopEvent (e);

        var li = $ (this).parent ();
        var index = li.prevAll ("li").length - 1;

        li.siblings ("li").removeClass ("active").addClass ("inactive");
        li.addClass ("active");

        itemContainer.stop ().
            animate ({ marginLeft: -positions[index] + "px" }, 450);
    });
});

