var forcereload = false; function loadComments(baseurl, page, comment) { var comments = document.getElementById("comment_container"); var xmlhttp = null; if (window.XMLHttpRequest) { var xmlhttp = new XMLHttpRequest(); } else { if (window.ActiveXObject) { var xmlhttp = new ActiveXObject('MSXML2.XMLHTTP'); } } if (xmlhttp && comments) { comments.innerHTML = "Loading comments..."; url = baseurl + page + "/"; if (comment && comment != 0) { url += "?comments_id=" + comment; forcereload = true; } xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { comments.innerHTML = xmlhttp.responseText; var countstore = document.getElementById("comment_count_storage"); var count = document.getElementById("comment_count"); if (countstore && count) { count.innerHTML = countstore.innerHTML; if (forcereload) { window.location.hash = "c" + comment; window.location.search = ''; } else if (window.location.hash != '') { window.location.hash = window.location.hash; } } } else { comments.innerHTML = ''; } } } xmlhttp.send(null); } else { comments.innerHTML = "Your browser does not support active comments."; } } function hideBlock(element) { element.style.visibility = "hidden"; element.style.display = "none"; } function showBlock(element) { element.style.visibility = "visible"; element.style.display = "block"; } function revealComment(element) { var comment = document.getElementById('ccr' + element); var warning = document.getElementById('cch' + element); if (comment && warning) { showBlock(comment); hideBlock(warning); } } function writeCommentCookie(action) { document.cookie = "hidecomments=" + encodeURIComponent(action) + "; path=/; max-age=" + (60 * 60 * 24 * 365) } function toggleLink() { var optout = document.getElementById('comment_optout'); var optin = document.getElementById('comment_optin'); var list = document.getElementById('comment_list'); var form = document.getElementById('comment_form'); if (optin.innerHTML == "Turn off") { hideBlock(list); if (form) { hideBlock(form); } optin.innerHTML = "Turn on"; writeCommentCookie("out"); return false; } else { showBlock(list); if (form) { showBlock(form); } optin.innerHTML = "Turn off"; writeCommentCookie("in"); return true; } }