//create a table
function addNewTable(rows,cols,newid)
{
	//alert('adding table named '+newid);
      // get the reference for the body
        var body = document.getElementsByTagName("body")[0];

        // creates a <table> element and a <tbody> element
        var tbl     = document.createElement("table");
        var tblBody = document.createElement("tbody");

        // creating all cells
        for (var j = 0; j < rows; j++) {
            // creates a table row
            var row = document.createElement("tr");

            for (var i = 0; i < cols; i++) {
                // Create a <td> element and a text node, make the text
                // node the contents of the <td>, and put the <td> at
                // the end of the table row
                var cell = document.createElement("td");
                var cellText = document.createTextNode("cell "+j+", column "+i);
                cell.appendChild(cellText);
	cell.setAttribute("align","center");	//alignment
                row.appendChild(cell);
            }

            // add the row to the end of the table body
            tblBody.appendChild(row);
        }

        // put the <tbody> in the <table>
        tbl.appendChild(tblBody);
        // appends <table> into <body>
        body.appendChild(tbl);
        // sets the border attribute of tbl to 1;
        tbl.setAttribute("border", "1");
        tbl.setAttribute("id", newid);	
}

function rowcount(tableid)
{
	var t=document.getElementById(tableid);
	return t.getElementsByTagName('tr').length;

}
  function addNewRow(tableID,noofcols)
  {
	//alert('adding new row in ' + tableID + ' \nwith ' + noofcols +' columns');

	    // Get a reference to the table
	    var tableRef = document.getElementById(tableID);

	var newposition=rowcount(tableID);	

	    // Insert a row in the table at last row index 
	    var newRow   = tableRef.insertRow(newposition);

	    // Insert cells in the row at index i
	for(var i=0;i<noofcols;i++)
	{
	    var newCell  = newRow.insertCell(i);

	    // Append a text node to the cell
	    var newText  = document.createTextNode('New  cell '+i)
	newCell.setAttribute("align","right");	//alignment
	    newCell.appendChild(newText);

	}
  }

//11:20 AM 10/16/2008
//MODIFY TABLE USING JQUERY
function setdecimals(n){
	//set decimal to n digits
	$("tr:odd").css("background", "#E0FFFF");	//alternate color stripe
	$('td').each(function (x) {if($(this).attr('value')) {$(this).text(eval($(this).attr('value')).toFixed(n))}})
}