(function($) {

$.validator.addMethod("xss", function(value, element) {
    if (value.length == 0)
        return true;
    
    var startIndex = 0;
    while (true) {
        var pos = value.indexOf('&', startIndex);
        if (pos < 0)
            pos = value.indexOf('<', startIndex);
        if (pos < 0)
            return true;
        if (pos == value.length - 1)
            return true;
        var ch = value.charAt(pos);
        var ch2 = value.charAt(pos + 1);
        if (ch != '&') {
            if ((ch == '<') && ((((ch2 >= 'a' && ch2 <= 'z') || (ch2 >= 'A' && ch2 <= 'Z')) || (ch2 == '!')) || (ch2 == '/')))
                return false;
        }
        else if (ch2 == '#')
            return false;
         
        startIndex = pos + 1;
    }
});

$.validator.addMethod("datePI", function(value, element) {
    return this.optional(element) || $.pi.parseDate(value) != false;
});

$.validator.addMethod("decimalPI", function(value, element) {
    return this.optional(element) ||!isNaN($.pi.parseDecimal(value));
});

$.validator.addMethod("integerPI", function(value, element) {
    return this.optional(element) ||!isNaN($.pi.parseInteger(value));
});

$.validator.addMethod("anyvalue", function(value, element) {
    return true;
});

})(jQuery);
