var allowScroll=true;window.onscroll=function(){if(allowScroll==false){document.documentElement.scrollTop=0;document.body.scrollTop=0}};function ajaxCall(D,B,C){var A=window.XMLHttpRequest?new XMLHttpRequest():(window.ActiveXObject("Msxml2.XMLHTTP")?new ActiveXObject("Msxml2.XMLHTTP"):new ActiveXObject("Microsoft.XMLHTTP"));A.open(B,D,true);A.send(null);A.onreadystatechange=C}function nl2br(B){B=escape(B);var A=/%0A/g;if(B.indexOf("%0D%0A")>-1){A=/%0D%0A/g}else{if(B.indexOf("%0A")>-1){A=/%0A/g}else{if(B.indexOf("%0D")>-1){A=/%0D/g}}}return unescape(B.replace(A,"<br />\n"))}function stripWhitespace(A){return A.replace(/^\s+|\s+$/g,"")}function focusElement(B){var A=$(B);if(A.style.display=="none"){allowScroll=false;cleanUpElement(B);$("ajaxOverlayId").style.display="block";A.style.display="block";originalHeight=document.documentElement.scrollTop;document.documentElement.scrollTop=0;document.body.scrollTop=0;$("ajaxOverlayId").style.height=getWindowHeight()}else{allowScroll=true;cleanUpElement(B);$("ajaxOverlayId").style.display="none";A.style.display="none";document.documentElement.scrollTop=originalHeight}}function cleanUpElement(A){if($(A+"Loading")){$(A+"Loading").style.display="none"}if($(A+"Finished")){$(A+"Finished").style.display="none"}if($(A+"Content")){$(A+"Content").style.display="block"}}function closeBoxCallback(A){if($(A).style.display=="block"){focusElement(A)}}function displayDeleteComment(){var A=$("confirmDeleteCommentLink");A.href="/comments/delete/"+this.parentId+"/";A.parentId=this.parentId;A.onclick=deleteComment;focusElement("deleteCommentBox");return false}function deleteComment(){$("deleteCommentBoxLoading").style.display="block";$("deleteCommentBoxContent").style.display="none";$(this.parentId).style.display="none";ajaxCall($("confirmDeleteCommentLink").href+"?formToken="+$("formToken").value,"GET",deleteCommentCallback);return false}function deleteCommentCallback(){if(this.readyState==4&&$("deleteCommentBoxLoading").style.display=="block"){$("deleteCommentBoxLoading").style.display="none";$("deleteCommentBoxFinished").style.display="block";if($("deleteCommentBox").style.display=="block"){setTimeout("closeBoxCallback( 'deleteCommentBox' )",1800)}}}function displayEditComment(){$("editCommentBox").className="largePopupBox";$("editCommentBoxError").style.display="none";$("editCommentForm").action="/comments/edit/"+this.parentId+"/";$("editCommentForm").parentId=this.parentId;$("editCommentTextbox").value=this.postContent;$("submitEditComment").onclick=editComment;focusElement("editCommentBox");return false}function editComment(){var A=$("editCommentTextbox");if(stripWhitespace(A.value)==""){$("editCommentBoxError").innerHTML='<p class="alert"><img src="/Interface/Icons/bullet_error.png" /> Please enter a comment.</p>';$("editCommentBoxError").style.display="block";return false}if(A.value.length>=656){$("editCommentBoxError").innerHTML='<p class="alert"><img src="/Interface/Icons/bullet_error.png" /> Comment was too long! Max post length is 655 characters.</p>';$("editCommentBoxError").style.display="block";return false}$("editCommentBox").className="smallPopupBox";$("editCommentBoxLoading").style.display="block";$("editCommentBoxContent").style.display="none";ajaxCall($("editCommentForm").action+"?post="+escape(A.value)+"&formToken="+$("formToken").value,"GET",editCommentCallback);return false}function editCommentCallback(){if(this.readyState==4){$("editCommentLink"+$("editCommentForm").parentId).postContent=$("editCommentTextbox").value;$($("editCommentForm").parentId+"comment").innerHTML=nl2br($("editCommentTextbox").value)}if(this.readyState==4&&$("editCommentBoxLoading").style.display=="block"){$("editCommentBoxLoading").style.display="none";$("editCommentBoxFinished").style.display="block";if($("editCommentBox").style.display=="block"){setTimeout("closeBoxCallback( 'editCommentBox' )",1800)}}}function assignAjaxHandlers(){var B=document.getElementsByName("deleteCommentLink");for(var D=0;D<B.length;D++){B[D].parentId=B[D].parentNode.parentNode.parentNode.parentNode.id;B[D].onclick=displayDeleteComment}var C=document.getElementsByName("editCommentLink");for(var A=0;A<C.length;A++){C[A].parentId=C[A].parentNode.parentNode.parentNode.parentNode.id;var F=$(C[A].parentId+"comment").innerHTML;if((document.all)&&(navigator.userAgent.indexOf("Opera")==-1)){var E="\n"}else{var E=""}C[A].postContent=F.replace(/<br>/gi,E);C[A].onclick=displayEditComment}if($("closeDeleteCommentBox")){$("closeDeleteCommentBox").onclick=function(){focusElement("deleteCommentBox");return false}}if($("ajaxOverlayId")){$("ajaxOverlayId").onclick=function(){if($("deleteCommentBox").style.display=="block"){focusElement("deleteCommentBox")}else{focusElement("editCommentBox")}}}var G=document.getElementsByName("closeBox");for(var H=0;H<G.length;H++){G[H].onclick=function(){if($("deleteCommentBox").style.display=="block"){focusElement("deleteCommentBox")}else{focusElement("editCommentBox")}}}}assignAjaxHandlers();