// Generic Form Validation

function validate_form() {



		// #############################
		// check if clientName field is blank
		// #############################

		if (document.form.clientName.value == "") {

			alert("Please enter a value for the \"Client Name\" field.");
			
			document.form.clientName.focus();

			return false

		}



		// ################################
		// check if jobTitle field is blank
		// ################################

		if (document.form.jobTitle.value == "") {

			alert("Please enter a value for the \"Job Title\" field.");
			
			document.form.jobTitle.focus();

			return false

		}




		// ################################
		// check if companyName field is blank
		// ################################

		if (document.form.companyName.value == "") {

			alert("Please enter a value for the \"Company Name\" field.");
			
			document.form.companyName.focus();

			return false

		}


		// ################################
		// check if telephone field is blank
		// ################################

		if (document.form.telephone.value == "") {

			alert("Please enter a value for the \"Telephone\" field.");
			
			document.form.telephone.focus();

			return false

		}		
		



		// #############################
		// check if EMAIL field is blank
		// #############################

		if (document.form.email.value == "") {

			alert("Please enter a value for the \"email\" field.");
			
			document.form.email.focus();

			return false

		}



		// #################################################
		// Test if valid email address i.e must have @ and .
		// #################################################

		var checkEmail = "@.";

		var checkStr = document.form.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) {

			alert("The \"email\" field must contain an \"@\" and a \".\".");

			document.form.email.focus();

			return false

		}



		// ################################
		// check if chosenUsername field is blank
		// ################################

		if (document.form.chosenUsername.value == "") {

			alert("Please enter a value for the \"Chosen Username\" field.");
			
			document.form.chosenUsername.focus();

			return false

		}




		// ################################
		// check if chosenPassword field is blank
		// ################################

		if (document.form.chosenPassword.value == "") {

			alert("Please enter a value for the \"Chosen Password\" field.");
			
			document.form.chosenPassword.focus();

			return false

		}






}