//<![CDATA[
//REQUIRES jQuery
$(function(){
	var emailPattern = /\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i ;
	$('form').submit(function(){
		var invalid = false;
		var email = $('#email').val();
		var message = "Please correct the following:\r\n-------------------------\r\n";
		$('input', this).removeClass('error').each(function(){
			if(this.value.match(/('|=|"|&)/)){//client-side guard against SQL insertion
				invalid=true;
				$(this).addClass('error');
				message += "Special characters ['|\"|&|=] are not allowed.\r\n";
			}
		});
		$('input.required', this).each(function(){
			if(this.value == ''){
				invalid=true;
				$(this).addClass('error');
				message += $(this).attr('alt')+"\r\n";
			}
		});
		if(email && !email.match(emailPattern)){
			invalid=true;
			$('#email').addClass('error');
			message += "Check email address.\r\n";
		}
		if(invalid){
			alert(message);
			return false;
		}
	});
});
//]]>