//46833145f969fc50d58d548ae3c8f994
var Talk=new Class({Implements:[Options,Events],generated_reply_cursor:0,generated_reply_approved:{},options:{ttitle_default:"Your Title (be descriptive but brief)...",tmessage_default:"Your Message...",attachment_type:0,attachment_id:0},initialize:function(A){this.setOptions(A);this.viewerfade=new Fx.Tween("forum_viewer",{property:"opacity",duration:250,link:"chain"});this.new_topic_post=null;this.initlinks();var B=window.location.href.match(/^([^#]*)#?([^\?]*)(\??.*)$/);this.starturl=B[1]+B[3];if(B[2]){window.location=B[2]}},attach_img_url_attn:function(){var A=new Fx.Tween("attach_img_url",{property:"background-color"}).start("#aa385d","#fff")},initlinks:function(){if($("form_attach_img")){this.attach_img_slider=new Fx.Slide($("form_attach_img"),{duration:500});$("form_attach_img").setOpacity(0);$("form_attach_img").setStyle("display","block");this.attach_img_slider.hide();$("form_attach_img").setOpacity(1);$("attach_img_url").addEvent("keydown",function(B){var A=new Event(B);if(A.key=="enter"){A.stop()}});$("attach_img_slide").addEvent("click",function(B){new Event(B).stop();var A=new Fx.Tween("attach_img_slide",{property:"opacity",link:"chain"});A.start(0).chain(function(){$("attach_img_slide").setStyle("display","none");this.attach_img_slider.slideIn()}.bind(this))}.bind(this));$("attach_img_submit").addEvent("click",function(C){C=new Event(C);C.stop();var A=$("attach_img_url").value;if(!A.match(/^\s*http:\/\/[\-\.\w]+\//)){this.attach_img_url_attn();return }if($("new_topic_form")!=null){ta=$("new_tmessage")}else{ta=$("topic_reply_form").reply}var B=ta.value;B+="\n!"+A+"!";ta.value=B;$("attach_img_url").value=""}.bind(this))}this.out_format="inner";if($("talk-search")){$("talk-search").addEvent("keydown",function(A){if(A&&A.key=="enter"){this.submitSearch()}}.bindWithEvent(this))}if($("talk-search-submit")){$("talk-search-submit").addEvent("click",function(A){A.stop();this.submitSearch()}.bindWithEvent(this))}if($("topic_reply_form")!=null){$$("input.reply").each(function(A){A.removeEvents("click");A.addEvent("click",this.submitReply.bindWithEvent(this,A.id))},this);$$("input.edit").each(function(A){A.removeEvents("click");A.addEvent("click",this.resubmitReply.bindWithEvent(this,A.id));A.setOpacity(0);A.setStyle("display","none")},this);$$("input.approve").each(function(A){A.removeEvents("click");A.addEvent("click",this.commitReply.bindWithEvent(this,A.id));A.setOpacity(0);A.setStyle("display","none")},this)}if($("new_topic_form")!=null){if(this.new_topic_post!=null){$("new_tcat").value=this.new_topic_post.new_tcat;$("new_ttitle").value=this.new_topic_post.new_ttitle;$("new_tmessage").value=this.new_topic_post.new_tmessage}else{if(!this.options.attachment_type==1){$("new_ttitle").value=this.options.ttitle_default}$("new_tmessage").value=this.options.tmessage_default}$("new_ttitle").addEvent("focus",function(){if($("new_ttitle").value==this.options.ttitle_default){$("new_ttitle").value=""}}.bind(this));$("new_tmessage").addEvent("focus",function(){if($("new_tmessage").value==this.options.tmessage_default){$("new_tmessage").value=""}}.bind(this));$$("input.topic_reply").each(function(A){A.removeEvents("click");A.addEvent("click",this.submitTopic.bindWithEvent(this,A))},this)}else{$$("input#new_tedit").each(function(A){A.removeEvents("click");A.addEvent("click",this.changeView.bindWithEvent(this,A.alt))},this);$$("input#new_tapprove").each(function(A){A.removeEvents("click");A.addEvent("click",this.submitTopic.bindWithEvent(this,A))},this)}},changeView:function(C,B,D){var A=this.viewerfade;if(!B.match(/\/talk\/(topic|new-topic)\//)){this.homeurl=B}A.start(0).chain(function(){var E=B;new Request.HTML({url:E,method:"get",update:"forum_viewer",onComplete:function(){A.start(0.99);if($type(D)=="function"){D.attempt()}}}).send({data:{of:this.out_format,aid:this.options.attachment_id,atp:this.options.attachment_type}})}.bind(this)).chain(function(){this.initlinks()}.bind(this));if(C!=null){C.stop()}},submitTopic:function(E,B){if(this._stlock){return }var C=0;var A=this.viewerfade;["new_tcat","new_ttitle","new_tmessage","nt_log"].each(function(G){if($(G)){$(G).set("tween",{duration:5000,transition:Fx.Transitions.Expo.easeIn})}});if($("new_tpreview")!=null){if($("new_tcat")!=null&&$("new_tcat").value==""){$("new_tcat").highlight("#aa385d");C=1}if($("new_ttitle")!=null&&$("new_ttitle").value==""||$("new_ttitle").value==this.options.ttitle_default){$("new_ttitle").highlight("#aa385d");C=1}if($("new_tmessage")!=null&&$("new_tmessage").value==""||$("new_tmessage").value==this.options.tmessage_default){$("new_tmessage").highlight("#aa385d");C=1}}if(C){$("nt_log").fade("show");$("nt_log").fade("out")}else{this._stlock=1;if($("new_tpreview")!=null){var D=1;this.new_topic_post={new_tcat:$("new_tcat").value,new_ttitle:$("new_ttitle").value,new_tmessage:$("new_tmessage").value}}else{var D=0}var F=B.alt;A.start(0).chain(function(){new Request.HTML({url:F,update:"forum_viewer",onError:function(){this._stlock=null}.bind(this),onComplete:function(){A.start(0.99);this._stlock=null}.bind(this)}).post({new_tcat:this.new_topic_post.new_tcat,new_ttitle:this.new_topic_post.new_ttitle,new_tmessage:this.new_topic_post.new_tmessage,new_tprevew:D,atp:this.options.attachment_type,aid:this.options.attachment_id})}.bind(this)).chain(function(){this.initlinks();if(!D){this.new_topic_post=null}}.bind(this))}if(E!=null){E.stop()}},submitReply:function(F,A,J,C){if(this.race==null){this.race=1;var E=A.match(/(\d+)/);E=E[1];var K=$("topic_reply_"+E).value;if(!K){this.race=null;if(F){F.stop()}return }if(C){C=1}else{C=0}if(C){$("topic_reply_"+E).value=""}var G=$("reply_button_"+E);var D=$("edit_reply_button_"+E);var H=$("approve_reply_button_"+E);if(!J&&!C){this.generated_reply_cursor++;G.get("tween",{property:"opacity",link:"chain"}).start(0).chain(function(){G.setStyle("display","none");D.setStyle("display","inline");H.setStyle("display","inline");D.get("tween",{property:"opacity"}).start(1);H.get("tween",{property:"opacity"}).start(1)})}var B="generated_reply_"+this.generated_reply_cursor;if(J){$("reply_approval_banner").setStyle("background-color","#ccc")}var I=$("topic_reply_form").action;new Request({url:I,onError:function(){this.race=null}.bind(this),onComplete:function(M){if(!J&&!C){var O=new Element("div");O.id=B;O.innerHTML=M;O.injectBefore($("topic_reply_form"));var N=0;var L=null;$$("dl.reply").each(function(P){if(N&&!P.hasClass("alt")){P.addClass("alt")}if(!N&&P.hasClass("alt")){P.removeClass("alt")}if(P.hasClass("last")){P.removeClass("last")}N=(N)?0:1;L=P},this);if(L!=null){L.addClass("last")}}else{if(J){$(B).innerHTML=M}else{if(C){$(B).innerHTML=M;D.get("tween",{property:"opacity"}).start(0);H.get("tween",{property:"opacity",link:"chain"}).start(0).chain(function(){D.setStyle("display","none");H.setStyle("display","none");G.setStyle("display","inline");G.get("tween",{property:"opacity"}).start(1)})}}}this.race=null}.bind(this)}).post({reply:K,tid:E,commit:C})}if(F!=null){F.stop()}},commitReply:function(A,B){this.submitReply(A,B,0,1)},resubmitReply:function(A,B){this.submitReply(A,B,1,0)},submitSearch:function(){if($("talk-search")==null){return }var B=$("talk-search").value;B=URLEncode(strip_accents(B.trim().replace(/[!@#\+\$\^\*\(\)\[\]\{\}'":;,]/g,"")));var A=snooth.options.site_url+"/talk/search/"+B+"/";window.location=A}});