var cWindow = {
    
    // abstract methods
    applyData: function(data)
    {
        alert('Window is reloaded');
    },

    reload: function()
    {
        var r = new Request();
        r.send(URL_AJAX_HANDLER, {'rm': 'window_reload', 'class': this._class}, this);
        delete(r);
    },

    handleJSException: function(e)
    {
        alert(e);
    },

    requestCallback: function(result, request_params, exception)
    {
        try {
            if (request_params.rm == 'window_reload') {
                this.applyData(result);
            }
        }
        catch (e) {
            this.handleJSException(e);
        }
    },

    // public methods
    setVisibility: function(visibile)
    {
        this.dom_window.style.display = visibile ? 'block' : 'none';
        this.is_visible = visibile;
    },
    
    getName: function()
    {
        return this.name;
    }
}

function Window(data) 
{
    if (!window.windows) {
        window.windows = [];
    }
            
    for (var f in cWindow) {
        this[f] = cWindow[f];        
    }    

    if (!data.name) {
        throw new Exception('ERROR_WINDOW_UNKNOWN_NAME');
    }
    
    this.name = data.name;
    this._class = data._class;
    this.dom_window = _(this.name);

    window.windows[this.name] = this;
    this.is_visible = data['visible'];
}


