var CommentNote='Click to write new comment.\nFree registration is required to post comments.\nYou also can modify your previously posted comment.';var TorrentId;var Posting=false;var cmdPost;var tRateWarning;var WarningsCount=0;function LoadComments(){cmdPost=dEl("cmdPost");var httpGet=new XmlHttpGet("Comments.aspx?tid="+TorrentId+"&rnd="+new Date().getTime(),function(responseText){var ResultId=responseText.substr(0,1);var ResultText=responseText.substr(1);if(ResultId=="0")dEl("Comments").innerHTML=HtmlUtility.AddResourceGetHtml(ResultText);else if(ResultId=="1"){dEl("Comments").innerHTML=HtmlUtility.AddResourceGetHtml(ResultText);ShowMessage(ResultText,true);}else if(ResultId=="2")ShowMessage("<span class=\"Larger\">"+ResultText+"</span>",true);});dEl("Comments").innerHTML="Loading comments...";httpGet.Send();}function SubmitComment(){var AudioRate=dEl("AudioRate").rate;var VideoRate=dEl("VideoRate").rate;var PlotRate=dEl("PlotRate").rate;if(!dEl("txtComment").isDefault)Comment=dEl("txtComment").value.trim();else Comment='';if(VideoRate!=AudioRate&& (VideoRate==0||AudioRate==0))return ShowMessage("<span class='Larger Bold'>Please rate both audio and video.</span",true);if(VideoRate==0 && AudioRate==0 && PlotRate==0 && Comment=='')return ShowMessage("<span class='Larger Bold'>Nothing to submit!</span>",true);if(Comment.length>200)return ShowMessage("<span class='Larger Bold'>Comment length exceeded maximum length: "+Comment.length+"/200</span>",true);if(AudioRate==0 && VideoRate==0 && PlotRate==0){clearInterval(tRateWarning);tRateWarning=setInterval(WarnRating,300);};PostComment("Action=Add&AudioRate="+AudioRate+"&VideoRate="+VideoRate+"&PlotRate="+PlotRate+"&Comment="+Comment.replace(/\r\n|\n/g,"<br />"));}function WarnRating(){if(WarningsCount>7){WarningsCount=0;return clearInterval(tRateWarning);};var elRateBox=dEl("RateBox");elRateBox.className=(WarningsCount++%2)==0?"Blink":""}function ReportComment(id){PostComment("Action=report&comment="+id);}function DeleteComment(id){if(confirm("Are you sure you want to delete this comment?")){PostComment("Action=delete&comment="+id);}}function PostComment(Params){var OldCommand=cmdPost.value;cmdPost.value="Wait...";cmdPost.disabled=true;var ThisFunction=function(){PostComment(Params)};Posting=true;var httpPost=new XmlHttpPost("Comments.aspx?tid="+TorrentId+"&rnd="+new Date().getTime(),Params,function(responseText){var ResultId=responseText.substr(0,1);var ResultText=responseText.substr(1);cmdPost.disabled=false;cmdPost.value=OldCommand;if(ResultId=="9")QuickLogin(ThisFunction,ResultText);if(ResultId=="8")ShowMessage(ResultText,false,4000);if(ResultId=="2")ShowMessage("<span class=\"Larger\">"+ResultText+"</span>",true);else if(ResultId=="0" || ResultId=="5")dEl("Comments").innerHTML=HtmlUtility.AddResourceGetHtml(ResultText);else if(ResultId=="1"){ShowMessage(ResultText,false);};Posting=false;});httpPost.Send();}function CalcCommentLength(){var MaxLength=200;var MaxLines=3;var TextArea=dEl("txtComment");var Length=TextArea.value.replace(/\n/g,"<br />").length;var Lines=TextArea.value.split("\n").length;var elCommentLength=dEl("CommentRemainingLength");elCommentLength.innerHTML="Remaining characters left: "+Math.max(0,MaxLength-Length);elCommentLength.style.color=(Length<MaxLength-5&&Lines<=MaxLines)?"#000000":"#ff0000";if(Lines>MaxLines){elCommentLength.innerHTML="Too many lines";TextArea.value=TextArea.oldText?TextArea.oldText:"";Lines=TextArea.value.split("\n").length;};if(Length>MaxLength)TextArea.value=TextArea.oldText?TextArea.oldText:TextArea.value.substr(0,MaxLength-6*Lines);TextArea.oldText=TextArea.value;}