window.addEvent('domready', function(){
	
	var rp = new Rp_animation();
									 
});

var Rp_animation = new Class({					 

	Implements: [Events, Options],
	
	options:{},

	initialize: function(){		
		this.img_timer;		
		this.images = $$('#intro_wrapper div');	
		this.current_img = this.images.length;
		if(this.images.length == 0){			
			window.location.href = 'index.htm';
			return false;
		}
		this.get_next.delay(2000, this);
	},
	
	get_next: function(){		
		previous = this.images[this.current_img-1];
		this.current_img--;
		if(this.current_img < 1){ this.current_img = this.images.length; }	
		previous.set('morph', {duration: 'long', transition: 'bounce:out'});
 		previous.morph({width: 0}).retrieve('morph').chain(function(){	
			previous.setStyle('width', '539px').inject('intro_wrapper', 'top');																	
			this.get_next.delay(2000, this);															
		}.bind(this));
	}
});
