function validateContact(form) {
	
	var errors = new Array();
	
	if (form.fromName.value == "") {
		errors.push('Must include your name');
	}
	
	if (form.fromEmail.value == "") {
		errors.push('Must include your email');
	} else if (validateEmail(form.fromEmail.value) <= 0) {
		errors.push('Must include a valid email address');
	}
	
	if (form.subject.value == "") {
		errors.push('Must include a subject');
	}
	
	if (errors.length > 0) {
		var errMessage = "Please fix the following errors first:\n\n";
		for (var i = 0; i < errors.length; i++) {
			var err = errors[i];
			errMessage += " - " + err + "\n";
		}
		alert(errMessage);
		return false;
	} else {
		//form.submit();
		return true;
	}
}

function validateEmail (e) {
	var i, j, l = e.length;

	var foundPoint = false;

	function checkChars (s, i, l)
	{
		while (i<l && ("_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789").indexOf(s.charAt(i)) != -1)
		{
			i++;
		}
		return i;
	}
	function checkFirstLevelDomainChars (s, i, l)
	{
		while (i<l && ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(s.charAt(i)) != -1)
		{
			i++;
		}
		return (i == l);
	}
	
	if ((i=checkChars(e, 0, l)) == 0)
	{
		return -1;
	}
	j=i;
	// followed by an arbitrary number of ("." string) combinations
	while (i<l && e.charAt(i) == ".")
	{
		// skip the point
		i++;
		// if there are no chars, we have an error
		if ((j=checkChars(e, i, l)) == i)
		{
			return -2;
		}
		// else skip the chars
		i = j;
		// trace(e.substring(i));
	}
	// then follows the magic @
	if (e.charAt(i) != "@")
	{
		// trace(e.charAt(i));
		return -3;
	}
	// followed by minimum one string point string
	// after the last point minimum 2 characters are allowed
	do {
		// skip the @ (j == i at the beginning, so it is like i++)
		i = j+1;
		// trace(e.substring(i));
		// do we have more chars ?
		j = checkChars(e, i, l);
		if (j == i) {
			// no more chars found -> error
			return -4;
		}
		else if (j == e.length)
		{
			// trace("j==e.length");
			// emailaddress is finished, do we have a first level domain ?
			j -= i;
			// we have one if it is at least 2 long and consists of the correct characters
			if(foundPoint && j>=2 && checkFirstLevelDomainChars(e, i, l))
			{
				return 1
			}
			else
			{
				return -5
			}
		}
		// if we reach the end or don't have a point, we return an error
		foundPoint = (e.charAt(j) == ".");
	} while (i<l && foundPoint);
	return -6;
}
