// JavaScript Document

// Adds file field to a form
// function name ("addFile") must match name in html document (onclick='addFile()')

function addFile() {
		var newArea = addElement();
		var num = (document.getElementById('intVal').value -1)+ 2; //this is the increment value for each file that is added
		var area = 
				"<tr>"+
                    "<td colspan='3' align='left' valign='top'>"+
					"<input name='attachement"+num+"' type='file' id='attachement"+num+"' style='color:#00275d; background-color:#f6f6f2; border:none; font-size:12px;'/>"+
					"</td>"+
                "</tr>"
		document.getElementById(newArea).innerHTML = area;
	}

	function addElement() {
	//argument for ni function ('field') must match empty DIV tag in html document
	//i.e. <div id="field"></div><!--This blank div needed for adding files if desired. -->
		  var ni = document.getElementById('field');
		  var numi = document.getElementById('intVal');
		  var num = (document.getElementById('intVal').value -1)+ 2;
		  numi.value = num;
		  var newdiv = document.createElement('div');
		  var divIdName = 'my'+num+'Div';
		  newdiv.setAttribute('id',divIdName);
		  ni.appendChild(newdiv);
		  return divIdName;
	}
	
	
