//816a4aac381b4d555722cd45e3d522ab
var ArticlesPage=new Class({Implements:[Options,Lock],options:{article:{id:0}},initialize:function(A){this.setOptions(A);this.initLinks();this.initSearch();if(this.options.article.id!==0){this.initComments();this.initNotification()}},initLinks:function(){$$("a.mm-image-action").each(function(B){var C=B.getElement("span.mm-image-action-text"),A=B.getParent("div.mm-image-wrapper");if(C&&A){this.setExpander(A,B,{},function(D){C.setStyles({display:"inline"})})}}.bind(this))},setExpander:function(B,E,C,G){var A,F,D,H;A=E.getWidth();G.apply(this,[E]);F=E.getWidth();H=A-F;D=0;E.set("tween",{link:"cancel",duration:200});E.setStyles({right:H});B.setEvents({mouseenter:function(){E.tween("right",D)},mouseleave:function(){E.tween("right",H)}})},initComments:function(){if($("article-comment-body")){$("article-comment-body").autoresize();$("article-comment-submit").click(this.postComment,[false],this);$("comment-preview-box").hide().removeClass("hide");$("article-comment-confirm").click(this.postComment,[true],this);$("article-comment-cancel").click(this.postCommentGoBack,[],this)}},initNotification:function(){var A=Cookie.read("inline_notification");if(A){inline_notification(A,$("article-bar"),"after");Cookie.dispose("inline_notification",{domain:snooth.options.cdom,path:"/"})}},initSearch:function(){$("article-search-submit").click(this.runSearch,[],this);$("article-search").enter(this.runSearch,[],this)},runSearch:function(){var A=$("article-search").value;if(A.match(/\w/)){window.location=snooth.options.site_url+"/articles/search/"+doc_prepare_search(A)+"/"}},postCommentGoBack:function(){this.unlock("confirm");this.unlock("comment");$("comment-form").show();$("comment-preview-box").hide()},postCommentConfirmed:function(A){Cookie.write("inline_notification","Thank you for your comment",{duration:5,domain:snooth.options.cdom,path:"/"});window.location=this.options.article_url},postComment:function(B){if(!snooth.options.user.id){snooth.removeEvents("login-callback");snooth.addEvent("login-callback",this.postComment.bind(this));snooth.si_show();return }var A=$("article-comment-body").value,C;if(!A.match(/\w/)){return }if(B){if(this.locked("confirm")){return }this.lock("confirm")}else{if(this.locked("comment")){this.lock("comment")}this.lock("confirm")}C=new Request.JSON({url:snooth.options.site_url+"/articles/",onSuccess:function(E){var D;if(!E||E.error||!E.html){if(B){this.unlock("confirm")}else{this.unlock("comment")}D="We were unable to add your comment.  Please try again.";if(E&&E.error){D=E.error}show_generic_bubble("Sorry!",D);return }if(B){this.postCommentConfirmed(E.id)}else{$("comment-preview").set("html",E.html);$("comment-form").hide();$("comment-preview-box").show();this.unlock("confirm")}}.bind(this),onComplete:function(){}.bind(this)});C.post({article_id:this.options.article.id,action:"comment",body:A,confirm:B?1:0})}});