function charcount() {
	var current = document.sign.comment.value.length;
	if (500-current >= 0) { document.getElementById("charcount").innerHTML = 500-current; }
	else { document.getElementById("charcount").innerHTML = "0"; document.sign.comment.value = document.sign.comment.value.substring(0,500); }  
}
function checkfields() {
	document.sign.name.style.backgroundColor="";
	document.sign.email.style.backgroundColor="";
	document.sign.comment.style.backgroundColor="";
	document.sign.verify_word.style.backgroundColor="";
	if (document.getElementById("typein1")) { document.getElementById("typein1").style.backgroundColor=""; }
	if (document.getElementById("typein2")) { document.getElementById("typein2").style.backgroundColor=""; }
	if (document.getElementById("typein3")) { document.getElementById("typein3").style.backgroundColor=""; }

	var chars = /^[\w\s\$%\.\?(),'"!:#\-/;@]+$/;
	if (!document.sign.name.value) {
		alert("You have not entered your name.  Please try again.");
		document.sign.name.style.backgroundColor="#FFFFCC";
		document.sign.name.focus();

		return false;
	}
	if (!chars.test(document.sign.name.value)) {
		alert("Your name contains characters that are not permitted.  Please try again.");
		document.sign.name.style.backgroundColor="#FFFFCC";
		document.sign.name.focus();

		return false;
	}
	if (document.getElementById("typein1")) {
	if (document.getElementById("typein1").value) {
		if (!chars.test(document.getElementById("typein1").value)) {
			alert("Your type in question 1 contains characters that are not permitted.  Please try again.");
			document.getElementById("typein1").style.backgroundColor="#FFFFCC";
			document.getElementById("typein1").focus();

			return false;
		}
	}}
	if (document.getElementById("typein2")) {
	if (document.getElementById("typein2").value) {
		if (!chars.test(document.getElementById("typein2").value)) {
			alert("Your type in question 1 contains characters that are not permitted.  Please try again.");
			document.getElementById("typein2").style.backgroundColor="#FFFFCC";
			document.getElementById("typein2").focus();

			return false;
		}
	}}
	if (document.getElementById("typein3")) {
	if (document.getElementById("typein3").value) {
		if (!chars.test(document.getElementById("typein3").value)) {
			alert("Your type in question 1 contains characters that are not permitted.  Please try again.");
			document.getElementById("typein3").style.backgroundColor="#FFFFCC";
			document.getElementById("typein3").focus();

			return false;
		}
	}}
	var charsemail = /^[\w\s\.\-_@]+$/;
	if (!document.sign.email.value) {
		alert("You have not entered your email address.  Please try again.");
		document.sign.email.style.backgroundColor="#FFFFCC";
		document.sign.email.focus();

		return false;
	}
	if (!(document.sign.email.value.match(/@/))) {
		alert("The email address that you have entered does not appear to be valid.  Please try again.");

		document.sign.email.style.backgroundColor="#FFFFCC";
		document.sign.email.focus();

		return false;
	}
	if (!charsemail.test(document.sign.email.value)) {
		alert("Your email address contains characters that are not permitted.  Please try again.");
		document.sign.email.style.backgroundColor="#FFFFCC";
		document.sign.email.focus();

		return false;
	}
	if (document.sign.comment.value && !chars.test(document.sign.comment.value)) {
		alert("Your comment contains characters that are not permitted.  Your comment cannot contain HTML or uncommon symbols.  Please try again.");
		document.sign.comment.style.backgroundColor="#FFFFCC";
		document.sign.comment.focus();

		return false;
	}
	var charscode1 = /^[\w]+$/;
	if (!document.sign.verify_word.value) {
		alert("You have not entered the verification code.  Please try again.");
		document.sign.verify_word.style.backgroundColor="#FFFFCC";
		document.sign.verify_word.focus();

		return false;
	}

	if (!charscode1.test(document.sign.verify_word.value)) {
		alert("Your verification code contains characters that are not permitted.\n\nThe image contains letters and numbers only, with no spaces, and is not case sensitive.");
		document.sign.verify_word.style.backgroundColor="#FFFFCC";
		document.sign.verify_word.focus();

		return false;
	}
}
