// JavaScript Document

function checkData(Form) {

	var strErrMsg = "";

				

	if (Form.name.value == '') {

		strErrMsg += " - Name field is required\n"

	}

	

	if (Form.company.value == '') {

		strErrMsg += " - Company field is required\n"

	}

	

	if (Form.phone.value == '') {

		strErrMsg += " - Phone field is required\n"

	}

	

	if (Form.email.value == '') {

		strErrMsg += " - Email field is required\n"

	}else{	

		// test if valid email address, must have @ and .

		var checkEmail = "@.";

		var checkStr = 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)

		{

			strErrMsg += " - The email field must contain an \"@\" and a \".\".\n"

		}	

	}

	

	if (Form.list2.options[Form.list2.selectedIndex].value == ''){

		strErrMsg += " - 'How did you hear of us' field is required\n"

	}

	

	if (strErrMsg != '') {

		alert("Following Errors Occured on submission:\n\n" + strErrMsg);

		return false;

		

	}else {			

		return true;

	}				

}



