/* Cached on Thu, 30 Jan 2025 19:51:33 */
LightBox = (function($) {
    function LightBox(options) {
        this.options = options || {};
        var defaultOptions = this.__proto__.options;
        for (var prop in defaultOptions) if (defaultOptions.hasOwnProperty(prop)) {
            if (!this.options.hasOwnProperty(prop)) {
                this.options[prop] = defaultOptions[prop];
            }
        }
    }

    LightBox.prototype.id = null;

    LightBox.prototype.options = {
        theme: '',
        title: '',
        content: '',
        footerContent: '',
        width: '300px',
        removeOnClose: false
    };

    LightBox.prototype.show = function() {
        var _this = this;
        if (this.id != null) {
            var box = $('[data-lightbox-id=' + this.id + ']').fadeIn(150);
            if (!!box.length) {
                return box;
            }
        }
        this.id = (new Date).getSeconds().toString() + ($('[data-lightbox-id]').length + 1).toString();
        var wrapper = $('<div class="light-box-form">')
            .append(
            $('<div class="light-box-title">')
                .text(this.options.title)
                .prepend($('<span class="light-box-close">').text(window.intl.close + ' [x]'))
        )
            .append(
            $('<div class="light-box-body">').append(this.options.content)
        )
            .width(this.options.width);
        if (this.options.footerContent) {
            wrapper.append($('<div class="light-box-footer">').append(this.options.footerContent));
        }
        return $('<div class="light-box">')
            .attr('data-lightbox-id', this.id)
            .addClass(this.options.theme)
            .append(wrapper)
            .appendTo('body')
            .fadeIn(150)
            .on('closed', function() {
                if (_this.options.removeOnClose) {
                    $(this).remove();
                    _this.id = null;
                }
            });
    };

    LightBox.prototype.getElement = function() {
        if (this.id != null) {
            return $('[data-lightbox-id=' + this.id + ']');
        }
        return null;
    };

    LightBox.prototype.close = function() {
        if (this.id != null) {
            this.getElement().trigger('click');
        }
    };

    $(function() {
        $('.lightBox').click(function(e) {
            if (e.target == this) {
                $(this).fadeOut(250);
            }
        });
        $('.lightBox .close').click(function() {
            $(this).parents('.lightBox').click();
        });
        $('body')
            .delegate('.light-box', 'click', function(e) {
                if ($(e.target).hasClass('light-box'))
                    $(this).fadeOut(150, function() {
                        $(this).trigger('closed');
                    });
            })
            .delegate('.light-box-close', 'click', function() {
                $(this).parents('.light-box').click();
            });
    });

    return LightBox;
})(jQuery);

function getDocumentViewerLightbox(title, url) {
    return new LightBox({
        title: title,
        width: 700,
        theme: 'no-pad orange with-preloader',
        content: $('<iframe class="iframe-unstyled">')
            .css({
                visibility: 'hidden',
                width: '100%',
                height: '450px'
            })
            .attr('src', '//docs.google.com/viewer?url=' + encodeURIComponent(url) + '&embedded=true')
            .on('load', function() {
                $(this)
                    .css('visibility', 'visible')
                    .parents('.light-box').removeClass('with-preloader');
            })
    });
}
function getYoutubeVideoLightbox(title, video) {
    return new LightBox({
        title: title,
        width: 700,
        theme: 'ytb ytb-red with-preloader',
        removeOnClose: true,
        content: $('<iframe class="iframe-unstyled">')
            .css({
                visibility: 'hidden',
                width: '100%',
                height: '394px'
            })
            .attr({
                allowfullscreen: 'allowfullscreen',
                src: '//www.youtube.com/embed/' + video + '?rel=0&amp;showinfo=0&amp;autoplay=1'
            })
            .on('load', function() {
                $(this)
                    .css('visibility', 'visible')
                    .parents('.light-box').removeClass('with-preloader');
            })
    });
}