﻿/*Set properties HTML Table*/
function htmltable()
{
  this.x=null;
  this.y=null;
  this.srcTable=null;
}

htmltable.prototype.createtable=function(tbname,divname,cellSpacing,cellPadding,width,height,border)
{
 if ($(tbname))
 {
   $(divname).removeChild($(tbname)) 
 }

   this.srcTable = document.createElement("table");
   this.srcTable.id=tbname;
   this.srcTable.border = border;
   this.srcTable.cellSpacing = cellSpacing;
   this.srcTable.cellPadding = cellPadding;
   this.srcTable.height = height;
   this.srcTable.width = width;
   $(divname).appendChild(this.srcTable);
}






htmltable.prototype.insertrow=function(TB,rowindex)
{
 
 $(TB).insertRow(rowindex);

}

htmltable.prototype.createcell=function(TB,rowindex,cellindex,value)
{
 this.x=$(TB).rows[rowindex];
 this.Y=this.x.insertCell(cellindex);
 this.Y.innerHTML=value

}

htmltable.prototype.updatecell=function(TB,rowindex,cellindex,value)
{
 this.x=$(TB).rows[rowindex].cells[cellindex];
 this.x.innerHTML=value;

}


htmltable.prototype.getcontentcell=function(TB,rowindex,cellindex)
{
 this.x=$(TB).rows[rowindex].cells[cellindex];
 return this.x.innerHTML

}


htmltable.prototype.deleterow=function(TB,numrow,rowindex)
{


for (var i=0;i<numrow;i++)
{
  $(TB).deleteRow(rowindex);
}



}
htmltable.prototype.deleteCell=function(TB,rowindex,cellindex)
{
 $(TB).rows[rowindex].deleteCell[cellindex];

}



htmltable.prototype.setclassrow=function(TB,rowindex,css)
{
 this.x=$(TB).rows[rowindex]
 this.x.className=css;

}




htmltable.prototype.setalignrow=function(TB,rowindex,align)
{
 this.x=$(TB).rows[rowindex]
 this.x.align=align;

}


htmltable.prototype.setclasscell=function(TB,rowindex,cellindex,css)
{
 this.x=$(TB).rows[rowindex].cells[cellindex];
 this.x.className=css;

}


htmltable.prototype.setmultipleclasscell=function(TB,rowindex,total_cell,css)
{

for (var i=0;i<total_cell;i++)
{
this.x=$(TB).rows[rowindex].cells[i]
this.x.className=css;
}


}


htmltable.prototype.setmultipleclasscell=function(TB,rowindex,total_cell,css)
{

for (var i=0;i<total_cell;i++)
{
this.x=$(TB).rows[rowindex].cells[i]
this.x.className=css;
}


}











htmltable.prototype.setwidthcell=function(TB,rowindex,cellindex,w)
{

  this.x=$(TB).rows[rowindex].cells[cellindex];
  this.x.width=w;

}

htmltable.prototype.setheightcell=function(TB,rowindex,cellindex,h)
{

  this.x=$(TB).rows[rowindex].cells[cellindex];
  this.x.height=h;

}


htmltable.prototype.setaligncell=function(TB,rowindex,cellindex,align)
{

  this.x=$(TB).rows[rowindex].cells[cellindex];
  this.x.align=align;

}

htmltable.prototype.setvaligncell=function(TB,rowindex,cellindex,valign)
{

  this.x=$(TB).rows[rowindex].cells[cellindex];
  this.x.vAlign=valign;

}

htmltable.prototype.setclosspancell=function(TB,rowindex,cellindex,colspan)
{

  this.x=$(TB).rows[rowindex].cells[cellindex];
  this.x.colSpan=colspan;

}


htmltable.prototype.setidrow=function(TB,rowindex,id)
{

  this.x=$(TB).rows[rowindex]
  this.x.id=id;

}


htmltable.prototype.setidcell=function(TB,rowindex,cellindex,id)
{

  this.x=$(TB).rows[rowindex].cells[cellindex];
  this.x.id=id;

}



htmltable.prototype.CheckAllCell = function(TB, StartIndex, EndIndex, Check1, Check2, Uncheck1, Uncheck2, TF,CellNumber) {
    this.Row1 = Check1;
    this.Row2 = Check2;
    if (TF) {
        this.Row1 = Uncheck1;
        this.Row2 = Uncheck2;
    }

    for (var i = StartIndex; i < EndIndex; i++) {
        for (var j = 0; j < CellNumber; j++) {

            if (j % 2 == 0)
                this.setclasscell(TB, i, j, this.Row1);
            else
                this.setclasscell(TB, i, j, this.Row2);


        }
    
    }
   
}



