var BustOutSolutions = { }

BustOutSolutions.Slideshow = Class.create();

BustOutSolutions.Slideshow.prototype =
{
    initialize: function( elements, options )
    {
        if( elements == null )
            throw "elements == null";

        this.elements = elements;

        this.options = Object.extend(
            {
                duration: 1.0,
                delay: 5.0
            },
            options || {}
        );
    },

    start: function()
    {
        this.cursor = 0;
        this.running = true;
        window.setTimeout( this.crossFade.bind( this ), this.options.delay * 1000 );
    },

    crossFade: function()
    {
        new Effect.Fade(
            this.elements[this.cursor],
            {
                duration: this.options.duration,
                from: 1.0, to: 0.0
            }
        );

        this.cursor++;
        if( this.cursor == this.elements.length )
            this.cursor = 0;

        new Effect.Appear(
            this.elements[this.cursor],
            {
                duration: this.options.duration,
                from: 0.0, to: 1.0
            }
        );

        window.setTimeout( this.crossFade.bind( this ), this.options.delay * 1000 );
    }
}
