var Banner = Class.create({ initialize: function(holder) { this.holder = holder; this.index = 0; this.timer; this.duration = 5000; this.current = 0; var target = $(this.holder + "-images"); this.images = target.getElementsByTagName("li"); this.length = this.images.length; var image; for (var i = 1; i < this.length; i++){ image = $(this.holder + "-" + i); image.setStyle({ 'display': 'none' }); } this.timer = setTimeout(this.play.bindAsEventListener(this), this.duration); }, play: function(){ var next = ( (this.current + 1) < this.length ) ? this.current + 1 : 0; var image = $(this.holder + "-" + this.current); new Effect.Fade(image, { duration: 0.5 }); var nextImage = $(this.holder + "-" + next); new Effect.Appear(nextImage, { duration: 0.5 }); this.current = next; this.timer = setTimeout(this.play.bindAsEventListener(this), this.duration); } });