window.addEvent('domready', function(){ 	
	
	if($chk($('product_slideshow'))){
		new Ps_animation();		
	}
	
});

var Ps_animation = new Class({					 

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

	initialize: function(){
		this.product_timer;	
		this.products = $$('#product_slideshow div[class=product]');	
		this.current_product = this.products.length;		
		this.product_timer = this.get_previous.delay(4000, this);		
	},
	
	get_previous: function(){		
		var current = this.products[this.current_product-1];
		current.fade('out').retrieve('tween').chain(function(){
			current.clone().setStyles({'visibility':'hidden', 'opacity':.999}).inject($('product_slideshow'), 'top');
			current.dispose();			
			this.products = $$('#product_slideshow div[class=product]');	
			this.product_timer = this.get_previous.delay(4000, this);			
		}.bind(this));			
	}	
	
});
