

function ValidateForm() 
{

	//
	// Set variables
	//Error messages are contained in an array called ErrorMessage[] which is created in ErrorMessage_default.js and custom 
	//error messages are in files with the naming convention: ErrorMessages_<siteid>.js	
		var FilledCorrectly = true;
		var message = "";
		message += "The form was not correctly filled in. Please check the following problems:\n\n";



	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was entered in the first name field
	//
		if (document.frm.txtFirstName.value == "") {
			//no first name entered
			message += ErrorMessage[1];
			FilledCorrectly = false;
			}

	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was entered in the surname field
	//
		if (document.frm.txtSurname.value == "") {
			message += ErrorMessage[2];
			FilledCorrectly = false;
			}

	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was enterer in the house number field
	// If so check it contains only numbers
	//
		if (document.frm.searchPremise)
		{
			if (document.frm.searchPremise.value == "") {
				message += ErrorMessage[3];
				FilledCorrectly = false;
				}
		}
		

		
	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was entered in the postcode field
	//

		
			if (document.frm.searchPostCode.value == "") {			
				message += ErrorMessage[4];
				FilledCorrectly = false;
				}
			else 
				{
				var x = document.frm.searchPostCode.value;
				var filter = /^[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]{0,1}[ ]{0,1}[0-9][a-zA-Z]{2}$/;
					if (filter.test(x))
					{
					}
					else
					{
					message += ErrorMessage[5];
					FilledCorrectly = false;
					}
				}
				
				
	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was entered in the email field
	// If so, check sl see it contains a '@' and a '.'
	//
		if (document.frm.txtEmail.value == "") 
			{
			message += ErrorMessage[6];
			FilledCorrectly = false;
			}
		else 
		{
			var x = document.frm.txtEmail.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
				if (filter.test(x))
				{
				}
				else
				{
				message += ErrorMessage[7];
				FilledCorrectly = false;
				}
			}

	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was enterer in the house number field
	// If so check it contains only numbers
	//

			if (document.frm.cboBirthDay.value == "") {
				message += "Please enter your brith day\n";
				FilledCorrectly = false;
				}


	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was enterer in the house number field
	// If so check it contains only numbers
	//

			if (document.frm.cboBirthMonth.value == "") {
				message += "Please enter your birth month\n";
				FilledCorrectly = false;
				}


	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was enterer in the house number field
	// If so check it contains only numbers
	//

			if (document.frm.cboBirthYear.value == "") {
				message += "Please enter your birth year\n";
				FilledCorrectly = false;
				}

				

	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was enterer in the house number field
	// If so check it contains only numbers
	//

			if (document.frm.job.value == "") {
				message += "Please enter your job\n";
				FilledCorrectly = false;
				}

			
	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was enterer in the house number field
	// If so check it contains only numbers
	//

			if (document.frm.employer.value == "") {
				message += "Please enter your employer\n";
				FilledCorrectly = false;
				}

	/////////////////////////////////////////////////////////////////////
	//
	// Check to see if a value was enterer in the house number field
	// If so check it contains only numbers
	//

			if (document.frm.workAddress.value == "") {
				message += "Please enter your work address\n";
				FilledCorrectly = false;
				}


	/////////////////////////////////////////////////
	/// Check for weekly hours, there must be a value and
	/// it must be numeric

		if (document.frm.hoursWorked.value == "")
		{
			message += "You have not entered your weekly hours worked, ";
			message += "If you are not currently working then please enter 0, ";
			message += "for the number of hours worked\n";
			FilledCorrectly = false;
		}
		if ( isNaN(document.frm.hoursWorked.value) )
		{
			message += "The hours worked must be numeric\n";
			FilledCorrectly = false;
		}



	/////////////////////////////////////////////////////////////////////*/
	//
	// Now check to see if any of the checks returned false and if so call alert
	
	
	//
		if (FilledCorrectly == false) 
		{
			alert(message);
			return false;
		}
	return true;
			


}




