// Date : 23 September, 2008

function appendRowWcm(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('input');
  el.setAttribute('name', 'wcm_mid[]');
  el.setAttribute('size', '10');
  el.className = 'input_dtbl_t';
  cellInputText.appendChild(el);

  // Cell 2: input text [organization]
  var cellInputText = row.insertCell(1);
  var el = document.createElement('input');
  el.setAttribute('name', 'wcm_name[]');
  el.setAttribute('size', '35');
  el.className = 'input_dtbl_t';
  cellInputText.appendChild(el);
  
  // Cell 3: input text [organization]
	var cellInputText = row.insertCell(2);
	var el = document.createElement('select');
	el.setAttribute('name', 'wcm_status[]');
	el.options[0] = new Option('', '');
	el.options[1] = new Option('Convener', 'convener');
	el.options[2] = new Option('Member', 'member');
	cellInputText.appendChild(el);
  
  // Cell 4: input Button [delete]
  var cellInputText = row.insertCell(3);
  var el = document.createElement('input');
  el.setAttribute('type', 'button');
  el.setAttribute('name', 'delete');
  el.setAttribute('value', 'delete');
  el.className = 'input_btn';
  el.onclick = function () {removeRowWcm(this);};
  cellInputText.appendChild(el);
  
  // Cell 5: input Button [delete]
  var cellInputText = row.insertCell(4);
  var el = document.createElement('input');
  el.setAttribute('type', 'button');
  el.setAttribute('name', 'insert');
  el.setAttribute('value', 'Insert');
  el.className = 'input_btn';
  el.onclick = function () {OpenWindowMl(this);};
  cellInputText.appendChild(el);
  
}

// deletes the specified row from the table
function removeRowWcm(src)
{
	var oRow = src.parentElement.parentElement;		
	
	//once the row reference is obtained, delete it passing in its rowIndex			
	document.all("tblWcommittee").deleteRow(oRow.rowIndex);		
}

// Open's stakeholder window and send value to window.location
function OpenWindowMl(obj){
	var curRow = obj.parentNode.parentNode;
	var tbl = curRow.parentNode.parentNode;
	var rIndex = curRow.sectionRowIndex;

   var winPop = window.open("include/m_add_wcm.php?cr="+rIndex,"winPop", "scrollbars = 1, resizable = 1, width = 940, height = 720,  left=20, top=0");
	winPop.focus();
}

// Insert's selected Member's record to Working Commiter  
function passChildToParentMl(obj){
	
	var curRow = obj.parentNode.parentNode;
	var tbl = curRow.parentNode.parentNode;
	var rIndex = curRow.sectionRowIndex;
	
	var id = tbl.rows[rIndex].cells[0].innerText;
	var name = tbl.rows[rIndex].cells[2].innerText;

	// Get's the cell of parent window
	var parentTable = opener.document.getElementById("tblWcommittee");
	parentTable.rows[currentRow].cells[0].firstChild.value = id;
	parentTable.rows[currentRow].cells[1].firstChild.value = name;
	self.close();
}