function trim(str)
{ 
	return str.replace(/^\s+|\s+$/, ''); 
}

function validateEmail(str)
{
    regex = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$");
    return regex.test(str);
}

function validateForm()
{
	error = false;
	error_string = "Please correct the following error(s):\n\n";

	if (trim(document.contactform.name.value) == "")
	{
		error = true;
		error_string = error_string + "- you must enter a name\n";
	}
	if (!validateEmail(trim(document.contactform.email.value)))
	{
		error = true;
		error_string = error_string + "- you must enter a valid E-mail address\n";
	}
	if (trim(document.contactform.message.value) == "")
	{
		error = true;
		error_string = error_string + "- you must enter a message\n";
	}

	if (error == true)
	{
		alert (error_string);
	}

	return (!error);
}

