/**
 * @requires cms
 */
cms.Slideshow = function(images, opts)
{
    this.intervalId;
    this.images = images;
    this.opts = opts || {};

    this.enableAutoplay = function() {
        var fn = EventUtils.Delegate.create(this, 'next', this.nextSlide);
        this.intervalId = setInterval(fn, this.opts.waittime);
    }

    this.disableAutoplay = function() {
        clearInterval(this.intervalId);
    }

    this.prevSlide = function() {
        $('#lbPrevLink').trigger('click');
    }

    this.nextSlide = function() {
        $('#lbNextLink').trigger('click');
    }

    this.load = function() {

        if (!this.opts['loop']) this.opts.loop = true;
        if (!this.opts['counterText']) this.opts.counterText = cms.Lang.getText('LightboxProgress');
        if (!this.opts['waittime']) this.opts.waittime = 5000;

        $.slimbox(this.images, 0, this.opts)

        $('#lbPrevLink').html('<span>' + cms.Lang.getText('LightboxPrevLink') + '</span>');
        $('#lbNextLink').html('<span>' + cms.Lang.getText('LightboxNextLink') + '</span>');
        $('#lbCloseLink').html('<span>' + cms.Lang.getText('LightboxCloseLink') + '</span>');

        if (this.opts['autoplay'] == 1) this.enableAutoplay();
    }



}

