// JavaScript Document

function initialName(field,alerttxt){
	with (field){
	  	if (value=="First Last"){
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function initialEmail(field,alerttxt){
	with (field){
	  	if (value=="name@domain.com"){
			alert(alerttxt);
			return false ;
		}
		else {
			return true;
		}
	}
}

function empty(field,alerttxt){
	with (field){
	  	if (value==null||value==""||value=="blank"){
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function BADemail(field,alerttxt){
	with (field){
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2||value=="name@domain.com"){
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_form(thisform){
	with (thisform){
		if (empty(From,"Please enter your name")==false){
			From.focus();
			return false;
		}
		else if (initialName(From,"You didn't enter your name")==false){
			From.focus();
			return false;
		}
		else if (empty(Sender,"Please enter your email address")==false){
			Sender.focus();
			return false;
		}
		else if (initialEmail(Sender,"You didn't enter your email address")==false){
			Sender.focus();
			return false;
		}
		else if (BADemail(Sender,"Not a valid e-mail address")==false){
			Sender.focus();
			return false;
		}
		else if (empty(State,"Let us know what state your from")==false){
			State.focus();
			return false;
		}
		else if (empty(Message,"You didn't type a message")==false){
			Message.focus();
			return false;
		}
		else {
		return true;
		}
	}
}