﻿	function validateForm() {
		var focusFld = "";
		var errorMsgs = "";
		var selectedIndex = document.getElementById("HowFound").selectedIndex;
		var selectedOption = document.getElementById("HowFound").options[selectedIndex].value;

		if (document.getElementById('Name').value == "") {
			if (focusFld == "")
				focusFld = "Name";
			errorMsgs += "Please enter your name\n";
		}

		if (document.getElementById('Telephone').value == "" && document.getElementById('Email').value == "") {
			if (focusFld == "")
				focusFld = "Telephone";
			errorMsgs += "Please enter your telephone number or email address\n";
		}

		if (document.getElementById('Enquiry').value == "") {
			if (focusFld == "")
				focusFld = "Enquiry";
			errorMsgs += "Please enter an Enquiry\n";
		}
		
		if (selectedOption == "select") {
			if (focusFld == "")
				focusFld = "HowFound";
			errorMsgs += "Please select how you found us\n";
		}

		if ((selectedOption == "seother" || selectedOption == "other" || selectedOption == "magazine") && document.getElementById("HowFoundOther").value == "") {
			if (focusFld == "")
				focusFld = "HowFoundOther";
			switch(selectedOption) {
				case "other":
					errorMsgs += "Please enter how you found us\n";
					break;
				case "seother":
					errorMsgs += "Please enter a search engine\n";
					break;
				case "magazine":
					errorMsgs += "Please enter a magazine\n";
					break;
			}
		}
		
		if (errorMsgs != "") {
			alert(errorMsgs);
			document.getElementById(focusFld).focus();
			return false;
		}
		return true;
		
	}

	function HowFoundChanged() {
		var selectedIndex = document.getElementById("HowFound").selectedIndex;
		var selectedOption = document.getElementById("HowFound").options[selectedIndex].value;

		document.getElementById("HowFoundOther").value = "";

		if (selectedOption == "other" || selectedOption == "seother" || selectedOption == "magazine") {
			document.getElementById("HowFoundOther").style.visibility = "visible";
			switch(selectedOption) {
				case "other":
					document.getElementById("OtherLabel").innerHTML = "Other:";
					break;
				case "seother":
					document.getElementById("OtherLabel").innerHTML = "Search Engine:";
					break;
				case "magazine":
					document.getElementById("OtherLabel").innerHTML = "Magazine:";
					break;
			}
		}
		else {
			document.getElementById("HowFoundOther").style.visibility = "hidden";
			document.getElementById("OtherLabel").innerHTML = "";
		}
	}


