function validateForm(thisForm) {
	with (thisForm){
		// Checks for empty fields.
		if (FirstName.value == ""){
			alert ("Please enter your first name.");
			FirstName.focus();
			return false;
		}
		if (LastName.value == ""){
			alert ("Please enter your last name.");
			LastName.focus();
			return false;
		}
		if (PostCode.value == ""){
			alert ("Please enter your post code.");
			PostCode.focus();
			return false;
		}
		if (ContactNumber.value == ""){
			alert ("Please enter your daytime contact number.");
			ContactNumber.focus();
			return false;
		}
		if (EmailAddress.value == ""){
			alert ("Please enter your email address.");
			EmailAddress.focus();
			return false;
		}
		if (ConfirmEmailAddress.value == ""){
			alert ("Please confirm your email address.");
			ConfirmEmailAddress.focus();
			return false;
		} else if (EmailAddress.value != ConfirmEmailAddress.value){
			alert ("Your email address and confirm email address do not match.");
			ConfirmEmailAddress.focus();
			return false;
		}

		// Validates the format of the email address

		// The following pattern checks whether the input string is a valid email 
            // address in the form "name@domain.com". Actually, it does not have to be a
		// ".com" address. Any combination of letters following the last period are 
		// fine. Also, the email name can have a dash or be separated by one or more 
		// periods. The Domain name can also have multiple words separated by periods. 

		// [\w-]+    
		// One or more matches of any character (a-z, A-Z, 0-9, and underscore) or dash. On either side of the @ character this ensures the address is in the form name@domainname.
		// \.              
		// An escaped period. (Without the backslash, a period matches any single character except the newline character.) Using this ensures there is at least one period in the domain name.
		// *?            
		// A non-greedy, or minimal, match of zero or more matches of the preceding expression.
		// ([\w-]+\.)*?    
		// Combination of the three preceding expressions:
		// Zero or more non-greedy matches of the expression one or more matches of any character (a-z, A-Z, 0-9, and underscore) or dash, followed by only one period.

		re = /^([\w-]+\.)*?[\w-]+@[\w-]+\.([\w-]+\.)*?[\w]+$/;
		if (!re.test(EmailAddress.value)){
			alert ("The format of your email address is not correct.");
			EmailAddress.focus();
			return false;
		}

		// Validates the format of PostCode

		// The following pattern checks whether the input string is a valid post code
		// in the format dddd, where d is any digit 0-9.
		// The ^ character matches the position at the beginning of the input string. 
		// The $ character matches the position at the end of the input string.
		// \d{4,5}: Exactly four or five digits (0-9).

		re = /^\d{4,5}$/;

		if (!re.test(PostCode.value)){
			alert ("The format of the post code is not correct.");
			PostCode.focus();
			return false;
		}

	}
	return true;
		
}

// Calculates the total amount donated.
function CalculateAmount(NumberOfVouchers)
{
	document.MakeKidsChristmasForm.TotalAmount.value = "$" + NumberOfVouchers.value * 25;
}