/// class ProspectDirector.Web.UI.Window

/**
@constructor
@class Window
@namespace Web.UI
@param options {Object}
**/
ProspectDirector.Web.UI.Window = Class.extend({

    //================================
    // FIELDS
    //================================

    _DOM: null,
    options: null,

    //================================
    // CONSTRUCTOR
    //================================

    init: function (options) {

        this.options = {
            id: uuid.v4(),
            config: {
                modal: true,
                content: null,
                markup: null,
                minHeight: 50
            },
            events: {},
            callbacks: {}
        };

        $.extend(true, this.options, options);

        this.render();
        this.activate();

    },

    //================================
    // PROPERTIES
    //================================

    get_id: function () {
        return this.options["id"];
    },

    //================================
    // PUBLIC METHODS
    //================================

    activate: function () {
        this.DOM().activate();
    },

    destroy: function (options) {

        if (options === undefined) {
            this._trigger("cancel", {});
        }
        else {
            this._trigger(options.command, options.data);
        }

        this.DOM().destroy();

    },

    DOM: function () {

        if (!this._DOM) {
            this._DOM = new ProspectDirector.Web.UI.WindowDOM(this.options);
        }

        return this._DOM;

    },

    maximize: function () {
        this.DOM().maximize();
    },

    render: function () {
        this.DOM().render();
    },

    resize: function () {
        this.DOM().resize();
    },

    setOptions: function (options) {
        this.DOM().setOptions(options);
    },

    //================================
    // PRIVATE METHODS
    //================================

    _trigger: function (command, args) {

        var callbacks = this.options["callbacks"],
            callback = null;

        if (command === null && $.isPlainObject(callbacks)) {
            return;
        }

        callback = callbacks[command];

        if ($.isFunction(callback)) {
            callback(this, args);
        }

    }

});
