// Copyright Zikula Foundation 2010 - license GNU/LGPLv3 (or at your option, any later version).
Zikula.define("Users");Zikula.Users.AdminModifyRegistration={init:function(){$("submitchanges").disabled=true;$("submitchanges").addClassName("z-hide");var c=Form.getElements("users_modifyregistration");for(var b=0,a=c.length;b<a;b++){if((c[b].id!="checkuserajax")&&(c[b].id!="submitchanges")){c[b].observe("click",Zikula.Users.AdminModifyRegistration.lastCheckExpired);c[b].observe("keypress",Zikula.Users.AdminModifyRegistration.lastCheckExpired)}}$("users_reginfo_uname").observe("keyup",function(){$("users_reginfo_uname").value=$("users_reginfo_uname").value.toLocaleLowerCase()});$("users_reginfo_email").observe("keyup",function(){$("users_reginfo_email").value=$("users_reginfo_email").value.toLocaleLowerCase()});$("checkuserajax").removeClassName("z-hide");$("checkuserajax").observe("click",Zikula.Users.AdminModifyRegistration.callGetRegistrationErrors)},lastCheckExpired:function(){if(!$("submitchanges").disabled){$("users_checkmessage").removeClassName("z-hide");$("users_validmessage").addClassName("z-hide");$("submitchanges").addClassName("z-hide");$("submitchanges").disabled=true}},callGetRegistrationErrors:function(){var a=Form.serialize("users_modifyregistration");new Zikula.Ajax.Request(Zikula.Config.baseURL+"ajax.php?module=Users&func=getRegistrationErrors",{parameters:a,onComplete:Zikula.Users.AdminModifyRegistration.responseGetRegistrationErrors})},responseGetRegistrationErrors:function(h){if(!h.isSuccess()){Zikula.showajaxerror(h.getMessage());return}var e=h.getData();var c=e.fields;var m=e.messages;var a=Form.getElements("users_modifyregistration");var j=null;var k=null;for(var f=0,g=a.length;f<g;f++){if(a[f].type=="checkbox"){k=$(a[f].id+"_field");if((typeof(k)!=undefined)&&(k!=null)){k.removeClassName("errorrequired")}}else{a[f].removeClassName("errorrequired")}}for(f=0,g=c.length;f<g;f++){j=$(c[f]);if(j.type=="checkbox"){k=j.id+"_field";if((typeof(k)!=undefined)&&(k!=null)){k.addClassName("errorrequired")}}else{c[f].addClassName("errorrequired")}}var d=$("users_errormessages");var l=$("users_errormessages_div");var b=$("submitchanges");if(d.childElementCount>0){d.childElements().each(function(i){i.remove()})}if(m.length>0){b.disabled=true;b.addClassName("z-hide");for(f=0,g=m.length;f<g;f++){d.insert("<li>"+m[f]+"</li>")}l.removeClassName("z-hide");location.hash="users_formtop"}else{b.disabled=false;b.removeClassName("z-hide");if(!l.hasClassName("z-hide")){l.addClassName("z-hide")}$("users_checkmessage").addClassName("z-hide");$("users_validmessage").removeClassName("z-hide")}}};document.observe("dom:loaded",Zikula.Users.AdminModifyRegistration.init);