// form validation on home


function form_validation()
{

	if(document.quick_form.name.value == "name*")
	{
	alert("Enter the name");
	document.quick_form.name.value = ""
	document.quick_form.name.focus();
	return (false);
	}
	

	
	// test if valid email address, must have @ and .
	var checkEmail = "@.";
	var checkStr = document.quick_form.email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	
		if (document.quick_form.email.value == "email*")
	{
		alert("Please enter a value for the \"Email\" field.");
		document.quick_form.email.value = ""
		document.quick_form.email.focus();
		return (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.quick_form.email.focus();
	return (false);
	}



/* Phone Number Validation */	
	var checkOK = "0123456789";
	var	checkStr = document.quick_form.phone.value;
	var allValid = true;
	var allNum = "";
	
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length)
	{
	allValid = false;
	break;
	}
	if (ch != ",")
	allNum += ch;
	}
	if (!allValid)
	{
	alert("Please enter only digit characters in the \"Telephone number\" field.");
	document.quick_form.phone.value = ""
	document.quick_form.phone.focus();
	return (false);
	}
	

return true;
}
