/* jquery anti-span keypress function */

$(document).ready(function(){
	$('INPUT,TEXTAREA').keypress(function(){
		this.form.elements.pv.value='verified';
	});
});

/* validate newsletter sign up form */

function fnValidateNewsletter(f) {
	if (!IsValidEmail(f.email_address.value)) {
		alert('Please enter a valid email address to continue.');
		f.email_address.focus();
		return false;
	}
	return true;
}

/* validate contact form */

function fnValidateContact(f) {
	if (f.name.value.length < 1) {
		alert('Please enter your name to continue.');
		f.name.focus();
		return false;
	}
	/*
	if (f.phone.value.length < 10 || !isNumeric(f.phone.value)) {
		alert('Please enter your phone number to continue.');
		f.phone.focus();
		return false;
	}
	*/
	if (!IsValidEmail(f.email.value)) {
		alert('Please enter a valid email address to continue.');
		f.email.focus();
		return false;
	}
	return true;
}

function isNumeric(val) {
	var ValidChars = "0123456789.-()";
	for (i=0; i<val.length; i++) if (ValidChars.indexOf(val.charAt(i)) == -1) return false;
	return true;
}

function IsValidEmail(val) {
	var iLen = val.length;
	if 	(iLen < 6 || val.indexOf('@') < 1 || (val.charAt(iLen - 3) != '.' && val.charAt(iLen - 4) != '.' && val.charAt(iLen - 5) != '.')) return false;
	return true;
}
