// JavaScript Document

//document.forms[0].onsubmit = checkDownload;
document.getElementById("btnContact").onclick = checkContact;

function checkContact()
{
	var isValid = true;
	var f = document.forms[0];
	var errors = "Please enter your information in the following required fields:               \n";

	if(f.n.value.length == 0)
	{
		errors += "\n\t *  A Name is required.";
		isValid = false;	
	}
	if(f.phone.value.length == 0)
	{
		errors += "\n\t *  A Phone Number is required.";
		isValid = false;	
	}
	if(f.email.value.length == 0)
	{
		errors += "\n\t *  A Contact Email Address is required.";
		isValid = false;
	}
	 else
	{
		// Check for Properly Formatted Email Addresses
		if (!(isValidEmail(f.email.value))) {
			errors += "\n\t * A properly formatted Email address is required.";
			isValid = false;
		}
	}
	
	if(f.comments.value.length == 0)
	{
		errors += "\n\t *  Please type your message.";
		isValid = false;	
	}
	
	if(!isValid)
	{
		alert(errors);
		return false;
	}
	else
	{
		return true;
		document.forms[0].submit();
	}
}

// Check for valid Email Address
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}