window.onload = initAll;window.onunload=function() {};function initAll() {   getElementByClass('rateup');   getElementByClass('ratedown');   getElementByPclass('rateit');   getElementByPclass('linkcolour');   tLinks();   //getElementByClassNav('newnav');   //getElementByClassNav('updatenav');   //getElementByClassNav('improvenav');}var alinkTags = new Array();function getElementByClass(theClass) {   var alinkTags=document.getElementsByTagName("a");   for (i=0; i<alinkTags.length; i++) {      // Get all tags with the specified class name      if (alinkTags[i].className=='rateup') {      // Place any code you want to apply to all pages with the class specified.      alinkTags[i].className='ratethisup';      alinkTags[i].onmousedown=toggleColourUp;      }      if (alinkTags[i].className=='ratedown') {      // Place any code you want to apply to all pages with the class specified.      alinkTags[i].className='ratethisdown';      alinkTags[i].onmousedown=toggleColourDown;      }      // Place any code you want to apply to all pages with the class specified.      if (alinkTags[i].className=='linkcolouralert') {         alinkTags[i].onclick=qAlert;      }   }}var alinkNav = new Array();function getElementByClassNav(theClass) {   var alinkTags=document.getElementsByTagName("a");   for (i=0; i<alinkTags.length; i++) {      if (alinkTags[i].className==theClass) {         var oldlink = alinkTags[i].innerHTML;         if (theClass=='newnav') {            var newlink = "&nbsp;&nbsp;<span class='newnavstyle'>New</span>";         }         if (theClass=='updatenav') {            var newlink = "&nbsp;&nbsp;<span class='newnavstyle'>Updated</span>";         }         if (theClass=='improvenav') {            var newlink = "&nbsp;&nbsp;<span class='newnavstyle'>Improved</span>";         }         alinkTags[i].innerHTML = oldlink + newlink;      }   }}var linkTags = new Array();function toggleColourUp() {   this.className='alreadypressed';   this.parentNode.className='clicked';   var commentid = this.parentNode.id;   setCookie(commentid);   readCookie();   var upordown = 'up';   commentCount(commentid,upordown);   // replace the button set just clicked (other buttons were replaced on pageload)   var comPara = this.parentNode;   nodeReplace(comPara);}function toggleColourDown() {   this.className='alreadypressed';   this.parentNode.className='clicked';   var commentid = this.parentNode.id;   setCookie(commentid);   readCookie();   var upordown = 'down';   commentCount(commentid,upordown);   // replace the button set just clicked (other buttons were replaced on pageload)   var comPara = this.parentNode;   nodeReplace(comPara);}function setCookie(theId) {   var expireDate = new Date();   expireDate.setMonth(expireDate.getMonth()+6);   document.cookie=theId+"=set;expires="+expireDate.toGMTString();}function readCookie() {   if (document.cookie !="") {   }}var pTags = new Array();function getElementByPclass(theClass) {   var pTags=document.getElementsByTagName("p");   for (i=0; i<pTags.length; i++) {      // Get all tags with the specified class name      if (pTags[i].className=='rateit') {         var comid = pTags[i].id;         var lastVisit = cookieVal(comid);         if (lastVisit=="set") {            var comPara = pTags[i];            nodeReplace(comPara);         }      }   }}function nodeReplace (thePara) {   // get rid of the a link buttons   if (thePara.hasChildNodes() ) {       while (thePara.childNodes.length >= 1 ) {          thePara.removeChild(thePara.firstChild );        }    }   // add a new + dummy button   var plusText = document.createTextNode("+");   var plusGraf = document.createElement("span");   plusGraf.className = "alreadypressed rightspace";   plusGraf.appendChild(plusText);   thePara.appendChild(plusGraf);   // add a new - dummy button   var minusText = document.createTextNode("\u2013");   var minusGraf = document.createElement("span");   minusGraf.className = "alreadypressed";   minusGraf.appendChild(minusText);   thePara.appendChild(minusGraf);}function cookieVal(cookieName) {   var thisCookie = document.cookie.split("; ");   for (var i=0; i<thisCookie.length; i++) {      if (cookieName == thisCookie[i].split("=")[0]) {         return thisCookie[i].split("=")[1];      }   }   return 0;}function commentCount(theCid,upOrDown){    var theCidTwo = theCid.substring(1);	var ajaxRequest;  // The variable that makes Ajax possible!		try{		// Opera 8.0+, Firefox, Safari		ajaxRequest = new XMLHttpRequest();	} catch (e){		// Internet Explorer Browsers		try{			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");		} catch (e) {			try{				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");			} catch (e){				alert("Browser error");				return false;			}		}	}	// Create a function that will receive data sent from the server - only used for error handling	ajaxRequest.onreadystatechange = function(){		if(ajaxRequest.readyState == 4){			document.getElementById("updatearea").innerHTML = ajaxRequest.responseText;		}	}	ajaxRequest.open("GET", "commentcount.php?commentid="+theCidTwo+"&maths="+upOrDown, true);	ajaxRequest.send(null); }function qAlert() {    alert("We ask for an email address to avoid spam comments being posted on the website. It will not be displayed online.\n\nIf your email is not recognised you will need to add your details to our free mailing list (although you can choose not to receive any newsletters) in order to post comments.");    return false;}function tLinks() {   var arr = document.getElementsByTagName("cite");   for (i = 0; i < arr.length; i++) {       var linkdisp = arr[i].innerHTML;       var linkref = arr[i].innerHTML;       if (linkref.length == 4){          arr[i].innerHTML = "<a href='../nav/news.php?id=" + linkref + "'>(CRN " + linkdisp + ")</a>";       }       if (linkref.length == 5){          arr[i].innerHTML = "<a href='../nav/commentarticle.php?id=" + linkref + "'>(MON " + linkdisp + ")</a>";       }   }} 
