function checkForm(myform){
	var error = 0;
	var total = myform.length;
	for(i=0;i<total;i++){
		myform[i].style.backgroundColor = "";
	}
	
	if(myform.title.value == ""){
		alert("You must complete the Title field");
		myform.title.style.backgroundColor = "#F56C8A";
		error = 1;
	}
	
	if(myform.first_name.value == ""){
		alert("You must complete the First Name field");
		myform.first_name.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(myform.last_name.value == ""){
		alert("You must complete the Family Name field");
		myform.last_name.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(myform.company.value == ""){
		alert("You must complete the Company / Organisation field");
		myform.company.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(myform.position.value == ""){
		alert("You must complete the Position field");
		myform.position.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(myform.address_1.value == ""){
		alert("You must complete the Address 1 field");
		myform.address_1.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(myform.town_city.value == ""){
		alert("You must complete the Town/City field");
		myform.town_city.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(myform.post_zip.value == ""){
		alert("You must complete the Zip/Postcode field");
		myform.post_zip.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(myform.country.value == ""){
		alert("You must complete the Country field");
		myform.country.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	var EmailError = false;
	if(myform.email.value == ""){
		alert("You must complete the Email field");
		myform.email.style.backgroundColor = "#F56C8A";
		EmailError = true;
		error = 1;
	}
	if(myform.con_email.value == ""){
		alert("You must complete the Confirm Email field");
		myform.con_email.style.backgroundColor = "#F56C8A";
		EmailError = true;
		error = 1;
	}
	if(myform.con_email.value != myform.email.value){
		alert("The Email field must match the Confirm Email field");
		myform.email.style.backgroundColor = "#F56C8A";
		myform.con_email.style.backgroundColor = "#F56C8A";
		EmailError = true;
		error = 1;
	}
	var checkEmail = "@.";
	var checkStr = myform.email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)	{
			if (ch == checkEmail.charAt(j) && ch == "@") { EmailAt = true; }
			if (ch == checkEmail.charAt(j) && ch == ".") { EmailPeriod = true; }
			if (EmailAt && EmailPeriod) {	break; }
			if (j == checkEmail.length) {	break; }
		}
		// if both the @ and . were in the string
		if (EmailAt && EmailPeriod)	{
			EmailValid = true
			break;
		}
	}
	if (!EmailValid && !EmailError) {
		alert("The \"Email\" field must contain a valid email address.");
		myform.email.style.backgroundColor = "#F56C8A";
		error = 1;
	}
	
	if(myform.secondary_email.value != "" || myform.con_secondary_email.value != ""){

		var EmailError = false;
		if(myform.secondary_email.value == ""){
			alert("You must complete the Secondary Email field");
			myform.secondary_email.style.backgroundColor = "#F56C8A";
			EmailError = true;
			error = 1;
		}
		if(myform.con_secondary_email.value == ""){
			alert("You must complete the Confirm Secondary Email field");
			myform.con_secondary_email.style.backgroundColor = "#F56C8A";
			EmailError = true;
			error = 1;
		}
		if(myform.con_secondary_email.value != myform.secondary_email.value){
			alert("The Email field must match the Confirm Secondary Email field");
			myform.secondary_email.style.backgroundColor = "#F56C8A";
			myform.con_secondary_email.style.backgroundColor = "#F56C8A";
			EmailError = true;
			error = 1;
		}
		var checkEmail = "@.";
		var checkStr = myform.secondary_email.value;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
		for (i = 0;  i < checkStr.length;  i++)	{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkEmail.length;  j++)	{
				if (ch == checkEmail.charAt(j) && ch == "@") { EmailAt = true; }
				if (ch == checkEmail.charAt(j) && ch == ".") { EmailPeriod = true; }
				if (EmailAt && EmailPeriod) {	break; }
				if (j == checkEmail.length) {	break; }
			}
			// if both the @ and . were in the string
			if (EmailAt && EmailPeriod)	{
				EmailValid = true
				break;
			}
		}
		if (!EmailValid && !EmailError) {
			alert("The \"Secondary Email\" field must contain a valid email address.");
			myform.secondary_email.style.backgroundColor = "#F56C8A";
			error = 1;
		}
	}

	if(myform.captcha_input.value == ""){
		alert("You must complete the Security Code field");
		myform.captcha_input.style.backgroundColor = "#F56C8A";
		error = 1;
	}

	if(error == 1){
		return(false);
	}
	
}
