var SlideShow = new Class ({
	Implements: Options,

	options : {
		imageTime	:	4000,
		fadeTime	:	1500
	},
	
	initialize : function (container, images, links, options) {
		this.setOptions(options);
		this.container = $(container);
		
		this.images = images.map(function(url) {
			return new Element('img', 
							   {'src' : url,
							    'width' : '100%', 'height': '100%',
								'tween' : {duration : this.options.fadeTime}
							   });
		}, this);
		
		this.links = links.map(function(url) {
			return new Element('a', 
							   {'href': url});
		}, this);

		this.index = 0;
		this.currentImage = (this.links[this.index].grab(this.images[this.index])).inject(container);
		this.fade.periodical(this.options.imageTime + this.options.fadeTime, this);
	},
	
	fade : function () {
		this.index = (this.index + 1) % this.images.length;
		this.lastImage = this.currentImage;
		
		this.currentImage = this.links[this.index].grab(this.images[this.index]).fade('hide').inject(this.container).fade('in');
	}
	
});