window.addEvent("domready",function(){CommentManager.initialize();when($("guideSteps"),GuideCommentManager.initialize);when($("commentWiki"),function(a){a.addEvent("click",function(b){new Event(b).stop().preventDefault();CommentManager.setMsg("Wiki Comment: "+a.get("rel"));CommentManager.setContext("wiki",a.get("rel"))})})});var GuideCommentManager={initialize:function(){$$(".stepComment").each(function(b){b.addEvent("click",function(c){new Event(c).stop().preventDefault();var a=b.getParent(".stepTitle").getElement(".stepValue").get("html");CommentManager.setMsg(a+" Note");CommentManager.setContext("step",b.get("rel"))})});$$(".guideComment").each(function(b){b.addEvent("click",function(a){new Event(a).stop().preventDefault();CommentManager.setMsg("Introduction Note");CommentManager.setContext("guide",b.get("rel"))})})}};var CommentManager={initialize:function(){when($("addCommentForm"),function(e){var d=new LoadingStatus(e);var c=CommentManager.formManager=new FormManager(e);c.required("comment_content");c.addSubmitHandler(function(){Auth.required({message:"You must be logged in to add a new comment",onAuthorize:function(){d.loading("Adding note...");new Request.AjaxIO("addComment",{onSuccess:function(f){d.doneLoading();if(f.success){$("comment_content").set("value","");$("commentDisplay").set("html",f.html);Icons.addEvents($("commentDisplay"));CommentManager.initialize();new Fx.Scroll(window).toElement("c"+f.commentid)}else{c.showError("comment_content","Comment not added. Was this a double post? If not, please refresh the page and try again.")}}}).send($("comment_content").value,$("comment_context").value,$("comment_contextid").value)}});return false});$("comment_preview").addEvent("click",function(f){new Event(f).stop().preventDefault();c.validate(function(){d.loading("Generating preview...");new Request.AjaxIO("previewComment",{onSuccess:function(g){$("previewContent").set("html",g.html);$("previewDiv").show();d.doneLoading()}}).send($("comment_content").value,$("comment_context").value,$("comment_contextid").value)})});$("syntaxToggle").addEvent("click",function(f){new Event(f).stop().preventDefault();$("formatting").toggle()});$$(".replyComment").each(function(f){f.addEvent("click",function(j){new Event(j).stop().preventDefault();var g=f.get("rel").split("_");CommentManager.setContext(g[0],g[1]);var h=f.getParent(".commentStepContainer");var l=h.getElement(".commentStepTitle a");var k;if(l){k=l.get("text")+" Note"}else{k="Add Note"}var i=f.getParent(".comment").getElement(".quoteText").get("html");i=new Element("div").set("html",i).firstChild.nodeValue;$("comment_content").set("value",i+"\n\n");CommentManager.setMsg(k)})});$$(".newComment").each(function(f){f.addEvent("click",function(i){new Event(i).stop().preventDefault();var g=f.get("rel").split("_");CommentManager.setContext(g[0],g[1]);var h=f.getParent(".commentStepContainer");var j=h.getElement(".commentStepTitle a").get("text");CommentManager.setMsg(j+" Note")})});$$(".defaultComment").each(function(f){f.addEvent("click",function(h){new Event(h).stop().preventDefault();var g=f.get("rel").split("_");CommentManager.setContext(g[0],g[1]);CommentManager.setMsg("Add Note")})})});var b=$("viewDeleted");if(b){b.addEvent("click",function(c){new Event(c).stop().preventDefault();new Request.AjaxIO("viewDeleted",{onSuccess:function(d){$("commentDisplay").set("html",d.html);Icons.addEvents($("commentDisplay"));CommentManager.initialize()}}).send()})}var a=$("viewActive");if(a){a.addEvent("click",function(c){new Event(c).stop().preventDefault();new Request.AjaxIO("showPage",{onSuccess:function(d){$("commentDisplay").set("html",d.html);Icons.addEvents($("commentDisplay"));CommentManager.initialize()}}).send("1")})}$$(".deleteComment").each(function(c){c.addEvent("click",function(d){new Event(d).stop().preventDefault();Auth.required({message:"You must be logged in to delete a comment",onAuthorize:function(){new Request.AjaxIO("delComment",{onSuccess:function(){var e=$("c"+c.get("rel"));if(e){e.destroy()}}}).send(c.get("rel"))}})})});$$(".unDeleteComment").each(function(c){c.addEvent("click",function(d){new Event(d).stop().preventDefault();Auth.required({message:"You must be logged in to delete a comment",onAuthorize:function(){new Request.AjaxIO("unDelComment",{onSuccess:function(){var e=$("c"+c.get("rel"));if(e){e.destroy()}}}).send(c.get("rel"))}})})});$$(".flagComment").each(function(c){c.addEvent("click",function(d){new Event(d).stop().preventDefault();new Request.AjaxIO("flagInappropriate",{onSuccess:function(){new Element("span",{html:"notification sent",styles:{color:"#999","font-style":"italic"}}).replaces(c)}}).send(c.get("rel"))})});window.onbeforeunload=function(){var c=$("comment_content");if(c.value){return"Your comments have not yet been posted. If you continue, your changes will be lost."}}},setMsg:function(c){var b=$("addCommentForm");var a=$("comment_content");$("commentText").set("html",c);b.show();CommentManager.formManager.clear(a);new Fx.Scroll(window).toElement(b).chain(function(){a.focus()})},setContext:function(b,a){$("comment_context").set("value",b);$("comment_contextid").set("value",a)},showPage:function(a){new Request.AjaxIO("showPage",{onSuccess:function(){$("commentDisplay").set("html",response)}}).send(a)}};