Crossfader = function(container, options) {
    this.container = $(container).makePositioned();
    this.images = new Array();

    this.options = Object.extend({ urls: null, delay: 7, width: 150, height: 100 }, options);

    if (this.options.urls)
    {
        for (var i = 0; i < this.options.urls.length; i++)
        {
            var image = new Image();
            image = $(image);
            image.hide();
            image.src = options.urls[i].replace("original.aspx",options.width+"x"+options.height+".aspx");
            image.style.position = "absolute";
            this.container.appendChild(image);
        }
    }
    this.images = this.container.immediateDescendants();
    this.images.each( function (e) { e.setStyle({position: "absolute"}).hide(); } );
    this.current = null;
    this.setCurrent(0);
    window.setTimeout(this.step.bind(this),this.options.delay*1000);
};

Crossfader.prototype.setCurrent = function(x)
{
    if (this.current != null)
    {
        new Effect.Fade(this.images[this.current]);
    }
    new Effect.Appear(this.images[x].hide());
    this.current = x;
};

Crossfader.prototype.step = function()
{
    this.setCurrent(this.current == null ? 0 : (this.current + 1) % this.images.length);
    window.setTimeout(this.step.bind(this),this.options.delay*1000);
};