﻿(function (b) { b.extend(b.fn, { validate: function (c) { if (!this.length) { c && c.debug && window.console && console.warn("nothing selected, can't validate, returning nothing"); return } var d = b.data(this[0], "validator"); if (d) { return d } d = new b.validator(c, this[0]); b.data(this[0], "validator", d); if (d.settings.onsubmit) { this.find("input, button").filter(".cancel").click(function () { d.cancelSubmit = true }); if (d.settings.submitHandler) { this.find("input, button").filter(":submit").click(function () { d.submitButton = this }) } this.submit(function (e) { if (d.settings.debug) { e.preventDefault() } function f() { if (d.settings.submitHandler) { if (d.submitButton) { var g = b("<input type='hidden'/>").attr("name", d.submitButton.name).val(d.submitButton.value).appendTo(d.currentForm) } d.settings.submitHandler.call(d, d.currentForm); if (d.submitButton) { g.remove() } return false } return true } if (d.cancelSubmit) { d.cancelSubmit = false; return f() } if (d.form()) { if (d.pendingRequest) { d.formSubmitted = true; return false } return f() } else { d.focusInvalid(); return false } }) } return d }, valid: function () { if (b(this[0]).is("form")) { return this.validate().form() } else { var d = true; var c = b(this[0].form).validate(); this.each(function () { d &= c.element(this) }); return d } }, removeAttrs: function (e) { var c = {}, d = this; b.each(e.split(/\s/), function (f, g) { c[g] = d.attr(g); d.removeAttr(g) }); return c }, rules: function (f, c) { var h = this[0]; if (f) { var e = b.data(h.form, "validator").settings; var j = e.rules; var k = b.validator.staticRules(h); switch (f) { case "add": b.extend(k, b.validator.normalizeRule(c)); j[h.name] = k; if (c.messages) { e.messages[h.name] = b.extend(e.messages[h.name], c.messages) } break; case "remove": if (!c) { delete j[h.name]; return k } var i = {}; b.each(c.split(/\s/), function (l, m) { i[m] = k[m]; delete k[m] }); return i } } var g = b.validator.normalizeRules(b.extend({}, b.validator.metadataRules(h), b.validator.classRules(h), b.validator.attributeRules(h), b.validator.staticRules(h)), h); if (g.required) { var d = g.required; delete g.required; g = b.extend({ required: d }, g) } return g } }); b.extend(b.expr[":"], { blank: function (c) { return !b.trim("" + c.value) }, filled: function (c) { return !!b.trim("" + c.value) }, unchecked: function (c) { return !c.checked } }); b.validator = function (c, d) { this.settings = b.extend(true, {}, b.validator.defaults, c); this.currentForm = d; this.init() }; b.validator.format = function (c, d) { if (arguments.length == 1) { return function () { var e = b.makeArray(arguments); e.unshift(c); return b.validator.format.apply(this, e) } } if (arguments.length > 2 && d.constructor != Array) { d = b.makeArray(arguments).slice(1) } if (d.constructor != Array) { d = [d] } b.each(d, function (e, f) { c = c.replace(new RegExp("\\{" + e + "\\}", "g"), f) }); return c }; b.extend(b.validator, { defaults: { messages: {}, groups: {}, rules: {}, errorClass: "error", validClass: "valid", errorElement: "label", focusInvalid: true, errorContainer: b([]), errorLabelContainer: b([]), onsubmit: true, ignore: [], ignoreTitle: false, onfocusin: function (c) { this.lastActive = c; if (this.settings.focusCleanup && !this.blockFocusCleanup) { this.settings.unhighlight && this.settings.unhighlight.call(this, c, this.settings.errorClass, this.settings.validClass); this.errorsFor(c).hide() } }, onfocusout: function (c) { if (!this.checkable(c) && (c.name in this.submitted || !this.optional(c))) { this.element(c) } }, onkeyup: function (c) { if (c.name in this.submitted || c == this.lastElement) { this.element(c) } }, onclick: function (c) { if (c.name in this.submitted) { this.element(c) } else { if (c.parentNode.name in this.submitted) { this.element(c.parentNode) } } }, highlight: function (e, c, d) { b(e).addClass(c).removeClass(d) }, unhighlight: function (e, c, d) { b(e).removeClass(c).addClass(d) } }, setDefaults: function (c) { b.extend(b.validator.defaults, c) }, messages: { required: "This field is required.", remote: "Please fix this field.", email: "Please enter a valid email address.", url: "Please enter a valid URL.", date: "Please enter a valid date.", dateISO: "Please enter a valid date (ISO).", number: "Please enter a valid number.", digits: "Please enter only digits.", creditcard: "Please enter a valid credit card number.", equalTo: "Please enter the same value again.", accept: "Please enter a value with a valid extension.", maxlength: b.validator.format("Please enter no more than {0} characters."), minlength: b.validator.format("Please enter at least {0} characters."), rangelength: b.validator.format("Please enter a value between {0} and {1} characters long."), range: b.validator.format("Please enter a value between {0} and {1}."), max: b.validator.format("Please enter a value less than or equal to {0}."), min: b.validator.format("Please enter a value greater than or equal to {0}.") }, autoCreateRanges: false, prototype: { init: function () { this.labelContainer = b(this.settings.errorLabelContainer); this.errorContext = this.labelContainer.length && this.labelContainer || b(this.currentForm); this.containers = b(this.settings.errorContainer).add(this.settings.errorLabelContainer); this.submitted = {}; this.valueCache = {}; this.pendingRequest = 0; this.pending = {}; this.invalid = {}; this.reset(); var c = (this.groups = {}); b.each(this.settings.groups, function (f, g) { b.each(g.split(/\s/), function (i, h) { c[h] = f }) }); var e = this.settings.rules; b.each(e, function (f, g) { e[f] = b.validator.normalizeRule(g) }); function d(h) { var g = b.data(this[0].form, "validator"), f = "on" + h.type.replace(/^validate/, ""); g.settings[f] && g.settings[f].call(g, this[0]) } b(this.currentForm).validateDelegate(":text, :password, :file, select, textarea", "focusin focusout keyup", d).validateDelegate(":radio, :checkbox, select, option", "click", d); if (this.settings.invalidHandler) { b(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler) } }, form: function () { this.checkForm(); b.extend(this.submitted, this.errorMap); this.invalid = b.extend({}, this.errorMap); if (!this.valid()) { b(this.currentForm).triggerHandler("invalid-form", [this]) } this.showErrors(); return this.valid() }, checkForm: function () { this.prepareForm(); for (var c = 0, d = (this.currentElements = this.elements()); d[c]; c++) { this.check(d[c]) } return this.valid() }, element: function (d) { d = this.clean(d); this.lastElement = d; this.prepareElement(d); this.currentElements = b(d); var c = this.check(d); if (c) { delete this.invalid[d.name] } else { this.invalid[d.name] = true } if (!this.numberOfInvalids()) { this.toHide = this.toHide.add(this.containers) } this.showErrors(); return c }, showErrors: function (d) { if (d) { b.extend(this.errorMap, d); this.errorList = []; for (var c in d) { this.errorList.push({ message: d[c], element: this.findByName(c)[0] }) } this.successList = b.grep(this.successList, function (e) { return !(e.name in d) }) } this.settings.showErrors ? this.settings.showErrors.call(this, this.errorMap, this.errorList) : this.defaultShowErrors() }, resetForm: function () { if (b.fn.resetForm) { b(this.currentForm).resetForm() } this.submitted = {}; this.prepareForm(); this.hideErrors(); this.elements().removeClass(this.settings.errorClass) }, numberOfInvalids: function () { return this.objectLength(this.invalid) }, objectLength: function (e) { var d = 0; for (var c in e) { d++ } return d }, hideErrors: function () { this.addWrapper(this.toHide).hide() }, valid: function () { return this.size() == 0 }, size: function () { return this.errorList.length }, focusInvalid: function () { if (this.settings.focusInvalid) { try { b(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus().trigger("focusin") } catch (c) { } } }, findLastActive: function () { var c = this.lastActive; return c && b.grep(this.errorList, function (d) { return d.element.name == c.name }).length == 1 && c }, elements: function () { var d = this, c = {}; return b([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function () { !this.name && d.settings.debug && window.console && console.error("%o has no name assigned", this); if (this.name in c || !d.objectLength(b(this).rules())) { return false } c[this.name] = true; return true }) }, clean: function (c) { return b(c)[0] }, errors: function () { return b(this.settings.errorElement + "." + this.settings.errorClass, this.errorContext) }, reset: function () { this.successList = []; this.errorList = []; this.errorMap = {}; this.toShow = b([]); this.toHide = b([]); this.currentElements = b([]) }, prepareForm: function () { this.reset(); this.toHide = this.errors().add(this.containers) }, prepareElement: function (c) { this.reset(); this.toHide = this.errorsFor(c) }, check: function (d) { d = this.clean(d); if (this.checkable(d)) { d = this.findByName(d.name)[0] } var i = b(d).rules(); var f = false; for (method in i) { var h = { method: method, parameters: i[method] }; try { var c = b.validator.methods[method].call(this, d.value.replace(/\r/g, ""), d, h.parameters); if (c == "dependency-mismatch") { f = true; continue } f = false; if (c == "pending") { this.toHide = this.toHide.not(this.errorsFor(d)); return } if (!c) { this.formatAndAdd(d, h); return false } } catch (g) { this.settings.debug && window.console && console.log("exception occured when checking element " + d.id + ", check the '" + h.method + "' method", g); throw g } } if (f) { return } if (this.objectLength(i)) { this.successList.push(d) } return true }, customMetaMessage: function (c, e) { if (!b.metadata) { return } var d = this.settings.meta ? b(c).metadata()[this.settings.meta] : b(c).metadata(); return d && d.messages && d.messages[e] }, customMessage: function (d, e) { var c = this.settings.messages[d]; return c && (c.constructor == String ? c : c[e]) }, findDefined: function () { for (var c = 0; c < arguments.length; c++) { if (arguments[c] !== undefined) { return arguments[c] } } return undefined }, defaultMessage: function (c, d) { return this.findDefined(this.customMessage(c.name, d), this.customMetaMessage(c, d), !this.settings.ignoreTitle && c.title || undefined, b.validator.messages[d], "<strong>Warning: No message defined for " + c.name + "</strong>") }, formatAndAdd: function (d, f) { var e = this.defaultMessage(d, f.method), c = /\$?\{(\d+)\}/g; if (typeof e == "function") { e = e.call(this, f.parameters, d) } else { if (c.test(e)) { e = jQuery.format(e.replace(c, "{$1}"), f.parameters) } } this.errorList.push({ message: e, element: d }); this.errorMap[d.name] = e; this.submitted[d.name] = e }, addWrapper: function (c) { if (this.settings.wrapper) { c = c.add(c.parent(this.settings.wrapper)) } return c }, defaultShowErrors: function () { for (var d = 0; this.errorList[d]; d++) { var c = this.errorList[d]; this.settings.highlight && this.settings.highlight.call(this, c.element, this.settings.errorClass, this.settings.validClass); this.showLabel(c.element, c.message) } if (this.errorList.length) { this.toShow = this.toShow.add(this.containers) } if (this.settings.success) { for (var d = 0; this.successList[d]; d++) { this.showLabel(this.successList[d]) } } if (this.settings.unhighlight) { for (var d = 0, e = this.validElements(); e[d]; d++) { this.settings.unhighlight.call(this, e[d], this.settings.errorClass, this.settings.validClass) } } this.toHide = this.toHide.not(this.toShow); this.hideErrors(); this.addWrapper(this.toShow).show() }, validElements: function () { return this.currentElements.not(this.invalidElements()) }, invalidElements: function () { return b(this.errorList).map(function () { return this.element }) }, showLabel: function (d, e) { var c = this.errorsFor(d); if (c.length) { c.removeClass().addClass(this.settings.errorClass); c.attr("generated") && c.html(e) } else { c = b("<" + this.settings.errorElement + "/>").attr({ "for": this.idOrName(d), generated: true }).addClass(this.settings.errorClass).html(e || ""); if (this.settings.wrapper) { c = c.hide().show().wrap("<" + this.settings.wrapper + "/>").parent() } if (!this.labelContainer.append(c).length) { this.settings.errorPlacement ? this.settings.errorPlacement(c, b(d)) : c.insertAfter(d) } } if (!e && this.settings.success) { c.text(""); typeof this.settings.success == "string" ? c.addClass(this.settings.success) : this.settings.success(c) } this.toShow = this.toShow.add(c) }, errorsFor: function (d) { var c = this.idOrName(d); return this.errors().filter(function () { return b(this).attr("for") == c }) }, idOrName: function (c) { return this.groups[c.name] || (this.checkable(c) ? c.name : c.id || c.name) }, checkable: function (c) { return /radio|checkbox/i.test(c.type) }, findByName: function (c) { var d = this.currentForm; return b(document.getElementsByName(c)).map(function (e, f) { return f.form == d && f.name == c && f || null }) }, getLength: function (d, c) { switch (c.nodeName.toLowerCase()) { case "select": return b("option:selected", c).length; case "input": if (this.checkable(c)) { return this.findByName(c.name).filter(":checked").length } } return d.length }, depend: function (d, c) { return this.dependTypes[typeof d] ? this.dependTypes[typeof d](d, c) : true }, dependTypes: { "boolean": function (d, c) { return d }, string: function (d, c) { return !!b(d, c.form).length }, "function": function (d, c) { return d(c) } }, optional: function (c) { return !b.validator.methods.required.call(this, b.trim(c.value), c) && "dependency-mismatch" }, startRequest: function (c) { if (!this.pending[c.name]) { this.pendingRequest++; this.pending[c.name] = true } }, stopRequest: function (c, d) { this.pendingRequest--; if (this.pendingRequest < 0) { this.pendingRequest = 0 } delete this.pending[c.name]; if (d && this.pendingRequest == 0 && this.formSubmitted && this.form()) { b(this.currentForm).submit(); this.formSubmitted = false } else { if (!d && this.pendingRequest == 0 && this.formSubmitted) { b(this.currentForm).triggerHandler("invalid-form", [this]); this.formSubmitted = false } } }, previousValue: function (c) { return b.data(c, "previousValue") || b.data(c, "previousValue", { old: null, valid: true, message: this.defaultMessage(c, "remote") }) } }, classRuleSettings: { required: { required: true }, email: { email: true }, url: { url: true }, date: { date: true }, dateISO: { dateISO: true }, dateDE: { dateDE: true }, number: { number: true }, numberDE: { numberDE: true }, digits: { digits: true }, creditcard: { creditcard: true} }, addClassRules: function (c, d) { c.constructor == String ? this.classRuleSettings[c] = d : b.extend(this.classRuleSettings, c) }, classRules: function (d) { var e = {}; var c = b(d).attr("class"); c && b.each(c.split(" "), function () { if (this in b.validator.classRuleSettings) { b.extend(e, b.validator.classRuleSettings[this]) } }); return e }, attributeRules: function (d) { var f = {}; var c = b(d); for (method in b.validator.methods) { var e = c.attr(method); if (e) { f[method] = e } } if (f.maxlength && /-1|2147483647|524288/.test(f.maxlength)) { delete f.maxlength } return f }, metadataRules: function (c) { if (!b.metadata) { return {} } var d = b.data(c.form, "validator").settings.meta; return d ? b(c).metadata()[d] : b(c).metadata() }, staticRules: function (d) { var e = {}; var c = b.data(d.form, "validator"); if (c.settings.rules) { e = b.validator.normalizeRule(c.settings.rules[d.name]) || {} } return e }, normalizeRules: function (d, c) { b.each(d, function (g, f) { if (f === false) { delete d[g]; return } if (f.param || f.depends) { var e = true; switch (typeof f.depends) { case "string": e = !!b(f.depends, c.form).length; break; case "function": e = f.depends.call(c, c); break } if (e) { d[g] = f.param !== undefined ? f.param : true } else { delete d[g] } } }); b.each(d, function (e, f) { d[e] = b.isFunction(f) ? f(c) : f }); b.each(["minlength", "maxlength", "min", "max"], function () { if (d[this]) { d[this] = Number(d[this]) } }); b.each(["rangelength", "range"], function () { if (d[this]) { d[this] = [Number(d[this][0]), Number(d[this][1])] } }); if (b.validator.autoCreateRanges) { if (d.min && d.max) { d.range = [d.min, d.max]; delete d.min; delete d.max } if (d.minlength && d.maxlength) { d.rangelength = [d.minlength, d.maxlength]; delete d.minlength; delete d.maxlength } } if (d.messages) { delete d.messages } return d }, normalizeRule: function (d) { if (typeof d == "string") { var c = {}; b.each(d.split(/\s/), function () { c[this] = true }); d = c } return d }, addMethod: function (c, e, d) { b.validator.methods[c] = e; b.validator.messages[c] = d != undefined ? d : b.validator.messages[c]; if (e.length < 3) { b.validator.addClassRules(c, b.validator.normalizeRule(c)) } }, methods: { required: function (d, c, f) { if (!this.depend(f, c)) { return "dependency-mismatch" } switch (c.nodeName.toLowerCase()) { case "select": var e = b(c).val(); return e && e.length > 0; case "input": if (this.checkable(c)) { return this.getLength(d, c) > 0 } default: return b.trim(d).length > 0 } }, remote: function (g, d, h) { if (this.optional(d)) { return "dependency-mismatch" } var e = this.previousValue(d); if (!this.settings.messages[d.name]) { this.settings.messages[d.name] = {} } e.originalMessage = this.settings.messages[d.name].remote; this.settings.messages[d.name].remote = e.message; h = typeof h == "string" && { url: h} || h; if (e.old !== g) { e.old = g; var c = this; this.startRequest(d); var f = {}; f[d.name] = g; b.ajax(b.extend(true, { url: h, mode: "abort", port: "validate" + d.name, dataType: "json", data: f, success: function (j) { c.settings.messages[d.name].remote = e.originalMessage; var l = j === true; if (l) { var i = c.formSubmitted; c.prepareElement(d); c.formSubmitted = i; c.successList.push(d); c.showErrors() } else { var m = {}; var k = (e.message = j || c.defaultMessage(d, "remote")); m[d.name] = b.isFunction(k) ? k(g) : k; c.showErrors(m) } e.valid = l; c.stopRequest(d, l) } }, h)); return "pending" } else { if (this.pending[d.name]) { return "pending" } } return e.valid }, minlength: function (d, c, e) { return this.optional(c) || this.getLength(b.trim(d), c) >= e }, maxlength: function (d, c, e) { return this.optional(c) || this.getLength(b.trim(d), c) <= e }, rangelength: function (e, c, f) { var d = this.getLength(b.trim(e), c); return this.optional(c) || (d >= f[0] && d <= f[1]) }, min: function (d, c, e) { return this.optional(c) || d >= e }, max: function (d, c, e) { return this.optional(c) || d <= e }, range: function (d, c, e) { return this.optional(c) || (d >= e[0] && d <= e[1]) }, email: function (d, c) { return this.optional(c) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(d) }, url: function (d, c) { return this.optional(c) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(d) }, date: function (d, c) { return this.optional(c) || !/Invalid|NaN/.test(new Date(d)) }, dateISO: function (d, c) { return this.optional(c) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(d) }, number: function (d, c) { return this.optional(c) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(d) }, digits: function (d, c) { return this.optional(c) || /^\d+$/.test(d) }, creditcard: function (g, d) { if (this.optional(d)) { return "dependency-mismatch" } if (/[^0-9-]+/.test(g)) { return false } var h = 0, f = 0, c = false; g = g.replace(/\D/g, ""); for (var i = g.length - 1; i >= 0; i--) { var e = g.charAt(i); var f = parseInt(e, 10); if (c) { if ((f *= 2) > 9) { f -= 9 } } h += f; c = !c } return (h % 10) == 0 }, accept: function (d, c, e) { e = typeof e == "string" ? e.replace(/,/g, "|") : "png|jpe?g|gif"; return this.optional(c) || d.match(new RegExp(".(" + e + ")$", "i")) }, equalTo: function (d, c, f) { var e = b(f).unbind(".validate-equalTo").bind("blur.validate-equalTo", function () { b(c).valid() }); return d == e.val() } } }); b.format = b.validator.format })(jQuery); (function (d) { var c = d.ajax; var b = {}; d.ajax = function (f) { f = d.extend(f, d.extend({}, d.ajaxSettings, f)); var e = f.port; if (f.mode == "abort") { if (b[e]) { b[e].abort() } return (b[e] = c.apply(this, arguments)) } return c.apply(this, arguments) } })(jQuery); (function (b) { if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) { b.each({ focus: "focusin", blur: "focusout" }, function (d, c) { b.event.special[c] = { setup: function () { this.addEventListener(d, e, true) }, teardown: function () { this.removeEventListener(d, e, true) }, handler: function (f) { arguments[0] = b.event.fix(f); arguments[0].type = c; return b.event.handle.apply(this, arguments) } }; function e(f) { f = b.event.fix(f); f.type = c; return b.event.handle.call(this, f) } }) } b.extend(b.fn, { validateDelegate: function (e, d, c) { return this.bind(d, function (f) { var g = b(f.target); if (g.is(e)) { return c.apply(g, arguments) } }) } }) })(jQuery); (function (c) { c.fn.superfish = function (k) { var g = c.fn.superfish, j = g.c, f = c(['<span class="', j.arrowClass, '"> &#187;</span>'].join("")), i = function () { var l = c(this), m = d(l); clearTimeout(m.sfTimer); l.showSuperfishUl().siblings().hideSuperfishUl() }, e = function () { var l = c(this), n = d(l), m = g.op; clearTimeout(n.sfTimer); n.sfTimer = setTimeout(function () { m.retainPath = (c.inArray(l[0], m.$path) > -1); l.hideSuperfishUl(); if (m.$path.length && l.parents(["li.", m.hoverClass].join("")).length < 1) { i.call(m.$path) } }, m.delay) }, d = function (l) { var m = l.parents(["ul.", j.menuClass, ":first"].join(""))[0]; g.op = g.o[m.serial]; return m }, h = function (l) { l.addClass(j.anchorClass).append(f.clone()) }; return this.each(function () { var l = this.serial = g.o.length; var n = c.extend({}, g.defaults, k); n.$path = c("li." + n.pathClass, this).slice(0, n.pathLevels).each(function () { c(this).addClass([n.hoverClass, j.bcClass].join(" ")).filter("li:has(ul)").removeClass(n.pathClass) }); g.o[l] = g.op = n; c("li:has(ul)", this)[(c.fn.hoverIntent && !n.disableHI) ? "hoverIntent" : "hover"](i, e).each(function () { if (n.autoArrows) { h(c(">a:first-child", this)) } }).not("." + j.bcClass).hideSuperfishUl(); var m = c("a", this); m.each(function (o) { var p = m.eq(o).parents("li"); m.eq(o).focus(function () { i.call(p) }).blur(function () { e.call(p) }) }); n.onInit.call(this) }).each(function () { var l = [j.menuClass]; if (g.op.dropShadows && !(c.browser.msie && c.browser.version < 7)) { l.push(j.shadowClass) } c(this).addClass(l.join(" ")) }) }; var b = c.fn.superfish; b.o = []; b.op = {}; b.IE7fix = function () { var d = b.op; if (c.browser.msie && c.browser.version > 6 && d.dropShadows && d.animation.opacity != undefined) { this.toggleClass(b.c.shadowClass + "-off") } }; b.c = { bcClass: "sf-breadcrumb", menuClass: "sf-js-enabled", anchorClass: "sf-with-ul", arrowClass: "sf-sub-indicator", shadowClass: "sf-shadow" }; b.defaults = { hoverClass: "sfHover", pathClass: "overideThisToUse", pathLevels: 1, delay: 800, animation: { opacity: "show" }, speed: "normal", autoArrows: true, dropShadows: true, disableHI: false, onInit: function () { }, onBeforeShow: function () { }, onShow: function () { }, onHide: function () { } }; c.fn.extend({ hideSuperfishUl: function () { var f = b.op, e = (f.retainPath === true) ? f.$path : ""; f.retainPath = false; var d = c(["li.", f.hoverClass].join(""), this).add(this).not(e).removeClass(f.hoverClass).find(">ul").hide().css("visibility", "hidden"); f.onHide.call(d); return this }, showSuperfishUl: function () { var f = b.op, e = b.c.shadowClass + "-off", d = this.addClass(f.hoverClass).find(">ul:hidden").css("visibility", "visible"); b.IE7fix.call(d); f.onBeforeShow.call(d); d.animate(f.animation, f.speed, function () { b.IE7fix.call(d); f.onShow.call(d) }); return this } }) })(jQuery); (function ($) { $(document).ready(function () { $(".cloud-zoom, .cloud-zoom-gallery").CloudZoom() }); function format(str) { for (var i = 1; i < arguments.length; i++) { str = str.replace("%" + (i - 1), arguments[i]) } return str } function CloudZoom(jWin, opts) { var sImg = $("img", jWin); var img1; var img2; var zoomDiv = null; var $mouseTrap = null; var lens = null; var $tint = null; var softFocus = null; var $ie6Fix = null; var zoomImage; var controlTimer = 0; var cw, ch; var destU = 0; var destV = 0; var currV = 0; var currU = 0; var filesLoaded = 0; var mx, my; var ctx = this, zw; setTimeout(function () { if ($mouseTrap === null) { var w = jWin.width(); jWin.parent().append(format('<div style="width:%0px;position:absolute;top:75%;left:%1px;text-align:center" class="cloud-zoom-loading" >Loading...</div>', w / 3, (w / 2) - (w / 6))).find(":last").css("opacity", 0.5) } }, 200); var ie6FixRemove = function () { if ($ie6Fix !== null) { $ie6Fix.remove(); $ie6Fix = null } }; this.removeBits = function () { if (lens) { lens.remove(); lens = null } if ($tint) { $tint.remove(); $tint = null } if (softFocus) { softFocus.remove(); softFocus = null } ie6FixRemove(); $(".cloud-zoom-loading", jWin.parent()).remove() }; this.destroy = function () { jWin.data("zoom", null); if ($mouseTrap) { $mouseTrap.unbind(); $mouseTrap.remove(); $mouseTrap = null } if (zoomDiv) { zoomDiv.remove(); zoomDiv = null } this.removeBits() }; this.fadedOut = function () { if (zoomDiv) { zoomDiv.remove(); zoomDiv = null } this.removeBits() }; this.controlLoop = function () { if (lens) { var x = (mx - sImg.offset().left - (cw * 0.5)) >> 0; var y = (my - sImg.offset().top - (ch * 0.5)) >> 0; if (x < 0) { x = 0 } else { if (x > (sImg.outerWidth() - cw)) { x = (sImg.outerWidth() - cw) } } if (y < 0) { y = 0 } else { if (y > (sImg.outerHeight() - ch)) { y = (sImg.outerHeight() - ch) } } lens.css({ left: x, top: y }); lens.css("background-position", (-x) + "px " + (-y) + "px"); destU = (((x) / sImg.outerWidth()) * zoomImage.width) >> 0; destV = (((y) / sImg.outerHeight()) * zoomImage.height) >> 0; currU += (destU - currU) / opts.smoothMove; currV += (destV - currV) / opts.smoothMove; zoomDiv.css("background-position", (-(currU >> 0) + "px ") + (-(currV >> 0) + "px")) } controlTimer = setTimeout(function () { ctx.controlLoop() }, 30) }; this.init2 = function (img, id) { filesLoaded++; if (id === 1) { zoomImage = img } if (filesLoaded === 2) { this.init() } }; this.init = function () { $(".cloud-zoom-loading", jWin.parent()).remove(); $mouseTrap = jWin.parent().append(format("<div class='mousetrap' style='background-image:url(\".\");z-index:999;position:absolute;width:%0px;height:%1px;left:%2px;top:%3px;'></div>", sImg.outerWidth(), sImg.outerHeight(), 0, 0)).find(":last"); $mouseTrap.bind("mousemove", this, function (event) { mx = event.pageX; my = event.pageY }); $mouseTrap.bind("mouseleave", this, function (event) { clearTimeout(controlTimer); if (lens) { lens.fadeOut(299) } if ($tint) { $tint.fadeOut(299) } if (softFocus) { softFocus.fadeOut(299) } zoomDiv.fadeOut(300, function () { ctx.fadedOut() }); return false }); $mouseTrap.bind("mouseenter", this, function (event) { mx = event.pageX; my = event.pageY; zw = event.data; if (zoomDiv) { zoomDiv.stop(true, false); zoomDiv.remove() } var xPos = opts.adjustX, yPos = opts.adjustY; var siw = sImg.outerWidth(); var sih = sImg.outerHeight(); var w = opts.zoomWidth; var h = opts.zoomHeight; if (opts.zoomWidth == "auto") { w = siw } if (opts.zoomHeight == "auto") { h = sih } var appendTo = jWin.parent(); switch (opts.position) { case "top": yPos -= h; break; case "right": xPos += siw; break; case "bottom": yPos += sih; break; case "left": xPos -= w; break; case "inside": w = siw; h = sih; break; default: appendTo = $("#" + opts.position); if (!appendTo.length) { appendTo = jWin; xPos += siw; yPos += sih } else { w = appendTo.innerWidth(); h = appendTo.innerHeight() } } zoomDiv = appendTo.append(format('<div id="cloud-zoom-big" class="cloud-zoom-big" style="display:none;position:absolute;left:%0px;top:%1px;width:%2px;height:%3px;background-image:url(\'%4\');z-index:99;"></div>', xPos, yPos, w, h, zoomImage.src)).find(":last"); if (sImg.attr("title") && opts.showTitle) { zoomDiv.append(format('<div class="cloud-zoom-title">%0</div>', sImg.attr("title"))).find(":last").css("opacity", opts.titleOpacity) } if ($.browser.msie && $.browser.version < 7) { $ie6Fix = $('<iframe frameborder="0" src="#"></iframe>').css({ position: "absolute", left: xPos, top: yPos, zIndex: 99, width: w, height: h }).insertBefore(zoomDiv) } zoomDiv.fadeIn(500); if (lens) { lens.remove(); lens = null } cw = (sImg.outerWidth() / zoomImage.width) * zoomDiv.width(); ch = (sImg.outerHeight() / zoomImage.height) * zoomDiv.height(); lens = jWin.append(format("<div class = 'cloud-zoom-lens' style='display:none;z-index:98;position:absolute;width:%0px;height:%1px;'></div>", cw, ch)).find(":last"); $mouseTrap.css("cursor", lens.css("cursor")); var noTrans = false; if (opts.tint) { lens.css("background", 'url("' + sImg.attr("src") + '")'); $tint = jWin.append(format('<div style="display:none;position:absolute; left:0px; top:0px; width:%0px; height:%1px; background-color:%2;" />', sImg.outerWidth(), sImg.outerHeight(), opts.tint)).find(":last"); $tint.css("opacity", opts.tintOpacity); noTrans = true; $tint.fadeIn(500) } if (opts.softFocus) { lens.css("background", 'url("' + sImg.attr("src") + '")'); softFocus = jWin.append(format('<div style="position:absolute;display:none;top:2px; left:2px; width:%0px; height:%1px;" />', sImg.outerWidth() - 2, sImg.outerHeight() - 2, opts.tint)).find(":last"); softFocus.css("background", 'url("' + sImg.attr("src") + '")'); softFocus.css("opacity", 0.5); noTrans = true; softFocus.fadeIn(500) } if (!noTrans) { lens.css("opacity", opts.lensOpacity) } if (opts.position !== "inside") { lens.fadeIn(500) } zw.controlLoop(); return }) }; img1 = new Image(); $(img1).load(function () { ctx.init2(this, 0) }); img1.src = sImg.attr("src"); img2 = new Image(); $(img2).load(function () { ctx.init2(this, 1) }); img2.src = jWin.attr("href") } $.fn.CloudZoom = function (options) { try { document.execCommand("BackgroundImageCache", false, true) } catch (e) { } this.each(function () { var relOpts, opts; eval("var	a = {" + $(this).attr("rel") + "}"); relOpts = a; if ($(this).is(".cloud-zoom")) { $(this).css({ position: "relative", display: "block" }); $("img", $(this)).css({ display: "block" }); if ($(this).parent().attr("id") != "wrap") { $(this).wrap('<div id="wrap" style="top:0px;z-index:990;position:relative;"></div>') } opts = $.extend({}, $.fn.CloudZoom.defaults, options); opts = $.extend({}, opts, relOpts); $(this).data("zoom", new CloudZoom($(this), opts)) } else { if ($(this).is(".cloud-zoom-gallery")) { opts = $.extend({}, relOpts, options); $(this).data("relOpts", opts); $(this).bind("click", $(this), function (event) { var data = event.data.data("relOpts"); $("#" + data.useZoom).data("zoom").destroy(); $("#" + data.useZoom).attr("href", event.data.attr("href")); $("#" + data.useZoom + " img").attr("src", event.data.data("relOpts").smallImage); $("#" + event.data.data("relOpts").useZoom).CloudZoom(); return false }) } } }); return this }; $.fn.CloudZoom.defaults = { zoomWidth: "auto", zoomHeight: "auto", position: "right", tint: false, tintOpacity: 0.5, lensOpacity: 0.5, softFocus: false, smoothMove: 3, showTitle: true, titleOpacity: 0.5, adjustX: 0, adjustY: 0} })(jQuery); (function (b) { b.fn.hoverIntent = function (l, k) { var m = { sensitivity: 7, interval: 100, timeout: 0 }; m = b.extend(m, k ? { over: l, out: k} : l); var o, n, i, e; var h = function (f) { o = f.pageX; n = f.pageY }; var d = function (g, f) { f.hoverIntent_t = clearTimeout(f.hoverIntent_t); if ((Math.abs(i - o) + Math.abs(e - n)) < m.sensitivity) { b(f).unbind("mousemove", h); f.hoverIntent_s = 1; return m.over.apply(f, [g]) } else { i = o; e = n; f.hoverIntent_t = setTimeout(function () { d(g, f) }, m.interval) } }; var j = function (g, f) { f.hoverIntent_t = clearTimeout(f.hoverIntent_t); f.hoverIntent_s = 0; return m.out.apply(f, [g]) }; var c = function (r) { var q = (r.type == "mouseover" ? r.fromElement : r.toElement) || r.relatedTarget; while (q && q != this) { try { q = q.parentNode } catch (r) { q = this } } if (q == this) { return false } var g = jQuery.extend({}, r); var f = this; if (f.hoverIntent_t) { f.hoverIntent_t = clearTimeout(f.hoverIntent_t) } if (r.type == "mouseover") { i = g.pageX; e = g.pageY; b(f).bind("mousemove", h); if (f.hoverIntent_s != 1) { f.hoverIntent_t = setTimeout(function () { d(g, f) }, m.interval) } } else { b(f).unbind("mousemove", h); if (f.hoverIntent_s == 1) { f.hoverIntent_t = setTimeout(function () { j(g, f) }, m.timeout) } } }; return this.mouseover(c).mouseout(c) } })(jQuery); (function (d) { var b = (d.browser.msie ? "paste" : "input") + ".mask"; var c = (window.orientation != undefined); d.mask = { definitions: { "9": "[0-9]", a: "[A-Za-z]", "*": "[A-Za-z0-9]"} }; d.fn.extend({ caret: function (g, e) { if (this.length == 0) { return } if (typeof g == "number") { e = (typeof e == "number") ? e : g; return this.each(function () { if (this.setSelectionRange) { this.focus(); this.setSelectionRange(g, e) } else { if (this.createTextRange) { var h = this.createTextRange(); h.collapse(true); h.moveEnd("character", e); h.moveStart("character", g); h.select() } } }) } else { if (this[0].setSelectionRange) { g = this[0].selectionStart; e = this[0].selectionEnd } else { if (document.selection && document.selection.createRange) { var f = document.selection.createRange(); g = 0 - f.duplicate().moveStart("character", -100000); e = g + f.text.length } } return { begin: g, end: e} } }, unmask: function () { return this.trigger("unmask") }, mask: function (g, k) { if (!g && this.length > 0) { var h = d(this[0]); var j = h.data("tests"); return d.map(h.data("buffer"), function (n, m) { return j[m] ? n : null }).join("") } k = d.extend({ placeholder: "_", completed: null }, k); var f = d.mask.definitions; var j = []; var l = g.length; var i = null; var e = g.length; d.each(g.split(""), function (m, n) { if (n == "?") { e--; l = m } else { if (f[n]) { j.push(new RegExp(f[n])); if (i == null) { i = j.length - 1 } } else { j.push(null) } } }); return this.each(function () { var v = d(this); var q = d.map(g.split(""), function (z, y) { if (z != "?") { return f[z] ? k.placeholder : z } }); var t = false; var x = v.val(); v.data("buffer", q).data("tests", j); function u(y) { while (++y <= e && !j[y]) { } return y } function p(A) { while (!j[A] && --A >= 0) { } for (var z = A; z < e; z++) { if (j[z]) { q[z] = k.placeholder; var y = u(z); if (y < e && j[z].test(q[y])) { q[z] = q[y] } else { break } } } s(); v.caret(Math.max(i, A)) } function m(C) { for (var A = C, B = k.placeholder; A < e; A++) { if (j[A]) { var y = u(A); var z = q[A]; q[A] = B; if (y < e && j[y].test(z)) { B = z } else { break } } } } function r(z) { var A = d(this).caret(); var y = z.keyCode; t = (y < 16 || (y > 16 && y < 32) || (y > 32 && y < 41)); if ((A.begin - A.end) != 0 && (!t || y == 8 || y == 46)) { n(A.begin, A.end) } if (y == 8 || y == 46 || (c && y == 127)) { p(A.begin + (y == 46 ? 0 : -1)); return false } else { if (y == 27) { v.val(x); v.caret(0, o()); return false } } } function w(B) { if (t) { t = false; return (B.keyCode == 8) ? false : null } B = B || window.event; var y = B.charCode || B.keyCode || B.which; var D = d(this).caret(); if (B.ctrlKey || B.altKey || B.metaKey) { return true } else { if ((y >= 32 && y <= 125) || y > 186) { var A = u(D.begin - 1); if (A < e) { var C = String.fromCharCode(y); if (j[A].test(C)) { m(A); q[A] = C; s(); var z = u(A); d(this).caret(z); if (k.completed && z == e) { k.completed.call(v) } } } } } return false } function n(A, y) { for (var z = A; z < y && z < e; z++) { if (j[z]) { q[z] = k.placeholder } } } function s() { return v.val(q.join("")).val() } function o(z) { var D = v.val(); var C = -1; for (var y = 0, B = 0; y < e; y++) { if (j[y]) { q[y] = k.placeholder; while (B++ < D.length) { var A = D.charAt(B - 1); if (j[y].test(A)) { q[y] = A; C = y; break } } if (B > D.length) { break } } else { if (q[y] == D[B] && y != l) { B++; C = y } } } if (!z && C + 1 < l) { v.val(""); n(0, e) } else { if (z || C + 1 >= l) { s(); if (!z) { v.val(v.val().substring(0, C + 1)) } } } return (l ? y : i) } if (!v.attr("readonly")) { v.one("unmask", function () { v.unbind(".mask").removeData("buffer").removeData("tests") }).bind("focus.mask", function () { x = v.val(); var y = o(); s(); setTimeout(function () { if (y == g.length) { v.caret(0, y) } else { v.caret(y) } }, 0) }).bind("blur.mask", function () { o(); if (v.val() != x) { v.change() } }).bind("keydown.mask", r).bind("keypress.mask", w).bind(b, function () { setTimeout(function () { v.caret(o(true)) }, 0) }) } o() }) } }) })(jQuery);
