//62a9f60852b0fba1b8060daf68199f3e
var ArticlesPage=new Class({Implements:[Options,Lock],options:{article:{id:0}},initialize:function(A){this.setOptions(A);this.initsearch();if(this.options.article.id!=0){this.initcomments();this.initnotification()}},initcomments:function(){$("article-comment-body").autoresize();$("article-comment-submit").click(this.post_comment,[false],this);$("comment-preview-box").hide().removeClass("hide");$("article-comment-confirm").click(this.post_comment,[true],this);$("article-comment-cancel").click(this.post_comment_goback,[],this)},initnotification:function(){var A=Cookie.read("inline_notification");if(A!=null){inline_notification(A,$("article-bar"),"after");Cookie.dispose("inline_notification",{domain:snooth.options.cdom,path:"/"})}},initsearch:function(){$("article-search-submit").click(this.run_search,[],this);$("article-search").enter(this.run_search,[],this)},run_search:function(){var A=$("article-search").value;if(A.match(/\w/)){window.location=snooth.options.site_url+"/articles/search/"+prepare_search(A)+"/"}},post_comment_goback:function(){this.unlock("confirm");this.unlock("comment");$("comment-form").show();$("comment-preview-box").hide()},post_comment_confirmed:function(A){Cookie.write("inline_notification","Thank you for your comment",{duration:5,domain:snooth.options.cdom,path:"/"});window.location=this.options.article_url},post_comment:function(B){if(snooth.options.user.id==0){snooth.removeEvents("login-callback");snooth.addEvent("login-callback",this.post_comment.bind(this));snooth.si_show();return }var A=$("article-comment-body").value;if(!A.match(/\w/)){return }if(B){B=1}else{B=0}if(B){if(this.locked("confirm")){return }this.lock("confirm")}else{if(this.locked("comment")){return }this.lock("comment");this.lock("confirm")}new Request.JSON({url:snooth.options.site_url+"/articles/",onSuccess:function(D){if(!D||D.error||!D.html){if(B){this.unlock("confirm")}else{this.unlock("comment")}var C="We were unable to add your comment.  Please try again.";if(D&&D.error){C=D.error}show_generic_bubble("Sorry!",C);return }if(B){this.post_comment_confirmed(D.id)}else{$("comment-preview").set("html",D.html);$("comment-form").hide();$("comment-preview-box").show();this.unlock("confirm")}}.bind(this),onComplete:function(){}.bind(this)}).post({article_id:this.options.article.id,action:"comment",body:A,confirm:B})}});