var JFormValidator=new Class({initialize:function(){this.handlers={};this.custom={};this.setHandler("username",function(a){regex=/[<|>|"|'|%|;|(|)|&]/i;return!regex.test(a)});this.setHandler("password",function(a){regex=/^\S[\S ]{2,98}\S$/;return regex.test(a)});this.setHandler("numeric",function(a){regex=/^(\d|-)?(\d|,)*\.?\d*$/;return regex.test(a)});this.setHandler("email",function(a){regex=/^[a-zA-Z0-9._-]+(\+[a-zA-Z0-9._-]+)*@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;return regex.test(a)});$$("form.form-validate").each(function(a){this.attachToForm(a)},
this)},setHandler:function(a,b,c){this.handlers[a]={enabled:c==""?true:c,exec:b}},attachToForm:function(a){a.getElements("input,textarea,select,button").each(function(b){if((document.id(b).get("tag")=="input"||document.id(b).get("tag")=="button")&&document.id(b).get("type")=="submit"){if(b.hasClass("validate"))b.onclick=function(){return document.formvalidator.isValid(this.form)}}else b.addEvent("blur",function(){return document.formvalidator.validate(this)})})},validate:function(a){a=document.id(a);
if(a.get("disabled")){this.handleResponse(true,a);return true}if(a.hasClass("required"))if(a.get("tag")=="fieldset"&&(a.hasClass("radio")||a.hasClass("checkboxes")))for(var b=0;;b++)if(document.id(a.get("id")+b)){if(document.id(a.get("id")+b).checked)break}else{this.handleResponse(false,a);return false}else if(!a.get("value")){this.handleResponse(false,a);return false}b=a.className&&a.className.search(/validate-([a-zA-Z0-9\_\-]+)/)!=-1?a.className.match(/validate-([a-zA-Z0-9\_\-]+)/)[1]:"";if(b==
""){this.handleResponse(true,a);return true}if(b&&b!="none"&&this.handlers[b]&&a.get("value"))if(this.handlers[b].exec(a.get("value"))!=true){this.handleResponse(false,a);return false}this.handleResponse(true,a);return true},isValid:function(a){var b=true;a=a.getElements("fieldset").concat(Array.from(a.elements));for(var c=0;c<a.length;c++)if(this.validate(a[c])==false)b=false;(new Hash(this.custom)).each(function(d){if(d.exec()!=true)b=false});return b},handleResponse:function(a,b){b.labelref||$$("label").each(function(c){if(c.get("for")==
b.get("id"))b.labelref=c});if(a==false){b.addClass("invalid");b.set("aria-invalid","true");if(b.labelref){document.id(b.labelref).addClass("invalid");document.id(b.labelref).set("aria-invalid","true")}}else{b.removeClass("invalid");b.set("aria-invalid","false");if(b.labelref){document.id(b.labelref).removeClass("invalid");document.id(b.labelref).set("aria-invalid","false")}}}});document.formvalidator=null;window.addEvent("domready",function(){document.formvalidator=new JFormValidator});
