
/* SUBMIT CONTACT FORM VALIDATION */
function validEmail(email) {
	invalidChars = ' !#$%^&*(){}[]+=~`?/:;,"'

	
	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) { //does it contain any invalid characters?
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)  		//there must be one "@" symbol
		if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) != -1) { //and only one "@"
		return false;
	}
	periodPos = email.indexOf(".",atPos+1)  //and at least one "." after the "@"
		if (periodPos == -1) {
		return false;
	}
	if (email.charAt(atPos+1) == ".") {	//is there a "." right after the "@"
		return false;
	}
	if (periodPos+3 > email.length) {  	//must be at least 2 characters after the "."
		return false;
	}
	return true;
}

function validateEmailSignup(form) {
	
	if (form.fname.value == '') {
		alert("Please fill in your first name.");
		form.fname.focus();
		form.fname.select();
		return false;
	}
	if (form.lname.value == '') {
		alert("Please fill in your last name.");
		form.lname.focus();
		form.lname.select();
		return false;
	}
	if (!validEmail(form.femail.value)) {
		alert("A valid E-mail Address is required.");
		form.femail.focus();
		form.femail.select();
		return false;
	}
	
	var myindexvalue = form.faddresstype.value
	var myindex = form.faddresstype.selectedIndex
	if (myindexvalue == 0) {
		alert("Please select an Address Type.");
		form.faddresstype.focus();
		return false;
	}
	
	if (form.faddress.value == '') {
		alert("Please fill in your address.");
		form.faddress.focus();
		form.faddress.select();
		return false;
	}
	if (form.fcity.value == '') {
		alert("Please fill in your city.");
		form.fcity.focus();
		form.fcity.select();
		return false;
	}
	
	var myindexvalue = form.fstate.value
	var myindex = form.fstate.selectedIndex
	if (myindexvalue == 0) {
		alert("Please select a State.");
		form.fstate.focus();
		return false;
	}
	var myindexvalue = form.fcountry.value
	var myindex = form.fcountry.selectedIndex
	if (myindexvalue == 0) {
		alert("Please select a Country.");
		form.fcountry.focus();
		return false;
	}
	
	if (form.fzip.value == '') {
		alert("Please fill in your Zip Cpde.");
		form.fzip.focus();
		form.fzip.select();
		return false;
	}
	if (form.fphonework.value == '') {
		alert("Please fill in your phone number.");
		form.fphonework.focus();
		form.fphonework.select();
		return false;
	}
	return true;
}
	
function ValidateSubmit(form) {
	
	
	var myindexvalue = form.referrer.value
	var myindex = form.referrer.selectedIndex
	if (myindexvalue == 0) {
		alert("Please select a recipient.");
		return false;
	}
		
	if (form.name.value == '') {
		alert("Please fill in your first name.");
		form.name.focus();
		form.name.select();
		return false;
	}
	if (form.last_name.value == '') {
		alert("Please fill in your last name.");
		form.last_name.focus();
		form.last_name.select();
		return false;
	}
	if (!validEmail(form.email.value)) {
		alert("A valid E-mail Address is required.");
		form.email.focus();
		form.email.select();
		return false;
	}
	if (form.comments.value == '') {
		alert("Please fill in a comment.");
		form.comments.focus();
		form.comments.select();
		return false;
	}
	
	//if we made it to here, everything's valid, so return true
	return true
	
}


