
if(Object.isUndefined(UI) || Object.isUndefined(UI.Window)) throw "UI.Message based on UI.Window";

UI.Window.addMethod('forceRendering', function() {
    this.startDrag(new Element('div'));
    this.endDrag();
});

UI.Message = Class.create(UI.Window, {
    initialize: function($super, message, buttons, options) {
        this.message = message;
        buttons = buttons || {OK:'destroy'};
        if(Object.isString(buttons)) {
            var button = buttons;
            buttons = {};
            buttons[button] = 'destroy';
        }
        this._buttons = $H(buttons);


        $super(Object.extend({
            height: 120,
            width: 250,
            superflousEffects: false
        }, options));
        this.disableButton('minimize')
            .disableButton('maximize')
            .setResizable(false)
        this.init();
        this.forceRendering();
    },
    init: function() {
        this.content.update('');
        this.content.insert(new Element('div', {
            className: 'ui_message'
        }).update(this.message));
        var buttons = new Element('div', {
            className: 'ui_message_buttons'
        });
        this._buttons.each(function(pair) {
            buttons.insert(new Element('input', {
                type: 'button',
                value: pair[0],
                className: 'ui_message_button'
            }).observe('click', this.getEventListener(pair[1])));
        }, this);
        this.content.insert(buttons);
    },
    getEventListener: function(func) {
        return Object.isString(func) ? this[func].bind(this) : func.bind(this, this);
    }
});
