var Curtain = {
    draw: function(oops) {
        var ct = document.createElement('div');
        ct.setAttribute('id', this._id);
        this._hide_select();
        document.body.appendChild(ct);
        this._position();
        this._fit();
        new Effect.Appear(this._id, {duration:0.3, from:0.3, to:0.7, afterFinish:oops});
        this.interval = window.setInterval(function() { this._fit(); }.bind(this), 200);
    },

    _position: function() {
        with ($(this._id).style) {
            position   = 'absolute';
            top        = '0px';
            left       = '0px';
            background = '#D4D4D4';
            zIndex     = '100';
            filter     = 'alpha(opacity=0)';
        }
    },

    hide: function() {
        new Effect.Opacity(this._id, {duration:0.1, to:0, afterFinish:this._remove.bind(this)});
        this._show_select();
        window.clearInterval(this.interval);
    },

    _fit: function() {
        var dimension = Element.getDimensions(document.body);
        $(this._id).style.width  = dimension.width + 'px';
        $(this._id).style.height = dimension.height + 'px';
    },

    _id: 'curtain',

    _hide_select: function() {
        $$('body select').each(function(el) {
            Element.hide(el);
        });
    },

    _show_select: function() {
        $$('body select').each(function(el) {
            Element.show(el);
        });
    },
    _remove: function() {
        this._show_select();
        Element.remove(this._id);
    }
}

