$(document).ready(
	function ()
	{
		$.validator.addMethod('pname',
			function(value, element)
			{
				return this.optional(element) || 0 >= value.match(/[^-A-Za-z .\',]/);
			},
			'Invalid character.'
		);
		$.validator.addMethod("phone",
			function(value, element)
			{
			    value = value.replace(/\s+/g, ""); 
				return this.optional(element) || value.length > 9 &&
					value.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9][0-8]\d-?\d{4}$/);
			},
			'Invalid phone/fax number.'
		);
		$.validator.addMethod('zip',
			function (value, element)
			{
				return this.optional(element) || 4 < value.length && 11 > value.length && value.match(/^\d{5}(-\d{4})?$/);
			},
			'Invalid zip code.'
		);
		$.validator.addMethod('email',
			function (value, element)
			{
				return this.optional(element) || value.match(/^[A-Za-z][-A-Za-z0-9\.]+@[A-Za-z][-A-Za-z0-9\.]+\.[A-Za-z]([A-Za-z]\.[A-Za-z][A-Za-z])|([A-Za-z]{2})$/);
			},
			'Invalid e-mail address.'
		);
		$('#contact-form').validate();
	}
);
