	window.addEvent('domready', function(){
		new Rotator({
			topImg : 'current_rotation_image',
			images :  [ "images/banners/2.jpg",
					    "images/banners/3.jpg",
						"images/banners/4.jpg"]});
		new Rotator({
			topImg : 'right_rotation_image',
			images :  [ "ads/r-ad-2.jpg",
						"ads/r-ad-3.jpg",
						"ads/r-ad-4.jpg"]});
		
		new Rotator({
			topImg : 'bottom_rotation_image',
			images :  [ "ads/b-ad-2.jpg",
						"ads/b-ad-3.jpg",
						"ads/b-ad-4.jpg"]});
						
						
	});

Rotator = new Class({
 
        options : {
                fade : 1500,
                timer : 5500
        },
 
        initialize: function(options){
        		var self = this;
 
        		this.idx = 1;
                this.setOptions(this.options, options);
 
                this.topImg = $(this.options.topImg);
 
                this.images = this.options.images;
               	this.images.unshift(this.topImg.src);
 
               	new Asset.images(this.images, {
               		onComplete : function(){
               				self.loaded();
               		}
               	});
 
        },
 
        loaded : function(){
        		var self = this;
                this.botImg = new Element('img').setProperties({'id':'background_rotation_image','src' : this.images[this.idx]})
                								.injectInside('bannerInner');
                this.fx = new Fx.Style(this.options.topImg, 'opacity', {duration:this.options.fade, onComplete: this.wait.bind(this) });
                this.fade();	
        },
 
        fade : function(){
        		this.botImg.setProperty('src',this.images[this.idx]);
				this.botImg.setStyles({'opacity': 1, 'visibility' : 'hidden'});
                this.fx.start(1,0);
        },
 
        wait : function(){ 
                this.topImg.src = this.images[this.idx];
                this.topImg.setStyles({'opacity': 1, 'visibility' : 'visible'});
                this.changeImage();
                this.wait.bind(self);
                this.waitID = this.fade.delay(this.options.timer,this);
        },
 
 
        changeImage : function(){
                        this.idx = ( this.idx == this.images.length-1 ) ? 0 : ++this.idx;
        }
});
 
Rotator.implement( new Options );