// highlight targeted id function highlight() { loc = window.location; loc = loc + ""; tstart = loc.indexOf("#"); if (tstart > -1) { targetId = loc.substring(tstart+1, loc.length); targetObj = document.getElementById(targetId); if (targetObj) { targetObj.className = "highlight"; } } } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function testCookies() { createCookie("test","ok",1); if (readCookie("test")) { return true; } else { return false; } } function getInnerHeight() { var y; if (self.innerHeight) // all except Explorer { y = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode { y = document.documentElement.clientHeight; } else if (document.body) // other Explorers { y = document.body.clientHeight; } return y; } function getInnerWidth() { var x; if (self.innerHeight) // all except Explorer { x = self.innerWidth; } else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode { x = document.documentElement.clientWidth; } else if (document.body) // other Explorers { x = document.body.clientWidth; } return x; } function getVertScroll() { var y; if (self.pageYOffset) // all except Explorer { y = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict { y = document.documentElement.scrollTop; } else if (document.body) // all other Explorers { y = document.body.scrollTop; } return y; } function getHorizScroll() { var x; if (self.pageYOffset) // all except Explorer { x = self.pageXOffset; } else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict { x = document.documentElement.scrollLeft; } else if (document.body) // all other Explorers { x = document.body.scrollLeft; } return x; } window.onload = function() { highlight(); initLinks(); } // Intercept Amazon links to set preferred store // URL components for the different affiliate schemes var amz_schemes = new Array("uk", "ca", "com"); var amz_affil = new Array(); amz_affil["uk"] = new Array(".co.uk", "jalfrezi-21", "UK and the rest of Europe"); amz_affil["ca"] = new Array(".ca", "clagnut0d-20", "Canada"); amz_affil["com"] = new Array(".com", "clagnut-20", "US and the rest of the world"); function initLinks() { // Test for cookies if (testCookies()) { // if cookies are enabled // Get existing store setting var amz_dest = readCookie("amz_dest"); var allLinks = document.getElementsByTagName('a'); for (var i=0; i < allLinks.length; i++) { // loop through all links on page var aLink = allLinks[i]; var url = aLink.href; var amzMatch = url.search(/amazon\./); if (amzMatch > -1) { // crude check for link to Amazon if (amz_dest) { // If store is set then rebuild link var country = amz_affil[amz_dest][0]; var affil = amz_affil[amz_dest][1]; // Change all possible urls to the desired country and affil for (var j=0; j