KYUI().use("key-io","k-auth","node-base","dom-base","event-custom",function(a){var e=null;var h=null;var g="form-reg";var d=3000;var c=function(){e=new a.KEY.io.FormRemoteConnect({successClear:false,form:{id:g,incremental:true}});e.on("formRemoteConnect:success",function(k){var j=e.get("data.JSONData");if(j!=null){b(j.nextstep,null)}})};var i=function(){h=new a.KEY.io.FormRemoteConnect({form:{id:"form-regcap",captcha:"cap"}});h.on("formRemoteConnect:success",function(l){var k=h.get("data.JSONData");if(k!=null){gTrack0();b(k.nextstep,k)}});h.on("formRemoteConnect:failure",function(m){var k=h.get("data.JSONData");if(k!=null){var l=k.backstep;if(l=="1"){b("1",null)}e.handleFormData(h.get("data.FormData"));m.stopPropagation()}});var j=a.one("#regcap-capreload");if(j!=null){j.on("click",function(k){h.captchaReload();k.preventDefault()})}};var b=function(v,u){a.log("Handling step "+v+" "+u,"info","Ajaj");if(v=="0"){if(e!=null){e.reset()}var p=a.one("#regbox");if(p!=null){p.addClass("hidden").setStyle("display","")}p=a.one("#regcapbox");if(p!=null){p.addClass("hidden")}ele=a.one("#formerr-regcap");if(p!=null){p.addClass("hidden")}p=a.one("#regsuccbox");if(p!=null){p.addClass("hidden")}p=a.one("#regeyes");if(p!=null){p.addClass("hidden")}p=null}if(v=="1"){if(e==null){c()}if(u==null){e.reset()}var p=a.one("#regbox");if(p!=null){p.removeClass("hidden").setStyle("display","")}var p=a.one("#regeyes");if(p!=null){p.removeClass("hidden")}p=a.one("#regcapbox");if(p!=null){p.addClass("hidden")}p=a.one("#formerr-regcap");if(p!=null){p.addClass("hidden")}p=a.one("#regsuccbox");if(p!=null){p.addClass("hidden")}p=null}else{if(v=="2"){if(h==null){i()}else{h.captchaReload()}a.one("#regbox").addClass("hidden");a.one("#regcapbox").removeClass("hidden");a.one("#regsuccbox").addClass("hidden");try{a.one("#regcap-cap").focus()}catch(q){}}else{if(v=="3"){a.one("#regbox").addClass("hidden");a.one("#regcapbox").addClass("hidden");a.one("#regsuccbox").removeClass("hidden");a.get("#regsucc-applettext").addClass("hidden");a.get("#regsucc-loading").removeClass("hidden");a.get("#regsucc-loadingdone").addClass("hidden");a.get("#regsucc-applettext-manual").addClass("hidden");a.get("#regsucc-applettext-java").addClass("hidden");a.get("#regsucc-applettext-loggedin").addClass("hidden");a.get("#regsucc-timeout").addClass("invisible");var j=u.nick;var r=u.checksum;var m=a.one("#regsuccbox-nick");if(m!=null){m.set("innerHTML"," "+j.replace(/\"/,"&#34;").replace(/</,"&lt;")+" ")}try{var o=a.get("#chatapplet");var l=null;if(o!=null){l=a.Node.getDOMNode(o)}var t=true;var s=false;try{t=navigator.javaEnabled()||(deployJava!=null&&deployJava.versionCheck("1.0+"))}catch(q){a.log(q)}try{s=l.hasActiveGroups()==true||l.hasActiveGroups()==false}catch(q){a.log(q)}t=t||s;if(t){if(o!=null){try{if(d>=0&&l!=null&&s){if(!l.hasActiveGroups()){a.get("#regsucc-applettext").removeClass("hidden");KYUI().use("async-queue",function(n){var w=new n.AsyncQueue();w.add({fn:function(){l.tryAutoLogin(j,r);a.get("#regsucc-timeout").removeClass("invisible");a.get("#regsucc-loading").addClass("hidden");a.get("#regsucc-loadingdone").removeClass("hidden")},timeout:d});w.run()})}else{a.get("#regsucc-applettext-loggedin").removeClass("hidden")}}else{a.get("#regsucc-applettext-manual").removeClass("hidden")}}catch(q){a.get("#regsucc-applettext-manual").removeClass("hidden");a.log(q)}}else{}}else{a.get("#regsucc-applettext-java").removeClass("hidden")}}catch(q){a.log(q);if(u.redirect){try{var k=a.get("#registration-redirect").get("title");if(k!=null&&k.length>4){k+="?nick="+encodeURIComponent(j)+"&toke="+encodeURIComponent(r);window.location=k}}catch(q){a.log(q);alert("You successfully registered your nick, try to login now")}}}}}}};a.on("available",function(){var k=K.auth.Info.getInstance();var j=a.one("#alwaysshowreg")!=null;if(j||k.hasValue()==false||window.location.hash=="#reg"||window.location.hash=="reg"){b(1)}},"#"+g,null);a.on("domready",function(){if(a.one("#alwaysshowreg")!=null){b(1)}},"#"+g,null);if(typeof K==="undefined"||!K){K=new Object()}if(typeof K.reg==="undefined"||!K.reg){K.reg=new Object()}K.reg.applyTrigger=function(){a.all(".jsregtrigger").removeClass("jsregtrigger").on("click",function(k){b(1);if(a.one("#regbox")!=null){k.preventDefault();var j=k.target;if(j!=null){j.blur()}return false}})};var f=function(){a.on("available",function(){a.all(".jsreguntrigger").removeClass("jsreguntrigger").on("click",function(j){b(0);if(a.one("#regbox")!=null){j.preventDefault();return false}});f()},".jsreguntrigger")};f()});