var Validator={isEmail:function(b){return this.test(b,"^[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&'*+\\/0-9=?A-Z^_`a-z{|}~]+.[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+$")},isAbsUrl:function(b){return this.test(b,"^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$")},isSize:function(b){return this.test(b,"^[0-9]+(%|in|cm|mm|em|ex|pt|pc|px)?$")},isId:function(b){return this.test(b,"^[A-Za-z_]([A-Za-z0-9_])*$")},isEmpty:function(f){var e,d;if(f.nodeName=="SELECT"&&f.selectedIndex<1){return true}if(f.type=="checkbox"&&!f.checked){return true}if(f.type=="radio"){for(d=0,e=f.form.elements;d<e.length;d++){if(e[d].type=="radio"&&e[d].name==f.name&&e[d].checked){return false}}return true}return new RegExp("^\\s*$").test(f.nodeType==1?f.value:f)},isNumber:function(d,c){return !isNaN(d.nodeType==1?d.value:d)&&(!c||!this.test(d,"^-?[0-9]*\\.[0-9]*$"))},test:function(d,c){d=d.nodeType==1?d.value:d;return d==""||new RegExp(c).test(d)}};var AutoValidator={settings:{id_cls:"id",int_cls:"int",url_cls:"url",number_cls:"number",email_cls:"email",size_cls:"size",required_cls:"required",invalid_cls:"invalid",min_cls:"min",max_cls:"max"},init:function(d){var c;for(c in d){this.settings[c]=d[c]}},validate:function(i){var c,f,j=this.settings,h=0;f=this.tags(i,"label");for(c=0;c<f.length;c++){this.removeClass(f[c],j.invalid_cls)}h+=this.validateElms(i,"input");h+=this.validateElms(i,"select");h+=this.validateElms(i,"textarea");return h==3},invalidate:function(b){this.mark(b.form,b)},reset:function(i){var k=["label","input","select","textarea"];var l,e,h,j=this.settings;if(i==null){return}for(l=0;l<k.length;l++){h=this.tags(i.form?i.form:i,k[l]);for(e=0;e<h.length;e++){this.removeClass(h[e],j.invalid_cls)}}},validateElms:function(o,n){var r,p,q,e=this.settings,f=true,m=Validator,i;r=this.tags(o,n);for(p=0;p<r.length;p++){q=r[p];this.removeClass(q,e.invalid_cls);if(this.hasClass(q,e.required_cls)&&m.isEmpty(q)){f=this.mark(o,q)}if(this.hasClass(q,e.number_cls)&&!m.isNumber(q)){f=this.mark(o,q)}if(this.hasClass(q,e.int_cls)&&!m.isNumber(q,true)){f=this.mark(o,q)}if(this.hasClass(q,e.url_cls)&&!m.isAbsUrl(q)){f=this.mark(o,q)}if(this.hasClass(q,e.email_cls)&&!m.isEmail(q)){f=this.mark(o,q)}if(this.hasClass(q,e.size_cls)&&!m.isSize(q)){f=this.mark(o,q)}if(this.hasClass(q,e.id_cls)&&!m.isId(q)){f=this.mark(o,q)}if(this.hasClass(q,e.min_cls,true)){i=this.getNum(q,e.min_cls);if(isNaN(i)||parseInt(q.value)<parseInt(i)){f=this.mark(o,q)}}if(this.hasClass(q,e.max_cls,true)){i=this.getNum(q,e.max_cls);if(isNaN(i)||parseInt(q.value)>parseInt(i)){f=this.mark(o,q)}}}return f},hasClass:function(f,c,d){return new RegExp("\\b"+c+(d?"[0-9]+":"")+"\\b","g").test(f.className)},getNum:function(c,d){d=c.className.match(new RegExp("\\b"+d+"([0-9]+)\\b","g"))[0];d=d.replace(/[^0-9]/g,"");return d},addClass:function(c,g,b){var h=this.removeClass(c,g);c.className=b?g+(h!=""?(" "+h):""):(h!=""?(h+" "):"")+g},removeClass:function(c,d){d=c.className.replace(new RegExp("(^|\\s+)"+d+"(\\s+|$)")," ");return c.className=d!=" "?d:""},tags:function(c,d){return c.getElementsByTagName(d)},mark:function(d,f){var e=this.settings;this.addClass(f,e.invalid_cls);this.markLabels(d,f,e.invalid_cls);return false},markLabels:function(i,h,g){var f,j;f=this.tags(i,"label");for(j=0;j<f.length;j++){if(f[j].getAttribute("for")==h.id||f[j].htmlFor==h.id){this.addClass(f[j],g)}}return null}};