function validateForm(form) {	
	var required = Array('name', 'phone', 'email');
	
	for (var i=0; i<required.length; i++) {
		var field = required[i];
		var name = field.replace("_", " ");

		if (form[field].value == "") { 
			alert('\'' + name + '\' is a required field.');
			form[field].focus();
			return false;
		}	
	}

	//validateEmail(form.email.value)) {
	
	return true;
}



function showEmailError(msg) {
	if (msg==null) msg = "Please enter a valid email address";
	alert(msg);
	form.email.focus();
}

function validateEmail(email) {
	alert('blah');
	
	if (!allValidChars(email)) {  // check to make sure all characters are valid
		showEmailError("Email address can only contain letters, numbers, @.-_");
		return false;
	} else if (email.indexOf("@") < 1) {
		showEmailError();
		return false;
	} else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
		showEmailError();
		return false;
	} else if (email.indexOf("@") == email.length) {  // @ must not be the last character
		showEmailError();
		return false;
	} else if (email.indexOf("..") >=0) { // two periods in a row is not valid
		showEmailError();
		return false;
	} else if (email.indexOf(".") == email.length) {  // . must not be the last character
		showEmailError();
		return false;
	} else {
		return false;
	}
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}
