/*
 * Useful built-in methods include: number, digits, email, url
 * See: http://docs.jquery.com/Plugins/Validation#List_of_built-in_Validation_methods
 */
jQuery.validator.addMethod("names", function(value, element) {
    return this.optional(element) || /^[a-z\-,.'\"\s]+$/i.test(value) && 
        !(/[^aeiouy'\-,.\s]{6,}/i.test(value));
}, "Names only please."); //using "name" as method name here causes problems
jQuery.validator.addMethod("address", function(value, element) {
    return this.optional(element) || /^[0-9A-Za-z\-.,'#\\\s]+$/i.test(value);
}, "Letters, numbers, and punctuation only please.");
jQuery.validator.addMethod("alphanumeric", function(value, element) {
    return this.optional(element) || /^[0-9A-Za-z\-.,'\"\s]+$/i.test(value);
}, "Letters, numbers, and punctuation only please.");
jQuery.validator.addMethod("addr1", function(value, element) {
    return this.optional(element) || /[0-9]+\s+[a-z]+|^general delivery$/i.test(value);  
}, "Please enter a valid street address.");
jQuery.validator.addMethod("zipcode", function(value, element) {
    return this.optional(element) || /^\d{5}$/i.test(value);
}, "Please enter a valid U.S. zip code.");

/*
 * Methods below copied here from distribution file "additional_methods.js"
 */

/**
 * Matches US phone number format 
 * 
 * where the area code may not start with 1 and the prefix may not start with 1 
 * allows '-' or ' ' as a separator and allows parens around area code 
 * some people may want to put a '1' in front of their number 
 * 
 * 1(212)-999-2345
 * or
 * 212 999 2344
 * or
 * 212-999-0983
 * 
 * but not
 * 111-123-5434
 * and not
 * 212 123 4567
 */
jQuery.validator.addMethod("phone", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
    return this.optional(element) || phone_number.length > 9 &&
        phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please enter a valid phone number.");
jQuery.validator.addMethod("email", function(value, element) {
    return this.optional(element) || /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value);
}, "Please enter a valid email address"); 

