var Home = Class.create({
    _delay: 6,
    initialize: function() {
        this._img = $('home_image');
        if (! this._img) return;
        this._cache = $('home_images').childElements();
        if (this._cache.length < 2) return;
        this._index = 1;
        this._rotate.bind(this).delay(this._delay);
    },
    _rotate: function() {
        var img = this._cache[this._index];
        this._img.writeAttribute('src', img.readAttribute('src'));
        if (this._index < this._cache.length - 1) {
            this._index++;
        } else {
            this._index = 0;
        }
        this._rotate.bind(this).delay(this._delay);
    }
});

document.observe('dom:loaded', function() {
    new Home;
});

