﻿// 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($) {
    /**
    * Most jQuery.serialScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
    * @see http://flesler.demos.com/jquery/scrollTo/
    * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.serialScroll.
    */

    /**
    * The plugin binds 6 events to the container to allow external manipulation.
    * prev, next, goto, start, stop and notify
    * You use them like this: $(your_container).trigger('next'), $(your_container).trigger('goto', [5]) (0-based index).
    * If for some odd reason, the element already has any of these events bound, trigger it with the namespace.
    */


    $('#list').css("overflow", "hidden");
    $('#list').css("width", "627px");
    $('#button1').css("display", "block");
    $('#button2').css("display", "block");

    $('#prev').hide();


    $('#list').serialScroll({
        items: 'li',
        prev: '#leaderboard a#prev',
        next: '#leaderboard a#next',
        // offset: -230, //when scrolling to photo, stop 230 before reaching it (from the left)
        start: 0, //as we are centering it, start at the 2nd
        duration: 1400,
        axis: 'y',
        force: true,
        stop: true,
        step: 5, // How many items to scroll each time ( 1 is the default, no need to specify )
        lock: false,
        cycle: false, //don't pull back once you reach the end
        easing: 'linear', //use this easing equation for a funny effect
        jump: false, //click on the images to scroll to them
        onBefore: function(e, elem, $pane, $items, pos) {
            $('#prev,#next').fadeIn("slow");

            if (pos == 0)
                $('#leaderboard a#prev').fadeOut("slow");
            else if (pos == $items.length - 1)
                $('#leaderboard a#next').fadeOut("slow");
        } 
    });

    $('#sml_list').css("overflow", "hidden");
    $('#sml_list').css("width", "292px");
    $('#sml_list').css("padding-left", "10px");
    $('#sml_list_end').css("margin", "0 auto");


    $('#sml_button1').css("display", "block");
    $('#sml_button2').css("display", "block");
    
    $('#prev').hide();

    $('#sml_list').serialScroll({
        items: 'li',
        prev: '#sml_leaderboard a#prev',
        next: '#sml_leaderboard a#next',
        // offset: -230, //when scrolling to photo, stop 230 before reaching it (from the left)
        start: 0, //as we are centering it, start at the 2nd
        duration: 1400,
        axis: 'y',
        force: true,
        stop: true,
        step: 5, // How many items to scroll each time ( 1 is the default, no need to specify )
        lock: false,
        cycle: false, //don't pull back once you reach the end
        easing: 'linear', //use this easing equation for a funny effect
        jump: false, //click on the images to scroll to them

        onBefore: function(e, elem, $pane, $items, pos) {          
        
        $('#prev,#next').fadeIn("slow");
        
        if (pos == 0)
            $('#sml_leaderboard a#prev').fadeOut("slow");
        else if (pos == $items.length - 1)
            $('#sml_leaderboard a#next').fadeOut("slow");     
        }      

    });



});