var JFormValidator=function(){"use strict";var a,b,c,d=function(b,c,d){d=""===d||d,a[b]={enabled:d,exec:c}},e=function(a,b){var c,d=jQuery(b);return!!a&&(c=d.find("#"+a+"-lbl"),c.length?c:(c=d.find('label[for="'+a+'"]'),!!c.length&&c))},f=function(a,b){var c=b.data("label");void 0===c&&(c=e(b.attr("id"),b.get(0).form),b.data("label",c)),a===!1?(b.addClass("invalid").attr("aria-invalid","true"),c&&c.addClass("invalid")):(b.removeClass("invalid").attr("aria-invalid","false"),c&&c.removeClass("invalid"))},g=function(b){var d,e,c=jQuery(b);if(c.attr("disabled"))return f(!0,c),!0;if(c.attr("required")||c.hasClass("required"))if(d=c.prop("tagName").toLowerCase(),"fieldset"===d&&(c.hasClass("radio")||c.hasClass("checkboxes"))){if(!c.find("input:checked").length)return f(!1,c),!1}else if(!c.val()||c.hasClass("placeholder")||"checkbox"===c.attr("type")&&!c.is(":checked"))return f(!1,c),!1;return e=c.attr("class")&&c.attr("class").match(/validate-([a-zA-Z0-9\_\-]+)/)?c.attr("class").match(/validate-([a-zA-Z0-9\_\-]+)/)[1]:"",c.attr("pattern")&&""!=c.attr("pattern")?c.val().length?(h=new RegExp("^"+c.attr("pattern")+"$").test(c.val()),f(h,c),h):(f(!1,c),!1):""===e?(f(!0,c),!0):e&&"none"!==e&&a[e]&&c.val()&&a[e].exec(c.val(),c)!==!0?(f(!1,c),!1):(f(!0,c),!0)},h=function(a){var b,e,f,h,j,k,d=!0,i=[];for(b=jQuery(a).find("input, textarea, select, fieldset"),j=0,k=b.length;j<k;j++)jQuery(b[j]).hasClass("novalidate")||g(b[j])===!1&&(d=!1,i.push(b[j]));if(jQuery.each(c,function(a,b){b.exec()!==!0&&(d=!1)}),!d&&i.length>0){for(e=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),f={error:[]},j=i.length-1;j>=0;j--)h=jQuery(i[j]).data("label"),h&&f.error.push(e+h.text().replace("*",""));Joomla.renderMessages(f)}return d},i=function(a){var d,c=[],e=jQuery(a);d=e.find("input, textarea, select, fieldset, button");for(var f=0,i=d.length;f<i;f++){var j=jQuery(d[f]),k=j.prop("tagName").toLowerCase();"input"!==k&&"button"!==k||"submit"!==j.attr("type")&&"image"!==j.attr("type")?"button"===k||"input"===k&&"button"===j.attr("type")||(j.hasClass("required")&&j.attr("aria-required","true").attr("required","required"),"fieldset"!==k&&(j.on("blur",function(){return g(this)}),j.hasClass("validate-email")&&b&&d[f].setAttribute("type","email")),c.push(j)):j.hasClass("validate")&&j.on("click",function(){return h(a)})}e.data("inputfields",c)},j=function(){a={},c=c||{},b=function(){var a=document.createElement("input");return a.setAttribute("type","email"),"text"!==a.type}(),d("username",function(a,b){var c=new RegExp("[<|>|\"|'|%|;|(|)|&]","i");return!c.test(a)}),d("password",function(a,b){var c=/^\S[\S ]{2,98}\S$/;return c.test(a)}),d("numeric",function(a,b){var c=/^(\d|-)?(\d|,)*\.?\d*$/;return c.test(a)}),d("email",function(a,b){a=punycode.toASCII(a);var c=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;return c.test(a)});for(var e=jQuery("form.form-validate"),f=0,g=e.length;f<g;f++)i(e[f])};return j(),{isValid:h,validate:g,setHandler:d,attachToForm:i,custom:c}};document.formvalidator=null,jQuery(function(){document.formvalidator=new JFormValidator});