// Auto-scroll every 2s
var direction = "left"
function scrollSponsor() {
    var api = $(".scrollableSponsors").data("scrollable");
    end = api.getSize() - 4;
    if( direction == "left" ) {
        var link = $( "div#home-sponsor-content  a.prev" );
        if( link.hasClass( "disabled" ) ) {
    	    direction = "right";
        } else {
    	    link.click();
        }
    } else {
        var link = $( "div#home-sponsor-content a.next" );
        if( api.getIndex() === end ) {
    	    direction = "left";
        } else {
    	    link.click();
        }
    }
}
$(document).ready(function() {
    // Sponsor Scroll Bar
    $.easing.custom = function (x, t, b, c, d) {
	if ((t/=d/2) < 1) {
	    return c/2*t*t*t + b;
	}
	return c/2*((t-=2)*t*t + 2) + b;
    }

    // initialize scrollable
    var scroller = $("div.scrollableSponsors").scrollable({
        size: 4,
        //next: 'a.next',
        //prev: 'a.prev',
        easing: 'custom',
        //items: '.items',
        keyboard: true,
        clickable: false,
        speed: 1000
        //circular: true,
    });

    setInterval( "scrollSponsor()", 5000);
});

