// JavaScript Document
// JavaScript Document
function CareerTable(objName,tableID)
{
		this.maxRow = 10;		
		this.tableID = tableID;
		this.objName = objName;
		
		// public method
		this.getRowCount = CT_getRowCount;
		this.addRow = CT_addRow;
		this.removeRow = CT_removeRow;		

}
	
function CT_getRowCount(){
		var table = document.all?document.all[this.tableID]:document.getElementById(this.tableID);		
		return table?table.rows.length-1:0;
}

function CT_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="txtCareerDateFrom'+rowsCount+'" type="text" class="Textbox" size="10" maxlength="10"  onclick="calCareer.select(this,this.name,\'dd/MM/yyyy\')"/>'
			
			// Insert Education DateTo Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtCareerDateTo'+rowsCount+'" type="text" class="Textbox" size="10" maxlength="10"  onclick="calCareer.select(this,this.name,\'dd/MM/yyyy\')"/>'
			
			// Insert  Institute Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtCompany'+rowsCount+'" type="text" class="Textbox"  />'
			
			// Insert  Institute Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtPosition'+rowsCount+'" type="text" class="Textbox" size="15" maxlength="40" />'
		
			// Insert  Institute Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtSalary'+rowsCount+'" type="text" class="Textbox" size="10" maxlength="10" />'
			
			// Insert  Institute Cell
			cell = newRow.insertCell(newRow.cells.length);				
			cell.innerHTML = '<input name="txtReason'+rowsCount+'" type="text" class="Textbox" size="20" maxlength="100" />'
			
			// 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 CT_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;
				}
			}
		}	
}