	var fieldArray;
	var IDEE;
	var position;
	var classname;
	var count;
	var defaultSize;
	var createdNames;



function DynTextFieldCreator(mainContainer,rowClassname)
{
	this.classname = rowClassname;
	this.mainContainer = mainContainer;
	this.position = 1;
	this.fieldArray = new Array();
	this.IDEE = new Array();
	this.createdNames = new Array();
	this.count = 0;
	this.addRow = addRow;
	this.removeRow = removeRow;
	this.setOuterDivName = setOuterDivName;
	this.setRowsClass = setRowsClass;
	this.setDefaultFileSize = setDefaultFileSize;
	this.getNumberOfRows =getNumberOfRows;
	this.getCreatedNames = getCreatedNames;

}

function addRow(array_of_basename_and_values) // has to be an  an associative array but must be defined as an object e.g new Object
{
	
	try
	{
		var div = document.createElement("div");
		div.id = "rows_"+this.position;
		div.className = this.classname;
		var __names = "|";
		var new_array_of_basename_and_values = new Object();	
		for ( var ki in array_of_basename_and_values )
		{
		    new_array_of_basename_and_values[ki] = "";
			var input =  document.createElement("input");
			input.id = "rows_"+ ki +this.position;
			input.name = "rows_"+ ki +this.position;
			input.type = "text";
			if(ki.indexOf("firstname") >= 0 || ki.indexOf("lastname") >= 0 )
			{
				input.style.width ="125px";//
			}
			__names = __names + input.name + "|";
			
			if(array_of_basename_and_values[ki] != "")
			{
				input.value = array_of_basename_and_values[ki];
			}
			else
			{
					input.value = "";
			}
			var input_span =  document.createElement("span");
			input_span.appendChild(input);
			div.appendChild(input_span);
		}
		var section_table = document.createElement("TBODY");
		var section_table_main = document.createElement("TABLE");
		var section_row1  = document.createElement('TR');
		var section_cell1 = document.createElement('TD');
		var section_cell2 = document.createElement('TD');
		var section_cell3 = document.createElement('TD');
		var minus = document.createElement('input');				
		var plus = document.createElement('input');
		
		plus.type ="button";
		minus.type ="button";
		plus.value ="+";
		minus.value ="-";
		plus.style.height ="18px";
		plus.style.width ="26px";
		minus.style.height ="18px";
		minus.style.width ="26px";
		var DynTextFieldCreator = this;
		minus.onclick = function()
		{
			DynTextFieldCreator.removeRow(DynTextFieldCreator.IDEE[minus.id]);

		}

		plus.onclick = function()
		{
			DynTextFieldCreator.addRow(new_array_of_basename_and_values);

		}
		
		minus.className = "pointer";
		plus.className = "pointer";
		minus.alt = "Remove row";
		plus.alt = "Add new row";
		minus.title = "Remove row";
		plus.title = "Add new row";
		plus.id = "plus_"+this.position;
		minus.id = "minus_"+this.position;
		this.IDEE[minus.id] = this.position;
		this.IDEE[plus.id] = this.position;

		section_cell1.appendChild(minus);
		section_cell3.appendChild(plus);
		section_cell2.appendChild(div);
		section_row1.appendChild(section_cell1);
		section_row1.appendChild(section_cell2);
		section_row1.appendChild(section_cell3);
		section_table.appendChild(section_row1);
		this.createdNames[this.position] = __names;
		section_table.appendChild(section_row1);
		section_table_main.appendChild(section_table);
		this.fieldArray[this.position++]  = section_table_main;
		document.getElementById(this.mainContainer).appendChild(section_table_main);
		this.count++;
		
	}
	catch(e)
	{
		
		alert("There was a problem Adding Row" +e);
	}
}	
	
	function removeRow(row)
	{
		if(this.count > 1)
		{
			document.getElementById(this.mainContainer).removeChild(this.fieldArray[row] );
			this.createdNames.splice(row,row);
			this.count--;				 
		}
		else
		{
			alert(" Sorry, You cannot remove the last row ");
		}	
	}
	
	function setRowsClass(classname)
	{
		this.classname = classname;
	}

	function setDefaultFileSize(size)
	{
		this.defaultSize = size;

	}
	
	function setOuterDivName(name)
	{
		this.mainContainer = name;

	}
	
	function getNumberOfRows()
	{
		return this.count;
	}

	function getCreatedNames()
	{
		return this.createdNames;	
	}