	
		function submitForm()
		{
			if(checkFormValues()) {
				return true;
			}else {
				return false;
			}
		}
		
		/**
		 *  Check the form is filled out in full
		 */	
		function checkFormValues()
		{
			var mainform = document.forms.checkMe;
			
			/* course choice */
			var choiceselected = false;
			for (var i=0; i < mainform.Course.length; i++) 
			{
				if(mainform.Course[i].checked)
					choiceselected = true;
			}
			if (!choiceselected)
			{
				alert('Please select your chosen course.');
				window.location = "#CourseChoice";
				return false;
			}
			
			/* name */
			if (mainform["FullName"].value == '')
			{
				alert('Please enter your name.'); 
				window.location = "#FullName"; 
				mainform["FullName"].focus();
				return false;
			}
			
			/* address */
			if (mainform["Address"].value == '')
			{
				alert('Please enter your address.'); 
				window.location = "#Address"; 
				mainform["Address"].focus();
				return false;
			}
			
			/* postcode */
			if (mainform["Postcode"].value == '')
			{
				alert('Please enter your postcode.'); 
				window.location = "#Postcode"; 
				mainform["Postcode"].focus();
				return false;
			}
			
			/* phone */
			if (mainform["Telephone"].value == '')
			{
				alert('Please enter your telephone number.'); 
				window.location = "#Telephone"; 
				mainform["Telephone"].focus();
				return false;
			}
			
			/* email */
			if (mainform["Email"].value == '')
			{
				alert('Please enter your e-mail address.'); 
				window.location = "#Email"; 
				mainform["Email"].focus();
				return false;
			}
			
			/* check any delivery fields are filled in at all */
			if (mainform["DeliveryName"].value == '' &&
				mainform["DeliveryAddress"].value == '' &&
				mainform["DeliveryPostcode"].value == '' &&
				mainform["DeliveryTelephone"].value == '')
			{
				alert("Please enter your delivery details.\n\nIf the details are the same as the name and address you've filled in already, please check the box\n\n'Delivery Address as above'");
				
				mainform["UseMainAddressForDelivery"].focus();
				window.location = "#UseMainAddressForDelivery"; 
				return false;
			}
			
			/* delivery name */
			if (mainform["DeliveryName"].value == '')
			{
				alert('Please enter your delivery name.'); 
				mainform["DeliveryName"].focus();
				window.location = "#DeliveryName"; 
				return false;
			}
			
			/* delivery address */
			if (mainform["DeliveryAddress"].value == '')
			{
				alert('Please enter your delivery address.'); 
				mainform["DeliveryAddress"].focus();
				window.location = "#DeliveryAddress"; 
				return false;
			}
			
			/* delivery postcode */
			if (mainform["DeliveryPostcode"].value == '')
			{
				alert('Please enter your delivery postcode.'); 
				mainform["DeliveryPostcode"].focus();
				window.location = "#DeliveryPostcode"; 
				return false;
			}
			
			/* delivery phone */
			if (mainform["DeliveryTelephone"].value == '')
			{
				alert('Please enter your delivery telephone number.'); 
				mainform["DeliveryTelephone"].focus();
				window.location = "#DeliveryTelephone"; 
				return false;
			}
			
			/* terms & conditions */
			if (!mainform["TermsAndConditions"].checked)
			{
				alert('Please indicate that you agree to the terms and conditions.'); 
				mainform["TermsAndConditions"].focus();
				window.location = "#TermsAndConditions"; 
				return false;
			}
			
			return true;
		}
		
		/**
		 *  Fill in delivery fields with home address values
		 */		 		
		function fillDeliveryFields()
		{
			var mainform = document.forms.checkMe;
			
			if (mainform["UseMainAddressForDelivery"].checked)
			{
				/* required fields */
				if (mainform["FullName"].value == '' ||
					mainform["Address"].value == '' ||
					mainform["Postcode"].value == '' ||
					mainform["Telephone"].value == '')
				{
					alert("Please make sure your name, address, postcode and telephone are filled in, then click 'Delivery Address as above' again");
					mainform["UseMainAddressForDelivery"].checked = false; 
					//mainform["FullName"].focus();
					window.location = "#FullName"; 
					return false; 
				}
				
				/* copy field values */
				mainform["DeliveryName"].value = mainform["FullName"].value;
				mainform["DeliveryAddress"].value = mainform["Address"].value;
				mainform["DeliveryPostcode"].value = mainform["Postcode"].value;
				mainform["DeliveryTelephone"].value = mainform["Telephone"].value;
			}
			else
			{
				/* clear field values */
				mainform["DeliveryName"].value = '';
				mainform["DeliveryAddress"].value = '';
				mainform["DeliveryPostcode"].value = '';
				mainform["DeliveryTelephone"].value = '';
			}
		}
		
		/**
		 *  NOT USED
		 *  If a delivery address field changes and user clicks out,
		 *  uncheck the UseMainAddressForDelivery checkbox
		 */	
		function uncheckUseMainAddress()
		{
			var mainform = document.forms.checkMe;
			mainform["UseMainAddressForDelivery"].checked = false;
		}
		

