B.Captcha=new $class(B.Page, { init:function() { $e.on('.reset_check,* .reset_check', this.reload_capcha, this); }, reload_capcha:function(el) { var img=$('check_code_img'), inp=$('checkcode'), src; if(!img) return true; src=img.src, img.src=JSRoot+'i/blank.png', img.src=src.split('?')[0]+'?reload=1&rand='+Math.random(); inp.value=''; inp.focus(); } }); B.EmailMisprint=new $class(B.Page, { name:'EmailMisprint', el:null, url:'', error_tpl:'', er:null, email:'', corrected_email:'', _cache:{}, init:function() { this.el=$el.down(document.body,'.email_misprint'); if(!this.el || !this.url) return; this._cache[this.email]=true; this._cache[this.corrected_email]=true; if(this.corrected_email) this.er=$el.down(this.el.parentNode,'.input_error_blue'); $e.on('.email_misprint_revert',this.revert,this); $e.add(this.el,'blur',this.correct,this); }, correct:function(el) { var q=this.el.value; if(q in this._cache) return; if(!q || q==this.email || q==this.corrected_email) return; this._cache[q]=true; if(this._loading) this._transport.abort(); this._loading=true; this.email=q; this._transport=new $r(this.url,{ params:{q:q}, ready:this.loaded, error:this.load_error },this); }, revert:function(el) { if(this._loading){ this._transport.abort(); this._loading=false; } this.el.value=this.email; this.hide_error(); new $r(this.url,{ params:{change_back:this.email} }); }, loaded:function(res) { this._loading=false; if(!res.errno) this.hide_error(); else this.show_error(res.q,res.email); }, load_error:function() { this._loading=false; }, show_error:function(email,corrected_email) { if(this.el.value!=email) return; this._cache[corrected_email]=true; this.corrected_email=corrected_email; this.el.value=corrected_email; if(!this.er){ this.er=$u.tpl2el(this.error_tpl); this.el.parentNode.insertBefore(this.er,this.el); } this.er.style.display='block'; }, hide_error:function() { if(this.er) this.er.style.display='none'; } }); B.MsgClose=new $class(B.Page, { shown:false, init:function() { $e.on('.msg-close', this.msg_close, this); setTimeout(this.show.bind(this), 500); }, show:function() { if(this.shown) return; this.shown=true; var el=$el.down(document.body,'.valert'); if(!el) return; new $fx.effect({ wait:false, duration:500, items:[ new $fx.style({ el:el, prop:'height', from:0, start:function() { this.el.style.height='0'; this.el.style.display='block'; this.to=this.el.scrollHeight; }, end:function() { this.el.style.height=''; } }) ] }); }, msg_close:function(a) { var el=$el.up(a,'.cfm'); if(!el) return; new $fx.effect({ wait:false, duration:300, items:[ new $fx.style({ el:el, prop:'height', start:function() { this.from=this.el.offsetHeight; this.el.style.overflow='hidden'; }, end:function() { this.el.parentNode.removeChild(this.el); } }) ] }); if(a.rev) new $r(a.rev); } }); $u.autofocus=function(w){ var el=$el.down(w,'.autofocus'); try{ el && el.focus(); }catch(er){} }; $e.onload($u.autofocus); B.SignIn=new $class(B.Page, { name:'SignIn', init:function() { if($u.ua_ie) $e.add($('signInForm'), 'submit', this.submit, this); }, submit:function(form) { var field=form.elements['make_homepage']; if(!field || !field.checked) return true; try{ var el=$el.create('div'); el.style.behavior='url(#default#homepage)'; el.setHomePage(this.homePageURL); }catch(e){} return true; } });
