var discuss_interval=3500;var timer;function addInterval(){if(discuss_interval<300000){discuss_interval*=1.2
}}function resetInterval(){discuss_interval=3500}function getComments(){new Ajax(baseURL()+"&r="+(Math.random()).toString().substr(2,6),{method:"get",onComplete:receiveComments}).request()
}function check_type(a){var b=a.keyCode?a.keyCode:a.which?a.which:a.charCode;if(b==13||b==3){sendComment();
return false}return true}function baseURL(){return $("sendDiscuss").getProperty("action")+"?"+$("discussMeta").toQueryString("&")
}function receiveComments(j){j=Json.clean(j);if(j=="null"){addInterval();$clear(timer);
timer=getComments.delay(discuss_interval);return}if($("discuss").hasClass("popout")){window.focus()
}resetInterval();timer=getComments.delay(discuss_interval);var b=Json.evaluate(j);
if(loaderFx.now>0){loaderFx.clearTimer().start(1,0)}var g=$("commentlist"),d=$("in-discuss"),k=$("lastID"),f=g.getFirst(),h,e,a;
if(f.getTag()=="strong"){f.remove();h=" ";new Fx.Height("timeshow",{duration:200}).toggle();
hadMessages=false}else{hadMessages=true;h=(g.getLast().hasClass("alt"))?" ":""}for(e=0,a=b.length;
e<a;e++){var l=b[e];if(l.id<=k.value){continue}h=(h=="")?"alt":"";oWrap=new Element("div").addClass(h).setProperty("rel",l.time);
oLI=new Element("div").injectInside(oWrap).setHTML(l.del+l.link+" : "+l.text);applyMouseovers(oWrap);
eff=new Fx.Height(oWrap,{duration:200,onComplete:function(){this.setStyle("overflow","visible");
this.setStyle("height","auto");toBottom()}.bind(oWrap)});eff.hide();eff.increase=function(){this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit));
toBottom()}.bind(eff);g.adopt(oWrap);eff.toggle();k.value=l.id}timeOut()}function sendComment(){resetInterval();
var a=$("discussmsg");if(a.value.trim()==""){return false}if(hasBadWords(a.value)){return false
}var b=$("sendDiscuss"),c=b.toQueryString()+"&action=sendComment";$clear(timer);loaderFx.start(0,1);
a.value="";new Ajax(b.getProperty("action"),{data:c,onComplete:getComments}).request();
return false}function mdelete(a){new Ajax(a.href+"&action=deleteMessage",{method:"get",onComplete:function(){var e=$(a.parentNode.parentNode),d=e==$("commentlist").getLast(),c=e==$("commentlist").getFirst(),b=e;
while(b=b.getNext()){b.toggleClass("alt")}ef=new Fx.Height(e,{duration:200,onComplete:function(){e.remove();
if(d&&c){new Element("strong").appendText("No Messages").injectInside($("commentlist").setStyle("margin-top","0"))
}else{if(d){timeOut()}}}});if(d&&c){new Fx.Height("timeshow",{duration:200}).toggle()
}ef.increase=function(){this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit))
}.bind(ef);ef.toggle()}}).request();return false}function timeOver(){this.addClass("over");
$("timeshow").setHTML("<b>That Message: </b> "+this.getProperty("rel")).addClass("over")
}function timeOut(){if($type(this)=="element"){this.removeClass("over")}$("timeshow").setHTML("<b>Last Message: </b> "+$("commentlist").getLast().getProperty("rel")).removeClass("over")
}function applyMouseovers(a){if($type(a.getProperty("rel"))=="string"){a.addEvent("mouseover",timeOver);
a.addEvent("mouseout",timeOut)}}function toBottom(){$("commentlist").scrollTop=99999
}Window.onDomReady(function(){$ES("div",$("commentlist")).each(applyMouseovers);toBottom();
toBottom.delay(100);timer=getComments.delay(discuss_interval);loaderFx=$("loader").effect("opacity")
});var loaderFx;