﻿jQuery.noConflict();

(function ($) {
    jQuery.fn.slideLeftHide = function( speed, callback ) { this.animate( { width: "hide", paddingLeft: "hide", paddingRight: "hide", marginLeft: "hide", marginRight: "hide" }, speed, callback ); }
    jQuery.fn.slideLeftShow = function( speed, callback ) { this.animate( { width: "show", paddingLeft: "show", paddingRight: "show", marginLeft: "show", marginRight: "show" }, speed, callback ); }
    jQuery.fn.sponsorRotator = function (options) {

        return this.each(function () {
            var settings = {
                interval: 1000
            };
            var settings = $.extend(settings, options); 
            var $this = $(this);
            var items = $("li", $this);
            var curItem = 0;
            var oldItem = 0;

            function rotate() {
                curItem = (oldItem + 1) % items.size();
                $(items[oldItem]).slideLeftHide("slow", function() {
                    $(items[curItem]).slideLeftShow("slow");
                    oldItem = curItem;                
                });
            }

            function initItems() {
                for (i = 1; i < items.size(); i++) {
                    $(items[i]).hide();
                }
            }

            initItems();
            setInterval(rotate, settings.interval);
        });

    };
})(jQuery);



jQuery(document).ready(function ($) {
    $('#sponsors ul').sponsorRotator({"interval": 5000});
});
