﻿var Table = Class.create();
Table.prototype = 
{
	initialize:function(tabId, rowIndex)
	{
        this.Id = tabId;
        this.Obj = $(this.Id);
        this.ArrayCell = new Array();
        for(var i=0; i<this.Obj.rows[rowIndex].cells.length; i++)
	    {
		    this.ArrayCell[i] = this.Obj.rows[rowIndex].cells[i].innerHTML;
	    }
	    this.Obj.deleteRow(rowIndex);
	},
	
	insertRow:function(rowIndex)
	{
		var objRow = this.Obj.insertRow(rowIndex);
	    objRow.id = this.id+'tr'+rowIndex;
	    for(var i=0; i<this.ArrayCell.length; i++)
	    {
		    var objCell = objRow.insertCell(i);
		    objRow.cells[i].innerHTML = this.ArrayCell[i];
	    }
	    this.iniRow(objRow);
	    return objRow;
	},
	
	iniRow:function(row)
	{
	    
	},
	
	removeRow:function(rowIndex)
	{
	    this.Obj.deleteRow(rowIndex);
	},
	
	removeRowById:function(id)
	{
        for(var i=0; i<this.Obj.rows.length; i++)
	    {
		    if(this.Obj.rows[i].id==id)
		        this.removeRow(i);
	    }
	},
	
	rowCount:function()
	{
	    return this.Obj.rows.length;
	},
	
	findControl:function(rowIndex, id)
	{
	    return getChildNodeById(this.Obj.rows[rowIndex], id);
	}
}