InitializeExtBase();
InitializeWindowsControl();

KankeiWebUI.ExtWindow = function(element) {

    KankeiWebUI.ExtWindow.initializeBase(this, [element]);

}

KankeiWebUI.ExtWindow.prototype = {

    extObjectType: Ext.Window,
    
    initialize: function() {
        // Initialize
        KankeiWebUI.ExtWindow.callBaseMethod(this,'initialize');
    },
    
    componentCreated: function() {
        this.extObject.windowName = this.get_element().id;
        KankeiWebUI.ExtWindowsControl.addWindow(this.extObject);
        
        this.extObject.show();
        this.extObject.hide();
        
        if(this.get_ShowImmediately()) {
            this.extObject.show();
        }
    },
    
    getConfig: function(){
        var config = {};
        var id = this.get_element().id;

        config.el = id;
        //config.layout = 'absolute';
        config.width = this.get_Width();
        config.height = this.get_Height();
        config.closeAction = 'hide';
        config.plain = true;
        config.title = this.get_Title();
        config.buttons = eval(this.get_Buttons());
        
        config.items = new Ext.Container({
                                applyTo: this.get_ItemsName()
                           });
                           
        var me = this;
                           
        for(i = 0; i < config.buttons.length; i++) {
            config.buttons[i].handler = function() {
                me.executeCommand(this.commandName);
            };
        };

        this.setConfigData(config);

        return config;
    },
    
    setConfigData: function(config){
        // MustOverride / Abstract method
    },
    
    get_Width: function() {
        return this._width;
    },
    set_Width: function(value) {
        this._width = value;
    },
    
    get_Height: function() {
        return this._height;
    },
    set_Height: function(value) {
        this._height = value;
    },
    
    get_Title: function() {
        return this._title;
    },
    set_Title: function(value) {
        this._title = value;
    },
    
    get_Buttons: function() {
        return this._buttons;
    },
    set_Buttons: function(value) {
        this._buttons = value;
    },
    
    get_ItemsName: function() {
        return this._itemsName;
    },
    set_ItemsName: function(value) {
        this._itemsName = value;
    },
    
    get_ShowImmediately: function() {
        return this._showImmediately;
    },
    set_ShowImmediately: function(value) {
        this._showImmediately = value;
    },
    
    executeCommand: function(commandName) {
        this.invoke(commandName);
    }
}

KankeiWebUI.ExtWindow.registerClass('KankeiWebUI.ExtWindow',KankeiWebUI.ExtControlBase);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();