// set your AFFILIATE IDs here. Leave blank any you do not have an account for. var arrAffiliates = { 'co.uk' : 'triciaschinesw07', 'com' : 'triciaschineswat', 'de' : 'triciaschines-21', 'fr' : 'triciaschin0e-21', 'ca' : 'triciaschin0f-20', 'jp' : 'triciaschines-22' } /** * search for any AMAZON product links and replace with a referral link to the user's local Amazon site * @author Pete Williams * @url http://petewilliams.info/blog/2009/07/javascript-amazon-associate-link-localiser/ */ function checkAmazonLinks() { // set required VARIABLES var strTld; var objRegexAsin = new RegExp( '\/([A-Z0-9]{10})' ); if ( typeof google != 'undefined' ) { var strCountry = google.loader.ClientLocation.address.country_code; } else { alert('You need to add the following code to your
section:\n'); return; } // get domain TLD from country code switch ( strCountry ) { case 'GB': case 'IE': strTld = 'co.uk'; break; case 'AT': strTld = 'de'; default: // by default, TLD is lowercase of country code. if no associate, then use .com strTld = ( arrAffiliates[strCountry.toLowerCase()] ? strCountry.toLowerCase() : 'com' ); break; } // get all LINKS var arrLinks = document.getElementsByTagName( 'a' ); // get appropriate aFFILIATE ID strAffiliateId = ( arrAffiliates[strTld] ? arrAffiliates[strTld] : arrAffiliatesSpares[strTld] ); // LOOP through for ( i=0; i