function setupSlideshow(slideshow, speed) {

	slideshow = $(slideshow);
	slideshow.slides = [];
	slideshow.duration = 1;
	slideshow.speed = speed;
	slideshow.effect = Effect.Fade;

	slideshow.setDuration = function(duration) {
		this.duration = duration;
	}

	slideshow.setSpeed = function(speed) {
		this.speed = speed;
	}

	slideshow.setEffect = function(fx) {
		this.effect = fx;
	}

	slideshow.swapSlide = function(start, end) {
		
		start.style.zIndex = 2;
		end.style.zIndex = 1;

		Element.show(end);
		end.setOpacity(1); //I fucking hate IE
		
		this.effect(start, {duration: this.duration});

		if (this.speed) {
			global_slide = slideshow;
			setTimeout('global_slide.next()', this.speed);
		}
	}


	slideshow.previous = function(event) {

		if (typeof event != 'undefined') {
			this.pause();
		} else if (!this.speed) {
			return;
		}

		var nextslide = this.currentSlide-1;
		if (nextslide == -1) {
			nextslide = this.slides.length-1;
		}

		this.swapSlide(this.slides[this.currentSlide], this.slides[nextslide]);
		this.currentSlide = nextslide;
	}
	
	slideshow.next = function(event) {

		if (typeof event != 'undefined') {
			this.pause();
		} else if (!this.speed) {
			return;
		}

		var nextslide = (this.currentSlide+1)%this.slides.length;
		this.swapSlide(this.slides[this.currentSlide], this.slides[nextslide]);
		this.currentSlide = nextslide;
	}

	slideshow.pause = function(event) {
		this.speed = 0;
	}

	
	$A(slideshow.getElementsByTagName('LI')).map(function(slide, cont){
		slideshow.slides[cont] = slide;
		Element.hide(slide);
		slide.style.position = 'absolute';
	});

	slideshow.currentSlide = 0;
	Element.show(slideshow.slides[0]);

	if (slideshow.speed) {
		global_slide = slideshow;
		setTimeout('global_slide.next()', slideshow.speed);
	}
}