
function check_email() {
	var valid = 1;
	if (document.form1.email.value.indexOf('@') == -1) {
		valid=0; mes = ' All e-mail addresses must contain a "@"!';
	}
	if (document.form1.email.value.indexOf(" ") != -1) {
		valid=0; mes = " E-mail addresses cannot contain spaces!";
	}
	if (document.form1.email.value.length <= 6) {
		valid=0; mes = " This is too short to be a valid e-mail address!";
	}
	if (document.form1.email.value.indexOf("@.") != -1 || document.form1.email.value.indexOf(".@") != -1) {
		valid=0; mes = ' Dot punctuation cannot be adjacent to the "@"!';
	}

	if (valid == 0 && document.form1.email.value.length > 0) {
		alert('"'+ document.form1.email.value + '"' + " is not a valid e-mail address." + "\n" + mes + "\n" + " Please try again.");
		document.form1.email.value = "";
		document.form1.email.focus();
	}
}

function check_friendemail() {
	var valid = 1;
	if (document.form1.friendemail.value.indexOf('@') == -1) {
		valid=0; mes = ' All e-mail addresses must contain a "@"!';
	}
	if (document.form1.friendemail.value.indexOf(" ") != -1) {
		valid=0; mes = " E-mail addresses cannot contain spaces!";
	}
	if (document.form1.friendemail.value.length <= 6) {
		valid=0; mes = " This is too short to be a valid e-mail address!";
	}
	if (document.form1.friendemail.value.indexOf("@.") != -1 || document.form1.friendemail.value.indexOf(".@") != -1) {
		valid=0; mes = ' Dot punctuation cannot be adjacent to the "@"!';
	}

	if (valid == 0 && document.form1.friendemail.value.length > 0) {
		alert('"'+ document.form1.friendemail.value + '"' + " is not a valid e-mail address." + "\n" + mes + "\n" + " Please try again.");
		document.form1.friendemail.value = "";
		document.form1.friendemail.focus();
	}
}

function check_phone() {
  if (document.form1.Phone.value.length < 10 && document.form1.Phone.value.length > 0) {
	alert(" Please don't forget to enter your phone number area code.");
	newValue = "(area code) " + document.form1.Phone.value;
	document.form1.Phone.value = newValue;
	document.form1.Phone.focus();
  }
}

function checkFieldsContact() {
  if (document.form1.email.value == "") {
	alert(" Please enter your e-mail address to send message ");
	document.form1.email.focus();
	return false;
  }
  else { return true; }
}

function checkFriendFields() {
  if (document.form1.friendemail.value == "" || document.form1.email.value == "" || document.form1.Name.value == "") {
	mes = "all fields"; if (document.form1.friendemail.value == "") {
		mes = "your friend's e-mail address"; document.form1.friendemail.focus();
	}
	else if (document.form1.email.value == "") {
		mes = "your e-mail address"; document.form1.email.focus();
	}
	else if (document.form1.Name.value == "") {
		mes = "your name"; document.form1.Name.focus();
	}
	alert(" Please enter " + mes + " to send message ");
	return false;
  }
  else { return true; }
}
