lightpopup = {
    _mask: null,
    _container: null,
    init: function(maskBg) {
        if(this._mask != null)return;
        this._mask = document.createElement('div');
        this._container = document.createElement('iframe');
        $(this._mask).hide()
            .css('background', maskBg)
            .css('z-index', '9999')
            .css('position', 'fixed')
            .css('right', '0')
            .css('left', '0')
            .css('top', '0')
            .css('bottom', '0');
        $(this._container).hide()
            .css('position', 'fixed')
            .css('top', '0')
            .css('bottom', '0')
            .css('width', '600')
            .css('margin-left', 'auto')
            .css('margin-right', 'auto')
            .css('z-index', '10000');
        $('body')
            .append(this._mask)
            .append(this._container);
    },
    open: function(url) {
        this._setVisible(true);
        this._container.src = url;
    },
    _isVisible: false,
    _setVisible: function(visible) {
        if(visible && !this._isVisible) {
            $(this._mask).fadeTo(200, 0.95, function() {this._onVisibilityChanged(true);})
        }else if(!visible && this._isVisible) {
            $(this._container).hide();
            $(this._mask).fadeTo(200, 0, function() {this._onVisibilityChanged(false);})
        }
    },
    _onVisibilityChanged: function(newVisibility) {
        this._isVisible = newVisibility;
        if(!this._isVisible) {
            $(this._mask).hide();
        } else {
            $(this._container).show();
        }
    }
};
