// JavaScript Document
function EducationTable(objName,tableID)
{
		this.maxRow = 5;		
		this.tableID = tableID;
		this.objName = objName;
		
		// public method
		this.getRowCount = ET_getRowCount;
		this.addRow = ET_addRow;
		this.removeRow = ET_removeRow;		

}
	
function ET_getRowCount(){
		var table = document.all?document.all[this.tableID]:document.getElementById(this.tableID);		
		return table?table.rows.length-1:0;
}

function ET_addRow()
{			
		var table = document.all?document.all[this.tableID]:document.getElementById(this.tableID);		
		if (table && table.rows && table.insertRow && table.rows.length<=this.maxRow) 
		{
			var sourceRow = table.rows[1];
			var rowsCount = table.rows.length;
			var newRow = table.insertRow(table.rows.length);
			newRow.name = this.tableID+'_Row'+rowsCount;
		
			var cell;
			// Insert Education DateForm Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtEduDateFrom'+rowsCount+'" type="text" class="Textbox" size="10" maxlength="10"  onclick="calEducation.select(this,this.name,\'dd/MM/yyyy\')"/>'
			
			// Insert Education DateTo Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtEduDateTo'+rowsCount+'" type="text" class="Textbox" size="10" maxlength="10"  onclick="calEducation.select(this,this.name,\'dd/MM/yyyy\')"/>'
			
			// Insert  Institute Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtEduInstitue'+rowsCount+'" type="text" class="Textbox" size="30" maxlength="100" />'
			
			cell = newRow.insertCell(newRow.cells.length);	
			var list = document.createElement('select');
			list.name = "listEduDegree"+rowsCount;
			var sourceOptions = sourceRow.cells[3].childNodes[0].options;
			for (var i=0;i<sourceOptions.length;i++){				
				var newOption = document.createElement('option');
				newOption.text = sourceOptions[i].text;		
				newOption.value= sourceOptions[i].value;
				list.options.add(newOption,i);
			}			
			cell.appendChild(list);
			
			// Insert Remove Button			
			cell = newRow.insertCell(newRow.cells.length);
			cell.innerHTML = '<input name="'+this.tableID+'_btnRemove" type="button" class="Button" value="Remove" onclick="'+this.objName+'.removeRow(\''+newRow.name+'\')"/>';
		}
}	
	
function ET_removeRow(rowName)
{			
		var table =  document.all?document.all[this.tableID]:document.getElementById(this.tableID);		
		if (table){			
			for (var i=1;i<table.rows.length;i++){
				if (table.rows[i].name==rowName){
					table.deleteRow(i);
					break;
				}
			}
		}	
}