function validate(contactForm)
{
	// this validates the information that is to be sent
	// if all fields are correct then itlets the form proceed
	var name = document.getElementsByName("name");	// the name of the sender
	var email = document.getElementsByName("email"); //	the email address of the sender
	var subject = document.getElementsByName("subject"); // the subject of the email
	var message = document.getElementsByName("message"); // the body of the email
	var errorMessage = "";
	
	if (name == null || name[0].value == "")	// is there a name there
	{
		errorMessage += ("Name missing \n");
	}
	if (email == null || isNotValidEmail(email[0].value))	// is there a valid email address
	{
		errorMessage += ("Email address is invalid \n");
	}
	if (subject == null || subject[0].value == "")	// is there a subject
	{
		errorMessage += ("Subject is missing \n");
	}
	if (message == null || message[0].value == "")	// is there a message
	{
		errorMessage += ("Message is missing \n");
	}
	
	if (errorMessage!="")	// if there are error messages alert the user and return false
	{
		alert("The following errors have been found: \n" + errorMessage);
		return false;
	}
	return true;	// it all went sweet, submit the form
}

function isNotValidEmail(mail) 
{ 
	// check whether the string recived is a valid format for an email
	// if not valid, return true, otherwise return false
	if (mail=="")	// cant have an email of nothing
	{
		return true;
	}
	var indexOfAt = mail.indexOf('@',1);	// finds the index of the occurence about the first '@'
	if ( (indexOfAt == -1) || (indexOfAt == (mail.length-1)) )	// if '@'is not in the string or is the last charater then isNotValidEmail() returns false
    {
		return true;
	}
	return false;	// most llikry a valid email so let is pass
}