function AppWindow(){
    if (!AppWindow.count) {
        AppWindow.count = 0
    }
    this.pane = null;
    this.create();
    this.pane.id = "AppPanel" + AppWindow.count++;
}

AppWindow.prototype.create = function(){
    var deskH = window.screen.availHeight;
    var deskW = window.screen.availWidth;
    this.pane = document.createElement("div");
    this.pane.style.width = deskW + "px";
    this.pane.style.height = deskH + "px";
    this.pane.style.position = "absolute";
    this.pane.style.top = "0px"
    this.pane.style.left = "0px";
    this.pane.style.border = "1px solid #304665";       
    this.pane.style.zIndex = "1000";
	//this.pane.style.visibility = "visible";    
}
/**
 * Desenha o objeto na tela;
 */
AppWindow.prototype.draw = function(){
    try {
        document.body.appendChild(this.pane);
    } 
    catch (e) {
        alert(e);
    }
}
/**
 *
 * @param {Object} styleProperties
 */
AppWindow.prototype.setProperties = function(styleProperties){
    try {
        if (typeof styleProperties == "object") {
            for (property in styleProperties) {
                this.pane.style[property] = styleProperties[property];
            }
        }
        else {
            throw new Error("O  parâmetro passado é inválido.");
        }
    } 
    catch (erro) {
        alert("Erro na configuração de atributos de folhas de estilos.\n" + this.constructor +"\n"+ erro );
    }
}

/**
 *
 * @param {AppWindow} aObject
 */
AppWindow.prototype.appendChild = function(aObject){
    try {
        if (!aObject) {
            throw new Error("Objeto inválido em appendChild()");
        }
        this.pane.appendChild(aObject.getClass());
    } 
    catch(erro) {
        alert("Erro na adição de objeto filho.\n" + this.constructor +"\n"+ erro  );
    }
    
}
/**
 * @param {AppWindow} aObject
 */
AppWindow.prototype.removeChild = function(aObject){
    try {
        if (!aObject) {
            throw new Error("Objeto inválido em appendChild()");
        }
        this.pane.removeChild(aObject.getClass());
    } 
    catch (erro) {
        alert("Erro na remoção de objeto filho.\n" + this.constructor +"\n"+ erro );
    }
}
AppWindow.prototype.getClass = function(){
    return this.pane;
}
//===========================================================
function AppPanel(){
    this.create();
}

AppPanel.prototype = new AppWindow()
AppPanel.prototype.constructor = AppPanel;

//===========================================================
function AppTableGrid(rows, cols){
    if (!rows) {
        rows = 4
    };
    if (!cols) {
        cols = 4
    };
    this.columns = cols;
    this.rows = rows;
    this.create();
}

AppTableGrid.prototype = new AppWindow()
AppTableGrid.prototype.constructor = AppTableGrid;

/**
 *
 * @param {Object} anonymous
 */
 
 AppTableGrid.prototype.create = function(){
    var input = document.createTextNode("");
    //sem o tbody nao func ie6
    var tbody = document.createElement("tbody");
    this.pane = document.createElement("table");
    this.pane.style.position = "absolute";
    this.pane.style.top = "0px"
    this.pane.style.left = "0px";
    this.pane.style.width = "99%";  
    for (var r = 0; r < this.rows; r++) {
        var newRow = document.createElement("tr");
        for (var c = 0; c < this.columns; c++) {
            var newCol = document.createElement("td");
            newCol.innerHTML = "&nbsp;";                       
            newCol.style.border = "1px solid #304665";
            newCol.style.color = "blue";
            newCol.style.cursor= "pointer";
            newCol.style.backgroundColor = "black";
            newCol.style.textAlign = "center";
            newRow.appendChild(newCol);
        }
        tbody.appendChild(newRow);
    }
    this.pane.appendChild(tbody);
}
