make_diaporama = function(image, desc, image_list, opt) {
    if (!(image && image_list)) {
        return;
    }
    return {
        image: image,
        desc: desc,
        image_list: image_list,
        settings: jQuery.extend(
            {
                delay: 4000,
                current_image: 0,
            }, opt
        ),
        paused: true,

        display: function(number) {
            if (number < 0) {
                number = this.image_list.length - 1;
            }
            if (number > this.image_list.length - 1) {
                number = 0;
            }
            this.settings.current_image = number;
            this.image.attr('src', this.image_list[number][0]);
            this.desc.text(this.image_list[number][1]);
            return this;
        },

        _next: function() {
            this.display(this.settings.current_image + 1);
            return this;
        },

        next: function() {
            this.pause();
            this._next(this);
            this.play();
            return this;
        },

        previous: function() {
            this.pause();
            this.display(this.settings.current_image - 1);
            return this;
        },

        play: function() {
            var diaporama = this;
            this.pause();
            this.settings.timer = setInterval(
                function() { diaporama._next(); },
                this.settings.delay
            );
            this.paused = false;
            return this;
        },

        pause: function() {
            clearInterval(this.settings.timer);
            this.paused = true;
            return this;
        },

        toggle_pause: function() {
            if (this.settings.paused) {
                this.play();
            } else {
                this.pause();
            }
            return this;
        },
    };
};
