function Slideshow(_bi, _speed) {
    var ref = this;
    this.bi = SJEL.$(_bi);
    this.loading = SJEL.CE("img");
    this.loading.src = "/images/loading.gif";
    this.loading.className = "loading";
    this.slsOn = true;
    this.slSpeed = _speed ? _speed : 2000;
    this.fadeSpeed = 460;
    this.slId = 0;
    this.thmbs = new Array();
    this.mo = new SJEL.Morph();
    this.OnSlTimer = function () {
        ref.ShowBigImage(++ref.slId)
    };
    this.tsl = new SJEL.Timer(this.OnSlTimer);
    this.tsl.SetSpeed(this.slSpeed);
    this.ShowBigImage = function (_id) {
        var id = _id;
        if (id == this.thmbs.length) id = 0;
        this.slId = id;
        var thmb = this.thmbs[id];
        if (thmb.bimg.src != "") this.FadeBigImage(thmb);
        else thmb.LoadBigImage()
    };
    this.FadeBigImage = function (_thmb) {
        this.bi.innerHTML = "";
        this.bi.href = _thmb.tl;
        SJEL.SStyle(_thmb.bimg, {
            opacity: 0.0
        });
        this.bi.appendChild(_thmb.bimg);
        this.mo.Init(_thmb.bimg, {
            opacity: 1.0
        }, this.fadeSpeed);
        this.mo.Morph()
    };
    this.Thumb = function (_l, _s, _i) {
        this.tl = _l;
        this.bis = _s;
        this.id = _i;
        this.bimg = SJEL.CE("img");
        this.bimg.r = this;
        this.bimg.onload = function () {
            ref.ShowBigImage(this.r.id)
        };
        this.LoadBigImage = function () {
            ref.bi.innerHTML = "";
            ref.bi.appendChild(ref.loading);
            this.bimg.src = this.bis
        }
    };
    this.OnSlTimer = function () {
        ref.ShowBigImage(++ref.slId)
    };
    this.AddImage = function (_l, _s) {
        this.thmbs.push(new this.Thumb(_l, _s, this.thmbs.length))
    };
    this.Start = function () {
        if (this.thmbs.length > 1) this.tsl.Start(true)
    }
};
