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