var Slideshow=new Class({
	sid: null,
	
	count: null,
	current: 0,
	
	imgs: null,
	tabs: null,
	
	initialize: function(imgs) {
		this.imgs=imgs;
		this.fxs=[];
		this.count=this.imgs.length;
		
		this.imgs.each(function(el) {
			var fx=new Fx.Tween(el);
			fx.set('opacity', 0);
			this.fxs.push(fx);
		}.bind(this));
		
		this.selectImage(0);
		
		this.next.periodical(5000, this);
	},
	
	selectImage: function(index) {
		this.current=index;
		
		if (this.current>=0 & this.current<this.count) {
			this.fxs.each(function(fx, i) {
				if (index==i) {
					if (this.imgs.length==1) {
						fx.options.duration=3000;
						fx.start('opacity', 1);
					} else {
						fx.options.duration=1000;
						fx.start('opacity', 1);
					}
				} else {
					fx.options.duration=2000;
					fx.start('opacity', 0);
				}
			}.bind(this));
		}
	},
	
	prev: function() {
		var index=this.current;
			
		if (index<=0) index=this.count;

		index=(index-1)%this.count;
		this.selectImage(index);
	},
	
	next: function() {
		this.selectImage((this.current+1)%this.count);
	}
});
