Scroll to and from every 12th li element with next/prev links issue
<p>I have been trying to make this thing work and it's been really getting to me. I'm not quite sure where I'm getting lost with it.</p>

<p>I have a ul li outputting a bunch of thumbnail images, that are displayed 12 at a time. </p>

<p>I almost have it working but it's still really buggy. If anyone can help that would be awesome. I want to show the prev link after the next link is clicked and hide it if the index is less than 0, and hide or show the next link according to if the index is greater than the length of the li collection.</p>

<p>Each time the links are clicked they need to increment plus or minus 12 so the next index to scrollTo is set up.</p>

<p>Here's the demo I have created: <a href="http://jsfiddle.net/jaredwilli/L9hns/" rel="nofollow">http://jsfiddle.net/jaredwilli/L9hns/</a></p>

<pre><code>var t = { 
    num: 12,
    scroll: {to: {}, from: {}},
    init: function() {
        var li = $('.barthumbs li'),
            first = li.eq(0),
            index = $('li.active').index();

        console.log(index);

        $('#next').click(function(e) {
            t.scroll.to = t.link(index, '+');
            index += t.num;

            $('#bartender-thumbs').scrollTo($('#'+t.scroll.to), 500);

            //console.log(index);
            e.preventDefault();
        });

        $('#prev').click(function(e) {
            t.scroll.from = t.link(index, '-');
            index -= t.num;
            //console.log(t.scroll.from);
            //console.log(index);
            $('#bartender-thumbs').scrollTo($('#'+t.scroll.from), 500);
            e.preventDefault();

        });
        //console.log(index);
    },
    link: function(index, operator) {
        if (operator == '+') {
            index = index + t.num;
        } else if (operator == '-') {
            index = index - t.num;
        }
        console.log(index);
        var curr = $('li').eq(index);

        $('li').removeClass('active');
        curr.addClass('active');
        curr = $('.active').attr('id');
        //console.log(curr);

        if (index &gt; 0) { $('#prev').show(); }
        if (curr == undefined) { $('#next').hide(); }

        return curr;
    }
};
t.init();
</code></pre>
