/*
	Purpose:		Contact Form Validation
	Created By: 	Melanie Decle (www.melaniedecle.com)
	Date:			11th May 2004
*/

function validateContact(f)
{   
	// check for empty email address value
	if(f.email.value=="")
	{
		alert("Please enter your email address.");
		f.email.focus();
		f.email.value = "";		
		return false;
	}
	
	if(f.subject.value=="")
	{
		alert("Please enter a subject.");
		f.subject.focus();
		f.subject.value = "";
		return false;
	}
			
	// valid email format that must have at least one @ and .
	if(!checkEmailFormat('email'))
	{
	  alert( "The email address format is invalid, please re-enter." );
	  f.email.value = "";
	  f.email.focus();
	  return false;
	}
		
	//function to validate email checking length and @ and . in it
	function checkEmailFormat(tag)
	{     
		 // Theoretically, the shortest email address is:
		 // x@x.xx  Therefore, length MUST be >= 6
		if(f.email.value.length < 6 ||  f.email.value.indexOf("@") == -1 || f.email.value.indexOf(".") == -1 )       
		return false;
		else return true;
	}	
	
	// check for empty message value
	if(f.message.value=="")
	{
		alert("Please enter your message in the area provided before sending.");
		f.message.focus();
		return false;
	}	
}	