var ContentScroller = Class.create();

ContentScroller.prototype = {
    
    current: 0,

    initialize: function(element, options){
        this.element = element;
        this.setOptions(options);
        this.items = this.element.getElementsByTagName("LI");
        this.all = this.items.length;
        this.hideAll();
        this.scroll();
    },
    
    setOptions: function(options) {
        this.options = {
            dynamicClass: 'js',
            wait: 5000
        };
        Object.extend(this.options, options || {});
    },
    
    hideAll: function(){
        var listItems = $$("." + this.element.className + " li")
        listItems.each(function(obj){
            obj.hide();
        });
        $(listItems.first()).show();
    },
    
    scroll: function(){
        me = this;
        setInterval("me.swapFade();",this.options.wait);
    },
    
    swapFade: function(){
        Effect.Fade(this.items[this.current], { duration:1, from:1.0, to:0.0 });
        this.current++;
        if (this.current == this.all)this.current = 0;
        Effect.Appear(this.items[this.current], { duration:1, from:0.0, to:1.0 });
    }
}

Event.observe(window, "load", function(){
	$$(".slideshow").each(function(obj){
	 new ContentScroller(obj);
	});
});