jQuery(document).ready(function($) {
    // Easing equation, borrowed from jQuery easing plugin
    // http://gsgd.co.uk/sandbox/jquery/easing/
    jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
    };

    jQuery(function( $ ){
        var $prev = $('#imageCluster img.prev'),//prev button
            $next = $('#imageCluster img.next');//next button
        
        $('#photoList').serialScroll({
            items:'li',
            prev:'#imageCluster img.prev',
            next:'#imageCluster img.next',
            //offset:-230, //when scrolling to photo, stop 230 before reaching it (from the left)
            start:0,
            duration:1200,
            force:true,
            stop:true,
            lock:false,
            axis:'y',
            cycle:false,
            easing:'easeOutQuart', //use this easing equation for a funny effect
            onBefore:function( e, elem, $pane, $items, pos ){
                $prev.add($next).show();
                if( pos == 0 )
                    $prev.hide();
                else if( pos == $items.length-2 )
                    $next.hide();
            }
        });
        
        $(document).ready(function() {
              $prev.hide();
          });
    });
});