//////////////////////////////////////////////////////////////////////////////
function RowData(size){
	this.size=size;
	this.cells=new Array(size);
}
//////////////////////////////////////////////////////////////////////////////
function addRows(tableDataObj,tableId,addRowMethod)
{
	/*
	addRowMethod needs to be defined according to table structure See addRowExample
	*/
	for (k=0;k<tableDataObj.length;k++){
		rowDataObj=tableDataObj[k];
		addRowMethod(rowDataObj,tableId);
	}    
}
//////////////////////////////////////////////////////////////////////////////
function removeAllRows(tableId)
{
   try
   {
	   table = document.getElementById(tableId);
	   if(table!=null&&table!=undefined){
		  //for(index=0;index<table.rows.length; index++){
		  for(index=table.rows.length-1; index > 0; index--){
		       table.deleteRow(index); 
		   }
		   /*
		   	for(index=table.rows.length-1; index > -1; index--){
		       table.deleteRow(index); 
		   	}
		   */
	   }
	   else
	   {
	   	alert(tableId + ' undefined');
	   }
	}
	catch(e){
		alert('Error in deleting table rows: '+e.message);
	}   
}
/////////////////////////////////////////////////////////////////////////////////
//deletes the specified row from the table
function removeRow(src,tableId)
   {
    /* src refers to the input button that was clicked. 
       to get a reference to the containing <tr> element,
       get the parent of the parent (in this case <tr>)
    */   
    var oRow = src.parentElement.parentElement;  
    //once the row reference is obtained, delete it passing in its rowIndex   
    document.all(tableId).deleteRow(oRow.rowIndex);  
}
/////////////////////////////////////////////////////////////////////////////////
function addRowSample(rowData,tableId)
   {
	try
	{
	    //add a row to the rows collection and get a reference to the newly added row
	    //var newRow = document.all(tableId).insertRow();
	    var table = document.getElementById(tableId);
	  	var lastRow = table.rows.length;
	    // if there's no header row in the table, then iteration = lastRow + 1
	    var iteration = lastRow;
	    var newRow = table.insertRow(lastRow);
	    for (i=0;i<rowData.cells.length;i++){
	    	if(i==0){
				var oCell = newRow.insertCell(i);
			    oCell.innerHTML = "<input type='checkbox' id='NEW_PLAN"+i+"' class='checkbox' name='NEW_PLAN' value='"+rowData.cells[i]+"'/>";
	       		oCell.className='firstcol';	    		
	    	}
	    	else if(i==rowData.cells.length-1){
				var oCell = newRow.insertCell(i);
				oCell.innerHTML = rowData.cells[i];
	       		oCell.className='lastcol';	    		
	    	}
	    	else{
	    		var oCell = newRow.insertCell(i);
	    		oCell.innerHTML = rowData.cells[i];
	    		oCell.className='centercol';
	    	}
	    }//end for
	  }
	  catch(e){
	  	alert('Error in adding new Plans to table: '+e.message);
	  }  
  }
////////////////////////////////////////////////////////////////////////////////// 