Slideshow = Class.create();
	Slideshow.prototype = {
		initialize : function(slides, options) {
			this.slide = 0;
			this.slides = slides;
			this.slideshowObserver = this.continueSlideshow.bind(this);
			this.fadeInObserver = this.fadeIn.bind(this);
			// Set options
			this.options = Object.extend({
				delay: 5000,
				autoStart: true
			}, options || {});
			this.stopped = !this.options.autoStart;
			if (this.slides.length > 0 && !this.stopped) {
				this.timeout = setTimeout(this.slideshowObserver, this.options.delay);
			}
		},
		startSlideshow : function() {
			if (this.stopped) {
			// Can only start when the slideshow is stopped
			this.stopped = false;
			if (this.slides.length > 0) {
			this.timeout = setTimeout(this.slideshowObserver, this.options.delay);
			}
			}
		},
		stopSlideshow : function() {
		if (!this.stopped) {
		// Can only stop when the slideshow is started
		this.stopped = true;
		if (this.timeout) {
		clearTimeout(this.timeout);
		}
		}
		},
		continueSlideshow : function() {
		if (this.stopped) {
		return;
		}
		// Go to the next slide
		this.nextSlide();
		if (this.slides.length > 0 && !this.stopped) {
		this.timeout = setTimeout(this.slideshowObserver, this.options.delay + 1000);
		}
		},
		nextSlide : function() {
		var nextSlide = 0;
		if (this.slide < this.slides.length - 1) {
		nextSlide = this.slide + 1;
		}
		this.gotoSlide(nextSlide);
		},
		prevSlide : function() {
		var prevSlide = this.slides.length - 1;
		if (this.slide > 0) {
		prevSlide = this.slide - 1;
		}
		this.gotoSlide(prevSlide);
		},
		gotoSlide : function(index) {
		if (index == this.slide) {
		return;
		}
		if (index < 0 || index > this.slides.length - 1) {
		index = 0;
		}
		var currentSlide = this.slide;
		this.slide = index;
		if (this.slides[currentSlide]) {
		new Effect.Fade(this.slides[currentSlide]);
		}
		setTimeout(this.fadeInObserver, 1000);
		},
		fadeIn : function() {
		if (this.slides[this.slide]) {
		new Effect.Appear(this.slides[this.slide]);
		}
	}
};
