var counter = 1;
var limit = 5;
/*function addInput(divName){
     if (counter == limit)  {
          alert("You have reached the maximum number of registrants - please resubmit this form if you have more than 5 registrants.");
     }
     else {
          var newdiv = document.createElement('div');
          newdiv.innerHTML = '<div id=parent' + (counter + 1) + '><div id=child' + (counter + 1) + '><font face="Arial, Helvetica, sans-serif" size="2"><br>Registrant #' + (counter + 1) + ' </font><br> \
                           <table border="0" cellpadding="5" cellspacing="0" width="100%"> \
				<tr> \
					<td width="133" height="22">  \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;First Name:</font></td> \
					<td  height="22"><font size="3"><input size=30 type=text name=strFirstName' + (counter + 1) + ' id=strFirstName' + (counter + 1) + ' ></font></td> \
				</tr>  \
				<tr>  \
					<td width="133" height="22"> \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Last Name:</font></td>  \
					<td  height="22"><font size="3"><input size=30 type=text name=strLastName' + (counter + 1) + '  ></font></td>   \
				</tr> \
				<tr>  \
					<td width="333" height="22" colspan="2"> \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Primary Function:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <select size="1" type=text name=strFunction' + (counter + 1) + ' width="200" STYLE="width: 200; height:22"><option>Event</option><option>Equipment</option><option>Both</option></select></td>   \
				</tr> \
				<tr>  \
					<td width="133" height="22"> \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Job Title:</font></td>  \
					<td  height="22"><font size="3"><input size=30 type=text name=strTitle' + (counter + 1) + ' id=strTitle' + (counter + 1) + ' ></font></td>   \
				</tr> \
						<tr>    \
							<td width="133" height="23">  \
							<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Email:</font></td>  \
							<td  height="23"><font size="3"><input size=30 type=text name=strEmail' + (counter + 1) + ' id=strEmail' + (counter + 1) + ' ></font></td> \
						</tr> \
						<tr>  \
							<td width="133" height="23">  \
							<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Cost:</font></td> \
							<td  height="23"><font size="3"><font face="Arial, Helvetica, sans-serif" size="2">+ $150 ($180 if within 30 days of the seminar date) = $' + (185 + (150 * counter))          + '</font></td> \
						</tr>  \
		       	</table>   \
                        <input type=button value="Remove Registrant" onClick="removeElement(\'parent'+(counter + 1)+'\',\'child'+(counter + 1)+'\');">     \
                        </div></div>   \
          ';
          document.getElementById(divName).appendChild(newdiv);
          counter++;
     }
}*/

function removeElement2(parentDiv, childDiv){
     if (childDiv == parentDiv) {
          alert("The parent div cannot be removed.");
     }
     else if (document.getElementById(childDiv)) {
          var child = document.getElementById(childDiv);
          var parent = document.getElementById(parentDiv);
          parent.removeChild(child);
          counter--;
     }
     else {
          alert("Child div has already been removed or does not exist.");
          return false;
     }
}

			function addElement(parentId, elementTag, elementId, html) {
				// Adds an element to the document
				var p = document.getElementById(parentId);
				var newElement = document.createElement(elementTag);
				newElement.setAttribute('id', elementId);
				newElement.innerHTML = html;
				p.appendChild(newElement);
			}

			function removeElement(elementId) {
				// Removes an element from the document
				var element = document.getElementById(elementId);
				element.parentNode.removeChild(element);
				counter--;
				}

	function addFile() {
     if (counter == limit)  {
          alert("You have reached the maximum number of registrants - please resubmit this form if you have more than 5 registrants.");
     }
     else {
				//
				// Example function showing how to add a file input box to an existing form
				//
				fileId++; // increment fileId to get a unique ID for the new element
				var html = '<br> \
                           <table border="0" cellpadding="5" cellspacing="0" width="100%"> \
				<tr> \
					<td width="133" height="22">  \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;First Name:</font></td> \
					<td  height="22"><font size="3"><input size=30 type=text name=strFirstName' + (counter + 1) + ' id=strFirstName' + (counter + 1) + ' ></font></td> \
				</tr>  \
				<tr>  \
					<td width="133" height="22"> \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Last Name:</font></td>  \
					<td height="22"><font size="3"><input size=30 type=text name=strLastName' + (counter + 1) + ' id=strLastName' + (counter + 1) + ' ></font></td>   \
				</tr> \
				<tr>  \
					<td width="333" height="22" colspan="2"> \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Primary Function:</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <select size="1" type=text name=strFunction' + (counter + 1) + ' width="180" STYLE="width: 180; height:22"><option>Select Primary Function</option><option>Event</option><option>Equipment</option><option>Both</option> \
					</select></td>   \
				</tr> \
				<tr>  \
					<td width="133" height="22"> \
					<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Job Title:</font></td>  \
					<td  height="22"><font size="3"><input size=30 type=text name=strTitle' + (counter + 1) + ' id=strTitle' + (counter + 1) + ' ></font></td>   \
				</tr> \
						<tr>    \
							<td width="133" height="23">  \
							<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Email:</font></td>  \
							<td  height="23"><font size="3"><input size=30 type=text name=strEmail' + (counter + 1) + ' id=strEmail' + (counter + 1) + ' ></font></td> \
						</tr> \
						<tr>  \
							<td width="133" height="23">  \
							<font face="Arial, Helvetica, sans-serif" size="2">&nbsp;Cost:</font></td> \
							<td  height="23"><font size="3"><font face="Arial, Helvetica, sans-serif" size="2">+ $150 ($180 if within 30 days of the seminar date) = $' + (185 + (150 * counter))          + '</font></td> \
						</tr>  \
		       	</table>   \
                        <input type=button value="Remove Registrant" onClick="removeElement(\'file-' + fileId + '\');">     \
          ';

				addElement('files', 'p', 'file-' + fileId, html);
          counter++;
			}
			}

			var fileId = 0; // used by the addFile() function to keep track of IDs

