   var slideshow = function(id, timerValue) {
        this.animated = false;
        this.dom = $(id);
        this.slides = this.dom.select(".slideshow-slide");
        this.timer = null;
        this.timerValue = timerValue ? timerValue : 5000;
        this.slides.each( function (elm, n) {
            if (n==0) {
                return;
            }
            elm.setStyle( { display: "block", opacity: 0 });
        } );
        this.activeSlide = 0;
        console.log(this.dom.select(".slideshow-navigation-right").first());
        Event.observe(this.dom.select(".slideshow-navigation-left").first(), "click", this.previous.bind(this));
        Event.observe(this.dom.select(".slideshow-navigation-right").first(), "click", this.next.bind(this));

        this.timer = setTimeout(this.next.bind(this), this.timerValue);
    }

    slideshow.prototype.next = function() {
        var slide;
        if ((this.activeSlide+1) >= (this.slides.length)) {
            slide = 0;
        } else {
            slide = this.activeSlide + 1;
        }
        this.goTo(slide);
    }

    slideshow.prototype.previous = function() {
        var slide;
        if ((this.activeSlide-1) < 0) {
            slide = this.slides.length-1;;
        } else {
            slide = this.activeSlide - 1;
        }
        this.goTo(slide);
    }

    slideshow.prototype.goTo = function (n) {
        if (this.animated == true) {
            return;
        }
        clearTimeout(this.timer);
        var willDisappear = this.slides[this.activeSlide];
        var willAppear = this.slides[n];
        this.animated = true;
        willAppear.setStyle( { "zIndex" : 30 });
        willDisappear.setStyle( { "zIndex" : 29 });
        var finished = function () {
            willDisappear.setStyle( { opacity: 0 } );
            this.animated = false;
        }
        new Effect.Fade(willAppear, {duration:1, from:0, to:1.0, afterFinish: finished.bind(this) });
        this.activeSlide = n;
        this.timer = setTimeout(this.next.bind(this), this.timerValue);
    }
