/* navigation */ var nextURL; var prevURL; function detectKeyPress(){ document.onkeypress = function(e){ var evt = window.event || e; var key = evt.keyCode.toString(); switch(key){ case "37": gotoURL(prevURL); break; case "39": gotoURL(nextURL); break; } }; } function gotoURL(url){ window.location.href = url; } /* comments.js */ function show_section(secID){ var sect = document.getElementById(secID); var clas = sect.className; clas = clas.replace('hidden', 'visible' ); sect.className = clas; } function hide_section(secID){ var sect = document.getElementById(secID); var clas = sect.className; clas = clas.replace('visible', 'hidden' ); sect.className = clas; } function toggleCommentList(){ var elem = document.getElementById('comment_list'); var sh = document.getElementById('show_hide_comment'); var clas = elem.className; var visp = /comment_visible/gi; var hidp = /comment_hidden/gi; var vis = "comment_visible"; var hid = "comment_hidden"; var newC = vis; if(clas.match(visp)){ clas = hid; sh.innerHTML = "Comments"; newC = hid; } else { //if(clas.match(hidp)){ clas = vis; sh.innerHTML = "Comments"; newC = vis; } elem.className = clas; saveCommentSettings(newC); } function toggleReply(id){ var elem = document.getElementById(id); if(elem.style.display == 'block'){ elem.style.display = 'none'; } else { elem.style.display = 'block'; } } function submitComment(cid){ var nameElem = null; var emailElem = null; var textElem = null; var nameValid = false; var emailValid = false; var textValid = false; var msg = "There was a problem with your form:\n\n"; if(cid == -1){ nameElem = document.getElementById('comment_author'); emailElem = document.getElementById('comment_author_email'); textElem = document.getElementById('comment_text'); formElem = document.getElementById('comment_form_add'); } else { nameElem = document.getElementById('comment_author_' + cid); emailElem = document.getElementById('comment_author_email_' + cid); textElem = document.getElementById('comment_text_' + cid); formElem = document.getElementById('comment_form_block_' + cid); } if(nameElem.value.length > 1){ nameValid = true; } else { msg = msg + " This form requires a valid name.\n"; } if(textElem.value.length > 5){ textValid = true; } else { msg = msg + " This form requires a comment of more than 5 characters.\n"; } emailValid = validateEmail(emailElem); if(emailValid == false){ msg = msg + " This form requires a valid email address.\n"; } if(nameValid == true && emailValid == true && textValid == true){ if(textElem.value.length > 300){ alert("Wow " + nameElem.value + ", that's a long message. You should probably use the forum when posting something that size. In fact... We insist.."); } else { formElem.submit(); } } else { alert(msg); } } function validateEmail(email_id) { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var address = email_id.value; if(reg.test(address) == false) { return(false); } return(true); } function openQuote(id,quot){ ele = 'comment_reply_' + id; form = document.getElementById('comment_text_' + id); form.value = '[quote]' + quot + '[/quote]\n\n'; form.focus(); var elem = document.getElementById(ele); elem.style.display = 'block'; } function loadCommentSettings(){ var htMatch = /https?/gi; var urlString = document.location.href.toString(); var urlArray = urlString.split("#"); urlString = urlArray[0]; urlString = urlString.replace(htMatch,""); urlString = urlString.replace("://",""); urlString = urlString.replace(/\//g,"_"); urlString = urlString.replace(/\./g,"_"); urlString = urlString.replace(/\?/g,"_"); urlString = urlString.replace(/\=/g,"_"); urlString = urlString.replace(/\&/g,"_"); urlString += "Comments"; var start = document.cookie.indexOf(urlString + "="); if (start == -1){ return; } start += urlString.length+1; var end = document.cookie.lastIndexOf(";", start); if (end == -1){ end = document.cookie.length; } if (end < start){ end = document.cookie.length; } var visData = unescape(document.cookie.substring(start, end)); setCommentVis(visData); } function setCommentVis(clas){ var elem = document.getElementById('comment_list'); var sh = document.getElementById('show_hide_comment'); var vis = "comment_visible"; var hid = "comment_hidden"; if(clas == vis){ sh.innerHTML = "Comments"; } else if(clas == hid){ sh.innerHTML = "Comments"; } elem.className = clas; } function loadLoginSettings(){ var urlString = "CommentLogin="; var start = document.cookie.indexOf(urlString); if (start == -1){ return; } start += urlString.length; var end = document.cookie.indexOf(";", start); if (end == -1){ end = document.cookie.length; } var loginData = unescape(document.cookie.substring(start, end)); loginData = loginData.replace(/\,/gi, ';'); setCommentProfile(loginData); } function deleteAllCookies() { var cookies = document.cookie.split(";"); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf("="); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; } exit; } function saveVotedSettings(comm){ var today = new Date(); var expire = new Date(today.getTime() + 7 * 1000 * 60 * 60 * 24); var urlString = "CommentVoted="; var vote_list = new Array(); var start = document.cookie.indexOf(urlString); var end = start; if (end == -1){ end = document.cookie.length; } if (start > -1){ start += urlString.length; end = document.cookie.indexOf(";", start); if (end == -1){ end = document.cookie.length; } vote_list = document.cookie.substring(start,end).split("|"); } vote_list.push(comm); vote_list = sort_and_unique(vote_list); document.cookie = urlString + vote_list.join("|") + ";expires=" + expire.toGMTString(); } function loadVotedSettings(){ var urlString = "CommentVoted="; var vote_list = new Array(); var start = document.cookie.indexOf(urlString); if(start == -1){ return; } start += urlString.length; var end = document.cookie.indexOf(";", start); if (end == -1){ end = document.cookie.length; } vote_list = document.cookie.substring(start,end).split("|"); for(var v = 0; v< vote_list.length; v++){ turn_off_voting(vote_list[v]); } } function sort_and_unique( my_array ) { my_array.sort(); for ( var i = 1; i < my_array.length; i++ ) { if ( my_array[i] === my_array[ i - 1 ] ) { my_array.splice( i--, 1 ); } } return my_array; }; function saveLoginSettings(avatar, name, email){ var today = new Date(); var expire = new Date(today.getTime() + 7 * 1000 * 60 * 60 * 24); var urlString = "CommentLogin=avatar=" + avatar + ",name=" + name + ",email=" + email; document.cookie = urlString + ";expires=" + expire.toGMTString(); } function saveCommentSettings(vis){ var htMatch = /https?/gi; var urlString = document.location.href.toString(); var urlArray = urlString.split("#"); urlString = urlArray[0]; urlString = urlString.replace(htMatch,""); urlString = urlString.replace("://",""); urlString = urlString.replace(/\//g,"_"); urlString = urlString.replace(/\./g,"_"); urlString = urlString.replace(/\?/g,"_"); urlString = urlString.replace(/\=/g,"_"); urlString = urlString.replace(/\&/g,"_"); urlString += "Comments"; var today = new Date(); var expire = new Date(today.getTime() + 365 * 1000 * 60 * 60 * 24); document.cookie = urlString + "=" + vis + ";expires=" + expire.toGMTString(); } function commentOnLoad(){ loadCommentSettings(); } /* archive.js */ function switchArchivePage(pre, curr, tot){ for(var i = 0; i < tot; i++){ var elid = pre + i.toString(); var elem = document.getElementById(elid); if(elem){ var clas = elem.className; clas = clas.replace('visible', 'hidden' ); clas = clas.replace('active_pagination',''); elem.className = clas; } } var show = document.getElementById(pre + curr.toString()); var scla = show.className; scla = scla.replace('hidden', 'visible' ) + ' active_pagination'; show.className = scla; } /* alerts.js */ var seenAlerts = new Array(); function alertsOnLoad(){ loadAlertSettings(); } function loadAlertSettings(){ var urlString = "HideAlerts="; var start = document.cookie.indexOf(urlString); if (start == -1){ return; } start += urlString.length; var end = document.cookie.indexOf(";", start); if (end == -1){ end = document.cookie.length; } var alertData = unescape(document.cookie.substring(start, end)); hideSeenAlerts(alertData); } function hideSeenAlerts(alertString){ var alerts = alertString.split(","); for(var a = 0; a < alerts.length; a++){ hideAlert(alerts[a]); seenAlerts.push(alerts[a]); } } function hideAlert(alertID){ var sect = document.getElementById(alertID); var clas = sect.className; clas = clas.replace('visible', 'hidden' ); sect.className = clas; seenAlerts.push(alertID); saveSeenAlerts(); } function saveSeenAlerts(){ var arrs = uniqueArray(seenAlerts); seenAlerts = arrs; var urlString = "HideAlerts=" + escape(arrs.join(",")); var today = new Date(); var expire = new Date(today.getTime() + 7 * 1000 * 60 * 60 * 24); document.cookie = urlString + ";expires=" + expire.toGMTString(); } function uniqueArray(arr){ var u = {}, a = []; for(var i = 0, l = arr.length; i < l; ++i){ if(arr[i] in u) continue; a.push(arr[i]); u[arr[i]] = 1; } return a; } /* On Startup */ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-16392406-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); commentOnLoad();