// Date : 23 September, 2008

function appendPayment(tblStr)
{
  var tbl = document.getElementById(tblStr);
  var row = tbl.insertRow(tbl.rows.length);
  
  // Cell 1: input text [position]
  var cellInputText = row.insertCell(0);
  var el = document.createElement('textarea');
  el.setAttribute('name', 'm_pay_year[]');
  el.setAttribute('cols', '20');
  el.setAttribute('rows', '3');
  el.style.setAttribute('overflow', 'hidden');
  el.className = 'input_dtbl_ta';
  cellInputText.appendChild(el);
  
  // Cell 2: input text [position]
  var cellInputText = row.insertCell(1);
  var el = document.createElement('textarea');
  el.setAttribute('name', 'm_pay_fee[]');
  el.setAttribute('cols', '10');
  el.setAttribute('rows', '3');
  el.style.setAttribute('overflow', 'hidden');
  el.className = 'input_dtbl_ta';
  cellInputText.appendChild(el);
  
  // Cell 2: input text [position]
  var cellInputText = row.insertCell(2);
  var el = document.createElement('textarea');
  el.setAttribute('name', 'm_pay_paid[]');
  el.setAttribute('cols', '10');
  el.setAttribute('rows', '3');
  el.style.setAttribute('overflow', 'hidden');
  el.className = 'input_dtbl_ta';
  cellInputText.appendChild(el);
  
  // Cell 2: input text [position]
  var cellInputText = row.insertCell(3);
  var el = document.createElement('textarea');
  el.setAttribute('name', 'm_pay_due[]');
  el.setAttribute('cols', '10');
  el.setAttribute('rows', '3');
  el.style.setAttribute('overflow', 'hidden');
  el.className = 'input_dtbl_ta';
  cellInputText.appendChild(el);

  // Cell 3: input text [organization]
  var cellInputText = row.insertCell(4);
  var el = document.createElement('textarea');
  el.setAttribute('name', 'm_pay_remarks[]');
  el.setAttribute('cols', '60');
  el.setAttribute('rows', '3');
  el.className = 'input_dtbl_ta';
  el.style.setAttribute('overflow', 'hidden');
  cellInputText.appendChild(el);
  
  // Cell 4: input Button [delete]
  var cellInputText = row.insertCell(5);
  var el = document.createElement('input');
  el.setAttribute('type', 'button');
  el.setAttribute('name', 'delete');
  el.setAttribute('value', 'del');
  el.className = 'input_btn';
  el.onclick = function () {removePayment(this)};
  cellInputText.appendChild(el);
  
}

// deletes the specified row from the table
function removePayment(src)
{
	/* 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 case <tr>)
	*/			
	var oRow = src.parentElement.parentElement;		
	
	//once the row reference is obtained, delete it passing in its rowIndex			
	document.all("tblPayment").deleteRow(oRow.rowIndex);		
}
