	
	function calculatePrice(isEarlyBird)
	{

		var gTotal = 0.0;
		
		// Get the number of participants
		var p = document.frmMain.NumParticipants.value;

		// Loop through all the participants
		var participantCount = 0;
		for(k = 0; k < p; k++)
		{
			var pTotal = 0.0;

			var fn = document.frmMain['FirstName' + (k+1)];
			var ln = document.frmMain['LastName' + (k+1)];
			
			// Ignore anything that isn't fill out (firstname + lastname)
			if (trim(fn.value).length > 0 || trim(ln.value).length > 0)
			{
				participantCount  = participantCount  + 1;
				
				// Selected attendee type
				var attendeeTypeId = 0;

				var ctlName = 'AttendeeTypeID-' + (k + 1);

				// Process the registration fees
				if (attendeeTypeIds.length == 1)
				{
					if (isEarlyBird)
					{
						pTotal = pTotal + attendeeEBPrices[0];
						
						// Save this on the form so we can get the registration fee
						document.frmMain['RegFee' + (k+1)].value = attendeeEBPrices[0];
						
					}
					else
					{
						pTotal = pTotal + attendeeRegPrices[0];

						// Save this on the form so we can get the registration fee
						document.frmMain['RegFee' + (k+1)].value = attendeeRegPrices[0];

					}					
//					// Get the single price
//					pTotal = pTotal + document.frmMain[ctlName].value;
				}
				else
				{
					var ctl = document.frmMain[ctlName];
					
					// Loop through the attendee type selections
					for(var m = 0; m < ctl.length; m++)
					{
						// Found a checked option
						if (ctl[m].checked)
						{
							// Get the value
							attendeeTypeId = ctl[m].value;
							
							// Find it in the array
							for (n = 0; n < attendeeTypeIds.length; n++)
							{
								// Add the appropriate dollar amount
								if (attendeeTypeId == attendeeTypeIds[n])
								{
									if (isEarlyBird)
									{
										pTotal = pTotal + attendeeEBPrices[n];
										
										// Save this on the form so we can get the registration fee
										document.frmMain['RegFee' + (k+1)].value = attendeeEBPrices[n];
										
									}
									else
									{
										pTotal = pTotal + attendeeRegPrices[n];

										// Save this on the form so we can get the registration fee
										document.frmMain['RegFee' + (k+1)].value = attendeeRegPrices[n];

									}
									
								}
							
							} // Find it in the array
												
						} // Found a checked option
						
					} // Loop through the attendee type selections
					
					//
					// Now we need to process all of the conference options
					//
					var ctlName = "ActivityID-" + (k+1) + "-" + attendeeTypeId;
					var ctl = document.frmMain[ctlName];

					if (ctl)
					{

						var ctlPriceName = "ActivityID-" + (k+1) + "-" + attendeeTypeId + "-price";
						var ctlPrice = document.frmMain[ctlPriceName];
	
						var ctlRegPriceName = "ActivityRegPrice-" + (k+1) + "-" + attendeeTypeId;
						var ctlRegPrice = document.frmMain[ctlRegPriceName];
	
						var ctlEbPriceName = "ActivityEbPrice-" + (k+1) + "-" + attendeeTypeId;
						var ctlEbPrice = document.frmMain[ctlEbPriceName];
						
						// Process the checkbox array
						if (ctl.length == null)
						{
							if (ctl.checked)
							{
								pTotal = pTotal + parseFloat(ctlPrice.value);
							}
						}
						else
						{
							for (n=0; n < ctl.length; n++)
							{
								if (ctl[n].checked)
								{
									pTotal = pTotal + parseFloat(ctlPrice[n].value);
								}
							}
						
						}
						
					} // Check for activity checkboxes
					
				} // First name filled out
				
			} 	// Process the registration fees

			// Add to the grand total
			gTotal = gTotal + pTotal;

			if (ctl)
			{
				// Display the participant total
				document.getElementById('att-' + (k+1) + "-" + attendeeTypeId + '-total-price').innerHTML = formatCurrency(pTotal);
				document.getElementById('att-' + (k+1) + "-" + attendeeTypeId + '-caption').innerHTML = 'Total for Participant';
			}
			
			// Save the participant total
			document.frmMain["PartFee" + (k+1)].value = pTotal;

		} // Loop through all the participants
		
		// Display the grand total
		if (participantCount > 0)
		{
			document.getElementById('grandTotal').innerHTML = 'Grand Total:&nbsp;' + formatCurrency(gTotal);
		}
		else
		{
			document.getElementById('grandTotal').innerHTML = '';
		}
		
		// Save the grand total in a value we can access
		document.frmMain.EventRegTotal.value = gTotal;
		
		//
		// If they have not completed the form, we can't show the payment form.
		//
		if (participantCount == 0 )
		{
			document.getElementById('divPayment').style.display = 'none';
			document.getElementById('divNoPayment').style.display = 'block';
		}
		else
		{
			document.getElementById('divPayment').style.display = 'block';
			document.getElementById('divNoPayment').style.display = 'none';
		}
		
		//
		// Adjust the buttons accordingly
		//
		if (gTotal == 0)
		{
			document.getElementById('paymentFree').style.display = 'block';
			document.getElementById('paymentOptions').style.display = 'none';
		}
		else
		{
			document.getElementById('paymentFree').style.display = 'none';
			document.getElementById('paymentOptions').style.display = 'block';
		}

//		alert('divPayment:' + document.getElementById('divPayment').style.display);
//		alert('paymentFree: ' + document.getElementById('paymentFree').style.display);
//		alert('paymentOptions: ' + 	document.getElementById('paymentOptions').style.display);

	}

	function validateForm(payby)
	{

		var k = 0;

		var part = document.frmMain.PartNumber;

		var b;

		if ( trim(document.frmMain['FirstName1'].value).length == 0 || trim(document.frmMain['LastName1'].value).length == 0)
		{
			alert('You must specify at least one participant');
			return;		
		}		
		
		if (part.length != null)
		{
			
			// Loop through the values
			for(k = 0; k < part.length; k++)
			{
				var ln = document.frmMain['LastName' + (k + 1)];
				var fn = document.frmMain['FirstName' + (k + 1)];
				var em = document.frmMain['Email' + (k + 1)];
				var ph = document.frmMain['Telephone' + (k + 1)];

				// We only check if they filled out the firstname or lastname
				if (fn.value.length > 0 || ln.value.length > 0 )
				{
					// First Name
					if (fn.value.length == 0)
					{
						alert("You must supply a first and last name for each participant");
						return false;
					}
					
					// Last Name
					if (ln.value.length == 0)
					{
						alert("You must supply a first and last name for each participant");
						return false;
					}										
			
					// Email
					if (em.value.length == 0)
					{
						alert("You must supply an e-mail address for each participant");
						return false;
					}
	
					// Telephone
					if (ph.value.length == 0)
					{
						alert("You must supply a telephone number for each participant");
						return false;
					}
					
					//
					// See if they selected an attendee (assume there is more than one)
					//
					var attendeeTypeSelected = 0;
					if (attendeeTypeIds.length > 1)
					{
						var selected = false;

						var radioName = 'AttendeeTypeID-' + (k + 1);
						var ctl = document.frmMain[radioName];
						
						for (m = 0; m < ctl.length; m++)
						{						
							if (ctl[m].checked == true)
							{
								selected = true;
								attendeeTypeSelected = ctl[m].value;
							}							
						}
						
						if (selected == false)
						{
							alert('You must select an registration fee option for each participant');
							return;
						}
					}
					
					//
					// See if there are any required fields out there that haven't been filled in
					// We want to check only those pertinent to the selected attendee type...
					//
					for (h = 0; h < 9; h++)
					{
						ctlName = "Field-" + (k + 1) + "-" + attendeeTypeSelected + "-" + h;
						
//						alert(ctlName);
						// See if it exists
						if (document.frmMain[ctlName])
						{
							var ctl = document.frmMain[ctlName];
							var alt = ctl.getAttribute('alt');
							var tit = ctl.getAttribute('title');
							
							// See if it's a required field
							if (alt == 'required')
							{
								// See if it has a value
								if (ctl.value.length == 0)
								{
									alert('A required field is missing: ' + tit);
									return;
								}
							}
						}
					}
													 					
				} // First or last name filled out
				
			} // next
		}		
		
		//
		// Payment forms
		//
		
		// Check

		if (document.frmMain.ChargeTypeID[0].checked && document.getElementById('paymentOptions').style.display == 'block')
		{
			var s = trim(document.frmMain.chkFirstName.value);
			if (s.length == 0)
			{
				alert('You must provide the required contact information when paying by check or money order');
				return;
			}

			var s = trim(document.frmMain.chkLastName.value);
			if (s.length == 0)
			{
				alert('You must provide the required contact information when paying by check or money order');
				return;
			}

			var s = trim(document.frmMain.chkEmail.value);
			if (s.length == 0)
			{
				alert('You must provide the required contact information when paying by check or money order');
				return;
			}

			var s = trim(document.frmMain.chkTelephone.value);
			if (s.length == 0)
			{
				alert('You must provide the required contact information when paying by check or money order');
				return;
			}

		}

		// Credit Card
		
		
		if (document.frmMain.ChargeTypeID[1].checked && document.getElementById('paymentOptions').style.display == 'block')
		{
			
			var s = trim(document.frmMain.ccFirstName.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (first name) when paying by credit card');
				return;
			}

			var s = trim(document.frmMain.ccLastName.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (last name) when paying by credit card');
				return;
			}

			var s = trim(document.frmMain.ccStreet1.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (street address) when paying by credit card');
				return;
			}

			var s = trim(document.frmMain.ccCity.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (city) when paying by credit card');
				return;
			}

			var s = trim(document.frmMain.ccState.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (state/province) when paying by credit card');
				return;
			}

			var s = trim(document.frmMain.ccZipCode.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (zip code/postal code) when paying by credit card');
				return;
			}

			var s = trim(document.frmMain.ccEmail.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (email address) when paying by credit card');
				return;
			}
			

			var s = trim(document.frmMain.ccTelephone.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (telephone number) when paying by credit card');
				return;
			}			
			
			var s = trim(document.frmMain.ccNumber.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (credit card number) when paying by credit card');
				return;
			}						
			
			var s = trim(document.frmMain.CVV2.value);
			if (s.length == 0)
			{
				alert('You must provide the required information (credit card security code) when paying by credit card');
				return;
			}						
			
		}

		document.frmMain.PayBy.value = payby;
		document.frmMain.Action.value = 'process';
		document.frmMain.submit();
		
	}
	
	
	
	function attendeeTypeChanged(participantNumber, attendeeTypeId, isEarlyBird)
	{
		for (var k = 0; k < attendeeTypeIds.length; k++)
		{
			// Hide all the fields that aren't selected
			var div = 'att' + participantNumber + '-' + attendeeTypeIds[k];
			var divAct = 'divAct' + participantNumber + '-' + attendeeTypeIds[k];
			
			try			
			{
				document.getElementById(div).style.display='none';
				document.getElementById(divAct).style.display='none';
			}
			catch(e)
			{
			}
		}

		// Show all the fields that aren't selected
		var div = 'att' + participantNumber + '-' + attendeeTypeId;
		var divAct = 'divAct' + participantNumber + '-' + attendeeTypeId;
		
		try
		{
			document.getElementById(div).style.display='block';
			document.getElementById(divAct).style.display='block';
		}
		catch(e)
		{
		}
		
		calculatePrice(isEarlyBird);
		
	}
	
	function clearSearch()
	{
		document.frmMain.Action.value = 'clear';
		document.frmMain.submit();
	}	