var SliderImg = new Class({
	
	Implements : Options,
	
	options: {
		imagesSet: '#slider img'
	},
	
	initialize : function(options){
		this.setOptions(options);
		this.crt=0;
		this.images = $$(this.options.imagesSet);
		this.fx = new Array();
		this.container = this.images[0].getParent();
		this.initImg();
		
	},
	
	initImg : function() {
		this.images.each(function(el,i){
			if(el.get('tag') != 'img') el.getElement('img').setStyle('display','block');
			el.setStyle('display','block');
			
			this.fx[i] = new Fx.Tween(el, {
				property:'opacity',
				duration: 500,
				onComplete: function(){
					this.images[i].setStyle('opacity',1).inject(this.container,'top');
				}.bind(this)
			});
			
		}.bind(this));
		this.images[0].inject(this.container);
		
		this.getNext.periodical(3500,this);
	},
	
	showProduct : function(index) {
		this.images[index].inject(this.container.getLast(),'before');
		this.fx[this.crt].start(1,0);
		this.crt = index;
	},
	
	getNext : function(){
		this.showProduct((this.crt+1)%this.images.length);
	}	
});

