Ext.ns("T");T.keyMapArrows;T.editedCmt;T.login=new Ext.form.FormPanel({frame:false,border:false,bodyStyle:"padding: 10px; background-color: #f1f1f1;",width:200,defaultType:"textfield",labelWidth:60,url:"/login.php",defaults:{width:"90%"},items:[{fieldLabel:"Login",name:"login",id:"form-login"},{fieldLabel:"Password",inputType:"password",name:"pass",submitValue:false,id:"form-pass"}],api:{submit:Ext.php.Auth.auth}});T.loginSubmit=function(){T.loginWindow.disable();T.login.getForm().submit({params:{encrypted:true,pass:sha1(Ext.getCmp("form-pass").getValue())},success:function(a,b){T.loginWindow.el.hide(true);window.location.reload(true)},failure:function(){T.loginWindow.enable()}})};T.loginWindow=new Ext.Window({items:T.login,closeAction:"hide",listeners:{show:{fn:function(){Ext.getCmp("form-login").focus(true,500)}},afterrender:{fn:function(){new Ext.KeyMap("form-login",[{key:Ext.EventObject.ENTER,fn:function(){T.loginSubmit()},scope:this,stopEvent:true}]);new Ext.KeyMap("form-pass",[{key:Ext.EventObject.ENTER,fn:function(){T.loginSubmit()},scope:this,stopEvent:true}]);if(S.auth){Ext.getCmp("form-login").setValue(S.login).setDisabled(true);Ext.getCmp("form-pass").setValue("1234567890").setDisabled(true)}}}}});T.applyButtons=function(){T.keyMapArrows=new Ext.KeyMap(Ext.getDoc(),[{key:Ext.EventObject.LEFT,ctrl:false,fn:function(){try{window.location.href=Ext.get("arrow-left").child("a").dom.href}catch(a){}},scope:this,stopEvent:true},{key:Ext.EventObject.RIGHT,ctrl:false,fn:function(){try{window.location.href=Ext.get("arrow-right").child("a").dom.href}catch(a){}},scope:this,stopEvent:true},{key:"q",ctrl:true,fn:function(){if(T.loginWindow.isVisible()){T.loginWindow.hide()}else{T.loginWindow.show()}},scope:this,stopEvent:true},{key:13,ctrl:true,fn:function(){try{var d,c=Ext.util.Cookies.get("mode",0),a=Ext.query(".mode-switcher .yellow-r-middle");if(++c>a.length-1){c=0}T.switchMode(a[c])}catch(b){}},scope:this,stopEvent:true}])};T.applyStarComments=function(){var a=Ext.query(".star-comment");if(a&&a.length){Ext.each(a,function(c){var b=new Ext.ux.StarComment({renderTo:c,imageId:S.image_id})})}Ext.get("image").on({click:{fn:function(f,c){if(Ext.ux.StarComment&&Ext.ux.StarComment.activeComment){Ext.ux.StarComment.activeComment.hideComment()}else{var d=f.getXY();var b=new Ext.ux.StarComment({x:d[0]-25,y:d[1]-25,imageId:S.image_id});b.add("comments").setDraft().applyRemoveTool().applySendTool().showComment()}},delegate:"#comments"}})};T.switchMode=function(c){var b=Ext.get(c);if(b.hasClass("active")){return}Ext.getBody().removeClass(["pic-mode","comment-mode","mode-line"]);var a=b.parent(".mode-switcher");Ext.each(a.query(".active"),function(e){Ext.get(e).removeClass("active")});if(b.hasClass("mode-pic")){Ext.getBody().addClass("pic-mode");Ext.each(a.query(".mode-pic"),function(e){Ext.get(e).addClass("active")});var d=0}else{if(b.hasClass("mode-cmt")){Ext.getBody().addClass("comment-mode");Ext.each(a.query(".mode-cmt"),function(e){Ext.get(e).addClass("active")});var d=1}else{Ext.getBody().addClass("mode-line");Ext.each(a.query(".mode-line"),function(e){Ext.get(e).addClass("active")});var d=2;if(W.init){W.init()}}}Ext.util.Cookies.set("mode",d)};T.applyModeSwitcher=function(){var a=Ext.query(".mode-switcher .yellow-r-middle");try{if(a&&a.length){Ext.each(a,function(c){Ext.get(c).on("click",function(d){T.switchMode(c)},this)})}}catch(b){}};Ext.onReady(function(){Ext.Direct.on("exception",function(a){if(Ext.ux.StarComment&&Ext.ux.StarComment.activeComment){Ext.ux.StarComment.activeComment.setMessageError()}});T.image=Ext.get("image");T.comments=Ext.get("comments");T.dt=Ext.get("dt");T.left=Ext.get("arrow-left");T.right=Ext.get("arrow-right");T.applyButtons();T.applyStarComments();T.applyModeSwitcher()});
