RotatingImage = Class.create({
    delay: null,
    i: null,
    count: null,

    initialize: function(delay) {
        this.delay = delay;

        // count the number of images available
        this.count = $('rotatingBanner').select('div.rotating-image-wrapper').length;

        // initialize start position
        this.i = 0;
        $('rotatingBanner').down('div.rotating-image-wrapper', this.i).show();

        new PeriodicalExecuter(function(pe){
            this.hideImage();
            this.i = (this.i + 1) % this.count;
            new PeriodicalExecuter(function(p2) {
                p2.stop();
                this.showImage();
            }.bind(this), 1);
        }.bind(this), this.delay);

    },
    hideImage: function() {
        // hide current image
        new Effect.Fade($('rotatingBanner').down('div.rotating-image-wrapper', this.i), {duration: 1});
    },
    showImage: function() {
        // show current image
        new Effect.Appear($('rotatingBanner').down('div.rotating-image-wrapper', this.i), {duration: 1});
    }
});

var rotatingImage;

