var Comments={start:function(){Comments.popup=$("popup");if(typeof Video!="undefined"){$$("p.comment-body").each(function(D,C){var B=D.innerHTML;B=B.replace(/([#@]\s*(\d+))/g,'<a href="#comment-$2" onmouseover="Comments.up($2)" onmouseout="Comments.down()">$1</a>');D.innerHTML=B})}var A=$("comment-form");if(A){A.addEvent("submit",Comments.preSubmit);$("timelink").addEvent("click",Comments.insertPlayTime);$$("#commentsmilies img").each(function(B){B.addEvent("click",Comments.insertText.pass(" "+B.getProperty("alt")+" "))})}Comments.initRateComment();Comments.initShowComment()},up:function(B){var C=$$(".comment .comment-posted")[B-1];var A=$$(".comment .comment-body")[B-1];if(C&&A){Comments.popup.innerHTML='<p class="comment-header">'+C.innerHTML+'</p><p class="comment-body">'+A.innerHTML+"</p>";Comments.popup.style.width="400px";Comments.popup.style.display="block";window.addEvent("mousemove",Comments.move)}},down:function(){window.removeEvent("mousemove",Comments.move);Comments.popup.innerHTML="";Comments.popup.style.display="none"},move:function(D){var B=window.getSize(),A=window.getScroll();var G={x:Comments.popup.offsetWidth,y:Comments.popup.offsetHeight};var F={x:15,y:-(G.y/2)};var C={x:"left",y:"top"};for(var E in C){var H=D.page[E]+F[E];Comments.popup.setStyle(C[E],H)}},preSubmit:function(){var A=Video.player.toElement().getInfo();$("comment-form-playtime").value=A.playTime;$("comment-form-videostate").value=A.state;$("comment-form-seenall").value=A.seenall;return true},insertText:function(C){var A=$("ac-input");A.focus();if(document.selection){var B=document.selection.createRange();B.text=C}else{if(A.selectionStart||A.selectionStart=="0"){A.value=A.value.substring(0,A.selectionStart)+C+A.value.substring(A.selectionEnd)}else{A.value+=C}}},insertPlayTime:function(){var B=Video.player.toElement().getInfo().playTime;var A=Math.floor(B/60);B%=60;Comments.insertText(" "+A+":"+B+" ");return false},initRateComment:function(){$$(".rc-good").each(function(A){A.addEvent("click",function(B){B.stop();Comments.rate.send("id="+A.rel+"&rate=good");urchinTracker("/ratecomment/good")})});$$(".rc-bad").each(function(A){A.addEvent("click",function(B){B.stop();Comments.rate.send("id="+A.rel+"&rate=bad");urchinTracker("/ratecomment/bad")})})},rate:new Request({url:"/ajax-rate-comment.php",method:"get",onSuccess:function(B){if(B.indexOf(":")!=-1){var A=B.split(":");$("comment-rating-"+A[0]).innerHTML=A[1];$("comment-"+A[0]).addClass("voted")}else{if(B.indexOf("@")!=-1){window.location="/login.php?back="+window.location.pathname}else{alert(B)}}}}),initShowComment:function(){$$(".comment-show").each(function(A){A.addEvent("click",function(B){B.stop();var C=A.rel;A.destroy();$("comment-"+C).removeClass("comment-hidden");$("comment-body-"+C).removeClass("hide");$("comment-posted-"+C).removeClass("hide")})})}};window.addEvent("domready",Comments.start);