/g, ">"); } function replaceTagUrls(allLinks) { var refRefurl = new RegExp("^http://.*(amazon|endless|myhabit|amazonwireless|javari|smallparts)\.(com|ca|co\.jp|de|fr|co\.uk|cn|it|es)/.*tag=.*linkcode=", "i"); var pageUrl = (window.location != window.parent.location) ? document.referrer: document.location; for (var i=0; i < allLinks.length; i++) { var href = new String(allLinks[i].href); var results; var tag_match; var newUrl; if (results = href.match(refRefurl)) { newUrl = href + "&ref-refURL=" + encodeStr(pageUrl); href = newUrl; allLinks[i].href = href; } } } function replaceAllURLs() { var allAHrefLinks = document.getElementsByTagName('a'); var allAreaHrefLinks = document.getElementsByTagName('area'); replaceTagUrls(allAHrefLinks); replaceTagUrls(allAreaHrefLinks); } replaceAllURLs();