var slimboxMagnify = {
    init: function (A) {
        this.options = $extend({
            magnifyImg: "magnify.png",
            magnifyImgWidth: 24,
            magnifyImgHeight: 24,
            magnifyImgMarginB: 8,
            magnifyImgMarginR: 8,
            magnifyTitle: "Click on image to magnify",
            magnifyDuration: 400,
            magnifyTransition: Fx.Transitions.Sine.easeInOut
        }, A || {});
        this.magnifyWrapper = new Element("div").setProperty("title", this.options.magnifyTitle).setStyles({
            position: "absolute",
            display: "block",
            cursor: "pointer",
            opacity: 0,
            background: "transparent url(" + this.options.magnifyImg + ") no-repeat",
            width: this.options.magnifyImgWidth,
            height: this.options.magnifyImgHeight,
            top: 0,
            left: 0
        }).injectInside(document.body);
        this.magnifyWrapper.addEvent("mouseover", this.showMagnify.bindWithEvent(this.magnifyWrapper, {
            magnifyWrapper: this.magnifyWrapper,
            options: this.options
        }));
        this.magnifyWrapper.addEvent("mouseout", this.hideMagnify.bindWithEvent(this.magnifyWrapper, {
            magnifyWrapper: this.magnifyWrapper,
            options: this.options
        }));
        this.magnifyWrapper.fx = new Fx.Morph(this.magnifyWrapper, {
            duration: this.options.magnifyDuration,
            transition: this.options.magnifyTransition,
            wait: false
        });
        $each(document.links, function (B) {
            if (B.rel && B.rel.test(/^lightbox/i) && B.getElement("img")) {
                B.addEvent("mouseover", this.showMagnify.bindWithEvent(B, {
                    magnifyWrapper: this.magnifyWrapper,
                    options: this.options
                }));
                B.addEvent("mouseout", this.hideMagnify.bindWithEvent(B, {
                    magnifyWrapper: this.magnifyWrapper,
                    options: this.options
                }))
            }
        }, this)
    },
    showMagnify: function (B, A) {
        var C = this.getElement("img");
        if (C) {
            var D = C.getCoordinates();
            A.magnifyWrapper.onclick = this.onclick;
            A.magnifyWrapper.setStyles({
                top: D.top + D.height - A.options.magnifyImgHeight - A.options.magnifyImgMarginB,
                left: D.left + D.width - A.options.magnifyImgWidth - A.options.magnifyImgMarginR
            })
        }
        A.magnifyWrapper.fx.start({
            opacity: [1]
        })
    },
    hideMagnify: function (B, A) {
        A.magnifyWrapper.fx.start({
            opacity: [0]
        })
    }
}
