/* List Ticker by Alex Fish 
// www.alexefish.com
//
// options:
//
// effect: fade/slide
// speed: milliseconds

// Revision Notes:
//  8/11/2010   JasonM  Added conditional to only enable ticker if there are two or more LIs in the list.
*/

(function($) {
    $.fn.list_ticker = function(options) {

        var defaults = {
            speed: 4000,
            effect: 'slide'
        };

        var options = $.extend(defaults, options);

        return this.each(function() {

            var obj = $(this);
            var list = obj.children();
            list.not(':first').hide();

            if ($("#" + this.id + " > li").length > 1) {
               
                setInterval(function() {

                    list = obj.children();
                    list.not(':first').hide();

                    var first_li = list.eq(0)
                    var second_li = list.eq(1)

                    if (options.effect == 'slide') {
                        first_li.slideUp();
                        second_li.slideDown(function() {
                            first_li.remove().appendTo(obj);
                        });
                    } else if (options.effect == 'fade') {
                        first_li.fadeOut(function() {
                            second_li.fadeIn();
                            first_li.remove().appendTo(obj);
                        });
                    }
                }, options.speed)
            }
        });
    };
})(jQuery);

