// JavaScript Document
(function($){
    var ezrotator;
    if (!ezrotator) 
        ezrotator = function(){
        };
    $.fn.ezrotator = function(options){
        var defaults = {
            interval: 5000
        };
        var opts = $.extend(defaults, options);
        return this.each(function(){
            var element = $(this);
            element.children().hide();
            var numChildren = ezrotator.countChildren(element);
            element.children().eq(0).show();
            ezrotator.rotate(element, numChildren, 0, opts.interval);
        });
    };
    ezrotator.countChildren = function(element){
        var numChildren = element.children().size();
        return numChildren;
    };
    ezrotator.rotate = function(element, numChildren, counter, interval){
        var elem = element;
        var numChild = numChildren;
        var count = counter;
        if (count == numChild - 1) 
            count = 0;
        else 
            count++;
        $(element).children("li").eq(counter).fadeOut("slow");
        $(element).children("li").eq(count).fadeIn("slow");
        setTimeout(function(){
            ezrotator.rotate(elem, numChild, count, interval);
        }, interval);
    };
})(jQuery);

