// Validates the form, prompts with a message if the values are invalid.
function validateForm(inForm)
{
	var errorString = "";
	var errorOccurred = false;
	
	// Prep the error string.
	errorString = errorString + "The following errors occurred:\n\n";
	
	// Iterate through form elements looking for required flag.
	for (var i = 0; i < inForm.elements.length; i++)
	{
		// Check for elements that are required.
		if (inForm.elements[i].required)
		{
			// Check the value.
			if (inForm.elements[i].value == '')
			{
				// An error did occur, flag it.
				errorOccurred = true;
				
				// Add the message to the error string.
				if (inForm.elements[i].message != '')
				{
					errorString = errorString + "• " + inForm.elements[i].message + "\n";
				}					
				else
				{
					// Output a default error for the field.
					errorString = errorString + "• There is a missing field.\n";
				}
			}
		}
	}
	
	// Finish the error string.
	errorString = errorString + '\nPlease correct these errors and re-submit this form.';
	
	// If an error occurred, show the message.
	if (errorOccurred == true) alert(errorString);
	
	// Return true if no error occurred.
	return !errorOccurred;
}
