if(jQuery)(
	function(jQuery){
		jQuery.extend(jQuery.fn,{
			formValidator: function(formSelector) {
				jQuery(formSelector).submit(function() {
					var okay = true;
					jQuery('tr.error', jQuery(this)).hide();
					jQuery(this).contents().find('.require').each(function() {
						if(jQuery(this).val() == '') {
							okay = false;
							jQuery('tr#error-empty-'+jQuery(this).attr('id')).show();
						}
					});
					
					jQuery(this).contents().find('.email').each(function() {
						if(jQuery(this).val() != '') {
							if(jQuery(this).val().match(/^[a-z0-9]+([\.\-_]*[a-z0-9]+)*@[a-z0-9]+([\.\-_]*[a-z0-9]+)*\.[a-z]{2,6}$/i) == null) {
								okay = false;
								jQuery('tr#error-email-'+jQuery(this).attr('id')).show();
							}
						}
					});
					
					jQuery(this).contents().find('.date').each(function() {
						if(jQuery(this).val() != '') {
							if(jQuery(this).val().match(/^\d{4}\-\d{1,2}\-\d{1,2}$/) == null) {
								okay = false;
								jQuery('tr#error-date-'+jQuery(this).attr('id')).show();
							}
						}
					});
					
					if(okay) {
						return true;
					} else {
						return false;
					}
				});
			}
		});
})(jQuery);
