	var alphaCompare = "abcdefghijklmnopqrstuvwxyz.' ";
	var passwordCompare = "abcdefghijklmnopqrstuvwxyz1234567890_";
	var numericCompare = "1234567890";
	var phoneCompare = "1234567890-() ";
	var blnFirstNumericMessage = true;
	var blnFirstAlphaMessage = true;
	var errorMessage = "";
	var error = false;
	
	//Check if the fields are empty - reset these fields after all functions passed
	
	var blnPasswordEmpty = false;
	var blnDateDOBEmpty = false;
	var blnDOBError = false;
	
	function mouseOver(button, image)
	{
		newImage = "url(" + image + ")";	
		button.style.backgroundImage = newImage;
	}
	
	function mouseOut(button, image)
	{
		newImage = "url(" + image + ")";	
		button.style.backgroundImage = newImage;
	}
	
	function checkContactForm()
	{
		
		var name = document.formObject.txtboxName.value;
		var email = document.formObject.txtboxEmail.value;
		var contactNumber = document.formObject.txtboxContactNumber.value;
		var subject = document.formObject.txtboxSubject.value;
		var comments = document.formObject.txtboxComments.value;
		var error_message_empty = "The following fields are empty:\n\n";
		var error_email_email = "";
		var error = false;
		var email_error = false;
		
		if(name == "")
		{
			error_message_empty = error_message_empty + "  * Name\n";
			error = true;
		}
		if(email == "")
		{
			error_message_empty = error_message_empty + "  * Email\n";
			error = true;
		}
		if(contactNumber == "")
		{
			error_message_empty = error_message_empty + "  * Contact No.\n";
			error = true;
		}
		if(subject == "")
		{
			error_message_empty = error_message_empty + "  * Subject\n";
			error = true;
		}
		if(comments == "")
		{
			error_message_empty = error_message_empty + "  * Comments";
			error = true;
		}
		if(!emailCheck(email))
		{
			error_message_email = "\n\nEmail field is not in correct format.";
			email_error = true;
		}
		
		if(error == true)
		{
			error_message = error_message_empty;
			if(email != "")
				error_message = error_message + error_message_email;
			alert(error_message);
			error = false;
			return false;
		}
		else if(email_error == true)
		{
			alert("Email field is not in correct format.");
			email_error = false;
			return false;
		}
		
		return true;
	}
	
	function evaluateError(error, section)
	{
		if(error == true)
			return false;
	
		else
		{
			document.formObject.toSectionForward.value = section;
			document.formObject.toSectionBackward.value = "";
			return true;
		}
	}
	
	function printErrorMessage()
	{
		if(error == true)
		{
			alert(errorMessage);
			resetVariables();
			return true;
		}
		else
		{
			resetVariables();
			return false;
		}
	}
	
	function resetVariables()
	{	
		//reset global variables	
		blnFirstNumericMessage = true;
		blnFirstAlphaMessage = true;
		errorMessage = "";
		blnPasswordEmpty = false;
		blnDateDOBEmpty = false;
		blnDOBError = false;
		error = false;
	}
		
	function validateSection1EmptyFields()
	{
		errorMessage = "* The following fields are empty: \n\n";
		if(document.formObject.txtboxUsername.value == "")
		{
			errorMessage = errorMessage + "  Username\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.selRepresentative.value == "")
		{
			errorMessage = errorMessage + "  Club Suntory Representative\n"; 
			error = true;
			//alert("11");
		}
		
		if((document.formObject.txtboxPassword1.value == "") || (document.formObject.txtboxPassword2.value == ""))
		{
			errorMessage = errorMessage + "  Password\n";
			blnPasswordEmpty = true;
			error = true;
		}
			
		if(document.formObject.txtboxFirstName.value == "")
		{
			errorMessage = errorMessage + "  First Name\n"; 
			error = true;
			//alert("2");
		}
		
		if(document.formObject.txtboxLastName.value == "")
		{ 
			errorMessage = errorMessage + "  Last Name\n"; 
			error = true;
			//alert("3");
		}
		
		if(document.formObject.selGender.value == "")
		{
			errorMessage = errorMessage + "  Sex\n"; 
			error = true;
			//alert("4");
		}
		
		if(document.formObject.txtboxDOBDay.value == "")
		{
			errorMessage = errorMessage + "  Date of Birth (day)\n"; 
			error = true;
			//alert("5");
		}
		
		if(document.formObject.txtboxDOBMonth.value == "")
		{
			errorMessage = errorMessage + "  Date of Birth (month)\n"; 
			error = true;
			//alert("6");
		}
		
		if(document.formObject.txtboxDOBYear.value == "")
		{
			errorMessage = errorMessage + "  Date of Birth (year)\n"; 
			blnDateDOBEmpty = true;
			error = true;
			//alert("7");
		}
		
		if(document.formObject.txtboxAddress.value == "")
		{
			errorMessage = errorMessage + "  Address\n"; 
			error = true;
			//alert("8");
		}
		
		if(document.formObject.txtboxSuburb.value == "")
		{
			errorMessage = errorMessage + "  Suburb\n"; 
			error = true;
			//alert("9");
		}
		
		if(document.formObject.txtboxCity.value == "")
		{
			errorMessage = errorMessage + "  City\n"; 
			error = true;
			//alert("10");
		}
		
		if(document.formObject.selState.value == "")
		{
			errorMessage = errorMessage + "  State\n"; 
			error = true;
			//alert("11");
		}
		
		if(document.formObject.selCountry.value == "")
		{
			errorMessage = errorMessage + "  Country\n"; 
			error = true;
			//alert("11");
		}
		
		/*if(document.formObject.txtboxPostcode.value == "")
		{
			errorMessage = errorMessage + "  Postcode\n"; 
			error = true;
			//alert("12");
		}*/
		
		if(document.formObject.txtboxEmail.value == "")
		{
			errorMessage = errorMessage + "  Email Address\n"; 
			error = true;
			//alert("15");
		}
	} // end function
	//----------------------------------------------
	
	function validateSection1AlphaNumericFields()
	{
		
		// Check text fields that should only contain alpha characters and apostrophes
		if(document.formObject.txtboxFirstName.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxFirstName.value, alphaCompare) == false)
			{				
				if(blnFirstAlphaMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must only contain alpha characters:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must only contain alpha characters:\n\n";
					
					blnFirstAlphaMessage = false;
				}
				errorMessage = errorMessage + "  First Name\n";
				error = true;
			}
		
		if(document.formObject.txtboxLastName.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxLastName.value, alphaCompare) == false)
			{
				if(blnFirstAlphaMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must only contain alpha characters:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must only contain alpha characters:\n\n";
	
					blnFirstAlphaMessage = false;
				}
				errorMessage = errorMessage + "  Last Name\n";
				error = true;
			}
			
		if(document.formObject.txtboxSuburb.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxSuburb.value, alphaCompare) == false)
			{
				if(blnFirstAlphaMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must only contain alpha characters:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must only contain alpha characters:\n\n";
	
					blnFirstAlphaMessage = false;
				}
				errorMessage = errorMessage + "  Suburb\n";
				error = true;
			}
			
		if(document.formObject.txtboxCity.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxCity.value, alphaCompare) == false)
			{
				if(blnFirstAlphaMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must only contain alpha characters:\n\n";
						error = true;
					}
					else	
						errorMessage = errorMessage + "\n* The following fields must only contain alpha characters:\n\n";
						
					blnFirstAlphaMessage = false;
				}
				errorMessage = errorMessage + "  City\n";
				error = true;
			}
	} // end function	
	
	function validateSection1NumericFields()
	{	
		// Check that numeric fields only contain numeric characters
		if(document.formObject.txtboxDOBDay.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxDOBDay.value, numericCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";	
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
						
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  DOB (day)\n";
				error = true;
			}
			
		if(document.formObject.txtboxDOBMonth.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxDOBMonth.value, numericCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";
						error = true;
					}
					else	
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  DOB (month)\n";
				error = true;
			}
				
		if(document.formObject.txtboxDOBYear.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxDOBYear.value, numericCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  DOB (year)\n";
				error = true;
				blnDOBError = true;
			}
			
		if(document.formObject.txtboxPostcode.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxPostcode.value, numericCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  Postcode\n";
				error = true;
				blnDOBError = true;
			}
	} // end function
	
	function validateSection1PasswordField()
	{
		if(document.formObject.txtboxPassword1.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxPassword1.value, passwordCompare) == false)
			{
				if(error == false) // First time
				{
		errorMessage = "* The Password field must only contain letters in The following range: (A-Z, a-z, 0-9, _)\n\n";
					error = true;
				}
				else
				errorMessage = errorMessage + "\n* The Password field must only contain letters in The following range: (A-Z, a-z, 0-9, _)\n";
			}
	}
	
	function validatePhoneNumbers()
	{
		if(document.formObject.txtboxPhoneNumber.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxPhoneNumber.value, phoneCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  Home Phone Number\n";
				error = true;
				blnDOBError = true;
			}
			
		if(document.formObject.txtboxMobile.value.length != 0)
		{
			if(checkOnlyAlpha(document.formObject.txtboxMobile.value, phoneCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  Mobile Number\n";
				error = true;
				blnDOBError = true;
			}
			if(document.formObject.txtboxMobile.value.length < 9)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data or are not of valid length:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data or are not of valid length:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  Mobile Number\n";
				error = true;
				blnDOBError = true;
			}
		}
	}	
	
	function validateSection1PasswordsAreTheSame()
	{
		// Check that the password fields are the same
		if(blnPasswordEmpty == false)
		{
			if((document.formObject.txtboxPassword1.value.length) < 6 || (document.formObject.txtboxPassword2.value.length < 6))
			{
				if(error == false)
					errorMessage = "* Password field must be at least 6 characters long.\n\n";
				else
					errorMessage = errorMessage + "\n* Password field must be at least 6 characters long.\n\n";
				error = true;
			}
			
			else if(document.formObject.txtboxPassword1.value != document.formObject.txtboxPassword2.value)
			{
				if(error == false)
					errorMessage = "* Password fields do not match.\n\n";
				else
					errorMessage = errorMessage + "\n* Password fields do not match.\n";
				error = true;
			}			
		}
	} // end function
		
	function validateSection1Email()
	{		
		// Check that the email is in correct format
		if(document.formObject.txtboxEmail.value.length != 0)
			if(emailCheck(document.formObject.txtboxEmail.value) == false)
			{
				if(error == false) // First time
				{
					errorMessage = "* Email field is in incorrect format:\n\n";
					error = true;
				}
				else
					errorMessage = errorMessage + "\n* Email field is in incorrect format:\n";
			}
	} // end function
	
	function stripLeadingZero(monthValue)
	{
		var month = monthValue;
		if(month.length == 2)
		{
			if(month.substring(0,1) == 0)
				return month.substr(1,1);
		}
		return monthValue;
	}
	
	function validateSection1DOBFieldsValid()
	{
		if(document.formObject.txtboxDOBDay.value != "" && document.formObject.txtboxDOBMonth.value != "" && document.formObject.txtboxDOBYear.value != "")
		{
			var dayNumber = document.formObject.txtboxDOBDay.value;
			var monthNumber = parseInt(stripLeadingZero(document.formObject.txtboxDOBMonth.value));
			var yearNumber = document.formObject.txtboxDOBYear.value;
			var dayError = false;
			var leapYear = false;

			if(monthNumber >= 1 && monthNumber <= 12)
			{
				// Now that the month days have been validated, lets validate that the days are correct
				switch(monthNumber)
				{
					case 1:
						if(dayNumber < 1 || dayNumber > 31)
							dayError = true;
						break;
					case 2:
						//check for leap year
						if(yearNumber % 4 == 0 && !(yearNumber % 100 == 0 && yearNumber % 400 != 0))
							leapYear = true;
						if(leapYear == true)
						{
							if(dayNumber < 1 || dayNumber > 29)
								dayError = true;
						}
						else
						{
							if(dayNumber < 1 || dayNumber > 28)
								dayError = true;
						}
						break;
					case 3:
						if(dayNumber < 1 || dayNumber > 31)
							dayError = true;
						break;
					case 4:
						if(dayNumber < 1 || dayNumber > 30)
							dayError = true;
						break;
					case 5:
						if(dayNumber < 1 || dayNumber > 31)
							dayError = true;
						break;
					case 6:
						if(dayNumber < 1 || dayNumber > 30)
							dayError = true;
						break;					
					case 7:
						if(dayNumber < 1 || dayNumber > 31)
							dayError = true;
						break;
					case 8:
						if(dayNumber < 1 || dayNumber > 31)
							dayError = true;
						break;
					case 9:
						if(dayNumber < 1 || dayNumber > 30)
							dayError = true;
						break;
					case 10:
						if(dayNumber < 1 || dayNumber > 31)
							dayError = true;
						break;
					case 11:
						if(dayNumber < 1 || dayNumber > 30)
							dayError = true;
						break;
					case 12:
						if(dayNumber < 1 || dayNumber > 31)
							dayError = true;
						break;
				} // end switch
				
				if(dayError == true)
				{
					//produce error
					if(error == false) // first time
					{
						errorMessage = "* Date of Birth(Day) field is not valid for the month entered\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* Date of Birth(Day) field is not valid for the month entered\n";
				}
			} // end if
			else
			{
				// The month is out of range
				if(error == false) // first time
				{
					errorMessage = "* Date of Birth(Month) field has to be in the range: 1-12\n\n";
					error = true;
				}
				else
					errorMessage = errorMessage + "\n* Date of Birth(Month) field has to be in the range: 01-12\n";
			}
			
			if(yearNumber < 1905 || yearNumber > 1992)
			{
				// Invalid year - either too young or too old
				if(error == false) // first time
				{
					errorMessage = "* Date of Birth(Year) field has to be in the range: 1905-1992\n\n";
					error = true;
				}
				else
					errorMessage = errorMessage + "\n* Date of Birth(Year) field has to be in the range: 1905-1992\n";
			}
		} // end if
	} // end function
	
	function validateSection1DOBYearCheck()
	{		
		// Check that DOB Year is 4 characters wide and is only a number, but only do this if the only numeric check has passed
		// successfully
		if(blnDOBError == false)
		{
			if(document.formObject.txtboxDOBYear.value != "")
			{
				if(document.formObject.txtboxDOBYear.value.length != 4)
				{
					if(error == false) // First time
						errorMessage = "* DOB (year) field must be in YYYY format.\n\n";
					else
						errorMessage = errorMessage + "\n* DOB (year) field must be in YYYY format.\n";
					error = true;

				}		
			}
		}
	} // end function
	
	function validateSection1PostCodeLengthCheck()
	{
		if(document.formObject.txtboxPostcode.value != "")
		{
			if(document.formObject.txtboxPostcode.value.length != 4)
			{
				if(error == false)
					errorMessage = "* Postcode field must be at exactly 4 characters wide.\n\n";
				else
					errorMessage = errorMessage + "\n* Postcode field must be at exactly 4 characters wide.\n";
				error = true;
			}
		}
	}
		
	// PAGE 2 VALIDATION
	
	function validateSection2EmptyFields()
	{
		errorMessage = "* The following fields are empty: \n\n";
		if(document.formObject.selRSA.value == "")
		{
			errorMessage = errorMessage + "  RSA Certified\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.selHearAboutUs.value == "")
		{
			errorMessage = errorMessage + "  How Did You Hear About Us\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.selJoinClubSuntory.value == "")
		{
			errorMessage = errorMessage + "  What made you Join Club Suntory?\n";
			error = true;
			//alert("1");
		}
			
		if(document.formObject.txtboxEmpVenueName.value == "")
		{
			errorMessage = errorMessage + "  Employer Name\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.txtboxEmpAddress.value == "")
		{
			errorMessage = errorMessage + "  Employer Address\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.txtboxEmpSuburb.value == "")
		{
			errorMessage = errorMessage + "  Employer Suburb\n"; 
			error = true;
			//alert("10");
		}
		
		if(document.formObject.txtboxEmpCity.value == "")
		{
			errorMessage = errorMessage + "  Employer City\n"; 
			error = true;
			//alert("9");
		}
		
		if(document.formObject.selEmployerState.value == "")
		{
			errorMessage = errorMessage + "  Employer State\n"; 
			error = true;
			//alert("11");
		}
		
		if(document.formObject.selPositionHeld.value == "")
		{
			errorMessage = errorMessage + "  Position Held\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.selEmploymentBasis.value == "")
		{
			errorMessage = errorMessage + "  Employment Basis\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.selTobacco.value == "")
		{
			errorMessage = errorMessage + "  Does your venue sell tobacco\n";
			error = true;
			//alert("1");
		}
	} // end function
	
	function validateSection2AlphaNumericFields()
	{
		if(document.formObject.txtboxEmpSuburb.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxEmpSuburb.value, alphaCompare) == false)
			{
				if(blnFirstAlphaMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must only contain alpha characters:\n\n";
						error = true;
					}
					else	
						errorMessage = errorMessage + "\n* The following fields must only contain alpha characters:\n\n";
						
					blnFirstAlphaMessage = false;
				}
				errorMessage = errorMessage + "  Employer Suburb\n";
				error = true;
			}	
		
		if(document.formObject.txtboxEmpCity.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxEmpCity.value, alphaCompare) == false)
			{
				if(blnFirstAlphaMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must only contain alpha characters:\n\n";
						error = true;
					}
					else	
						errorMessage = errorMessage + "\n* The following fields must only contain alpha characters:\n\n";
						
					blnFirstAlphaMessage = false;
				}
				errorMessage = errorMessage + "  Employer City\n";
				error = true;
			}	
	}
	
	function validateSection2NumericFields()
	{
		if(document.formObject.txtboxEmpPostcode.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxEmpPostcode.value, numericCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  Employer Postcode\n";
				error = true;
				blnDOBError = true;
			}			
	}
	
	function validateSection2PostCodeLengthCheck()
	{
		if(document.formObject.txtboxEmpPostcode.value != "")
		{
			if(document.formObject.txtboxEmpPostcode.value.length != 4)
			{
				if(error == false)
					errorMessage = "* Employer Postcode field must be at exactly 4 characters wide.\n\n";
				else
					errorMessage = errorMessage + "\n* Employer Postcode field must be at exactly 4 characters wide.\n";
				error = true;
			}
		}
	}
		

        function validateSection3EmptyFields() {
          errorMessage = "Error! \n\n";
          var obj = document.formObject;
	  if(obj.check61.checked == false && obj.check62.checked == false && obj.check63.checked == false && obj.check64.checked == false && obj.check65.checked == false && obj.check66.checked == false && obj.check67.checked == false) {
	    errorMessage = errorMessage + " -> Q1: You must select at least one item \n";
	    error = true;
	  }

	  if(obj.check111.checked == false && obj.check112.checked == false && obj.check113.checked == false && obj.check114.checked == false && obj.check115.checked == false && obj.check116.checked == false && obj.check117.checked == false && obj.check118.checked == false && obj.check119.checked == false) {
	    errorMessage = errorMessage + " -> Q2: You must select at least one item \n";
	    error = true;
	  }

	  if(obj.check141.checked == false && obj.check142.checked == false && obj.check143.checked == false && obj.check144.checked == false && obj.check145.checked == false && obj.check146.checked == false && obj.check147.checked == false && obj.check148.checked == false) {
	    errorMessage = errorMessage + " -> Q3: You must select at least one item \n";
	    error = true;
	  }
	  myMixedDrink = -1;
for (i=obj.radio2.length-1; i > -1; i--) {
if (obj.radio2[i].checked) {
myMixedDrink = i; i = -1;
}

}
if (myMixedDrink == -1) {
errorMessage = errorMessage + " -> Q4: Please select the most ordered mixed drink in your bar \n";
error = true;
}

myCocktail = -1;
for (i=obj.radio3.length-1; i > -1; i--) {
if (obj.radio3[i].checked) {
myCocktail = i; i = -1;
}

}
if (myCocktail == -1) {
errorMessage = errorMessage + " -> Q5: Please select the most requested cocktail in your bar \n";
error = true;
}

        }
		
	function validateSection5EmptyFields()
	{
		errorMessage = "* The following fields are empty: \n\n";
		if(document.formObject.txtboxYearsExperience.value == "")
		{
			errorMessage = errorMessage + "  Years Spent In Industry\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.selCareerStep.value == "")
		{
			errorMessage = errorMessage + "  Career Step\n";
			error = true;
			//alert("1");
		}
		
		if(document.formObject.selGoOnline.value == "")
		{
			errorMessage = errorMessage + "  Go Online For Information And Offers\n";
			error = true;
			//alert("1");
		}
	}
	
	function validateSection5NumericFields()
	{
		if(document.formObject.txtboxYearsExperience.value.length != 0)
			if(checkOnlyAlpha(document.formObject.txtboxYearsExperience.value, numericCompare) == false)
			{
				if(blnFirstNumericMessage == true)
				{
					if(error == false) // First time
					{
						errorMessage = "* The following fields must contain only numeric data:\n\n";
						error = true;
					}
					else
						errorMessage = errorMessage + "\n* The following fields must contain only numeric data:\n\n";
	
					blnFirstNumericMessage = false;
				}
				errorMessage = errorMessage + "  Years Spent In Industry\n";
				error = true;
				blnDOBError = true;
			}	
	}
	
	function validateSection5CheckTerms()
	{
		if(!document.formObject.chkTerms.checked)
		{
			if(error == false)
				errorMessage = "* Please agree to the Terms and Conditions.";
			else
				errorMessage = errorMessage + "\n* Please agree to the Terms and Conditions.";
			error = true;
		}
	}
	
	function checkOnlyAlpha(fieldName, compareString)
	{
		for(var i=0; i < fieldName.length; i++)
		{
			var letter = fieldName.charAt(i).toLowerCase();	
			if(compareString.indexOf(letter) != -1)
				continue;
							
			return false;
		}
		
		return true;
	}
	
	function emailCheck (emailStr) 
	{
		/* The following pattern is used to check if the entered e-mail address
		   fits the user@domain format.  It also is used to separate the username
		   from the domain. */
		var emailPat=/^(.+)@(.+)$/
		/* The following string represents the pattern for matching all special
		   characters.  We don't want to allow special characters in the address. 
		   These characters include ( ) < > @ , ; : \ " . [ ]    */
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		/* The following string represents the range of characters allowed in a 
		   username or domainname.  It really states which chars aren't allowed. */
		var validChars="\[^\\s" + specialChars + "\]"
		/* The following pattern applies if the "user" is a quoted string (in
		   which case, there are no rules about which characters are allowed
		   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		   is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")"
		/* The following pattern applies for domains that are IP addresses,
		   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		   e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		/* The following string represents an atom (basically a series of
		   non-special characters.) */
		var atom=validChars + '+'
		/* The following string represents one word in the typical username.
		   For example, in john.doe@somewhere.com, john and doe are words.
		   Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")"
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		/* The following pattern describes the structure of a normal symbolic
		   domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		
		
		/* Finally, let's start trying to figure out if the supplied address is
		   valid. */
		
		/* Begin with the coarse pattern to simply break up user@domain into
		   different pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
		  /* Too many/few @'s or something; basically, this address doesn't
			 even fit the general mould of a valid e-mail address. */
			return false;
			}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		// See if "user" is valid 
		if (user.match(userPat)==null) {
			// user is not valid

			return false
		}
		
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		   host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			// this is an IP address
			  for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {

				return false
				}
			}
			return true
		}
		
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) 
		{

			return false
		}
		
		/* domain name seems valid, but now make sure that it ends in a
		   three-letter word (like com, edu, gov) or a two-letter word,
		   representing country (uk, nl), and that there's a hostname preceding 
		   the domain or country. */
		
		/* Now we need to break up the domain to get a count of how many atoms
		   it consists of. */
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
		   // the address must end in a two letter or three letter word.

		   return false
			}
	
	// Make sure there's a host name preceding the domain.
	if (len<2) {

	   return false
	}
	
	// If we've gotten this far, everything's valid!
	return true;
	} // end function
	
	
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function goForward(section)
{
	document.formObject.toSectionForward.value = section;
	document.formObject.toSectionBackward.value = "";
}

function goBack(section)
{
	document.formObject.toSectionBackward.value = section;
	document.formObject.toSectionForward.value = "";
}

function checkFieldsValidForward(section)
{
	var error = false;
	if(section == "section2")
	{
		//check the fields are valid from page 1
		validateSection1EmptyFields();
		validateSection1AlphaNumericFields();
		validateSection1NumericFields();
		validateSection1PasswordField();
		validatePhoneNumbers();
		validateSection1PasswordsAreTheSame();
		validateSection1Email();
		validateSection1DOBYearCheck();
		validateSection1DOBFieldsValid();
		validateSection1PostCodeLengthCheck();
		error = printErrorMessage();
		return evaluateError(error, "section2");
	}
	
	if(section == "section3")
	{
		//check the fields are valid from page 2
		validateSection2EmptyFields();
		validateSection2AlphaNumericFields();
		validateSection2NumericFields();
		validateSection2PostCodeLengthCheck();
		error = printErrorMessage();
		return evaluateError(error, "section3");
	}

        if (section == "section4") {
             validateSection3EmptyFields();
             error = printErrorMessage();
	     return evaluateError(error, "section4");
        }
	
	if(section == "section5")
	{
		// Check the fields are valid from page 5
		validateSection5EmptyFields();
		validateSection5NumericFields();
		validateSection5CheckTerms();
		error = printErrorMessage();
		if(error == false)
			document.formObject.lastpage.value = "true"; // set the variable to true because we are ready to submit to database
		return evaluateError(error, "section5");
	}				
}


function unCheck2() {
		if(document.formObject.check66.checked == true)
    {
      document.formObject.check61.checked = false;
	  document.formObject.check62.checked = false;
	  document.formObject.check63.checked = false;
	  document.formObject.check64.checked = false;
	  document.formObject.check65.checked = false;
	  document.formObject.check67.checked = false;
    }
	}

function unCheck3() {
		if(document.formObject.check118.checked == true)
    {
      document.formObject.check111.checked = false;
	  document.formObject.check112.checked = false;
	  document.formObject.check113.checked = false;
	  document.formObject.check114.checked = false;
	  document.formObject.check115.checked = false;
	  document.formObject.check117.checked = false;
    }
	}

function unCheck1(id) {
//document.getElementById(id).style.display = 'inline';
		if(document.formObject.check2.checked == true)
    {
      document.formObject.check1.checked = false;
    }
}

/* NEW SELECT REP FUNCTIONS */
var xmlHttp

function changeRep(element) {
 xmlHttp=GetXmlHttpObject();
 
 if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
 } 

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET","../repList.php?state="+element.value,true);
xmlHttp.send(null);
}

function stateChanged()  { 
 if (xmlHttp.readyState==4) { 
  document.getElementById("selrepdiv").innerHTML=xmlHttp.responseText;
 }
}

function GetXmlHttpObject() {
 var xmlHttp=null;
  try {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
  catch (e) {
  // Internet Explorer
    try {
     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
 return xmlHttp;
}
function fixmobile(what)
{
	what.value = what.value.replace('+','');
	if(parseInt(what.value.charAt(2)) == 0)
	{
		what.value = what.value.replace('0','');	
	}
	if(parseInt(what.value.charAt(2)) == 6 && parseInt(what.value.charAt(3)) == 1)
	{
		what.value = what.value.replace('6161','61');	
	}
	if(parseInt(what.value.charAt(2)) == 6 && parseInt(what.value.charAt(3)) == 4)
	{
		what.value = what.value.replace('6464','64');	
	}
}
function setprefix(what,remove)
{
	if(!remove)
	{
		if(document.forms['formObject'].selCountry.value == 'Australia')
		{
			what.value = '61';	
		}
		if(document.forms['formObject'].selCountry.value == 'New Zealand')
		{
			what.value = '64';	
		}
	}
	if(remove)
	{
		if(what.value == '61' || what.value == '64')
		{
			what.value = '';	
		}
	}
}