
function checkEmail (strng) {
	var error="";
	if (strng == "") {
   	error = "You must provide your email address.\n";
	}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "You must provide a valid email address.\n";
    }
    else {
	//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
       if (strng.match(illegalChars)) {
          error = "Your email address contains illegal characters.\n";
       }
    }
	return error;    
}


function checkName (strng) {
	var error = "";
	if (strng == "") {
		error = "You must provide your name.\n";
	}
	return error;
}

function checkCity (strng) {
	var error = "";
	if (strng == "") {
		error = "You must provide your city and state.\n";
	}
	return error;
}

function checkCounty (strng) {
	var error = "";
	if (strng == "") {
		error = "You must provide your county.\n";
	}
	return error;
}

function checkNotify (strng) {
	var error = "";
	if (strng == "") {
		error = "You must provide at least one recipient email address.\n";
	}
	return error;
}

function checkQuestion (strng) {
	var error = "";
	if (strng == "") {
		error = "You must provide a question or a comment.\n";
	}
	return error;
}




function checkShareForm(theform) {
	var why = "";
	why += checkEmail(theform.from_email.value);
	why += checkName(theform.from_name.value);
	why += checkNotify(theform.notify.value);
	if (why != "") {
		alert(why);
		return false;
	}
	else theform.submit();
	return true;
}

function checkQuestionForm(theform) {
	var why = "";
	why += checkEmail(theform.from_email.value);
	why += checkName(theform.from_name.value);
	why += checkCity(theform.citystate.value);
	why += checkCounty(theform.county.value);
	why += checkQuestion(theform.question.value);
	if (why != "") {
		alert(why);
		return false;
	}
	else theform.submit();
	return true;
}