﻿/*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,cellno,row1,row2,row3,row4,TF,S,inc,rowindex)
{

try{
      this.rownum=$(TB).rows.length+inc
      this.rowstyle1=row1
      this.rowstyle2=row2
      
      
      if (rowindex !=0)
      this.rownum=S+1
      
      if (TF)
      {
        this.rowstyle1=row3
        this.rowstyle2=row4    
      
      }
      
      
     for (var j=S;j<this.rownum;j++)
   {   
      for (var i=0;i<cellno;i++)
      {
      
        if (i%2==0)
        this.setclasscell(TB,j,i,this.rowstyle1); 
        else
        this.setclasscell(TB,j,i,this.rowstyle2);
      
       
      }
}
}

catch(e)
{
//do noting
}
}


