/*
   AutoBlink - Puts Google's Autolink on the Blink :)
   (c) 2005 Chris Ridings   http://www.searchguild.com
   Redistribute at will but leave this message intact

   -
   AutoBlink will disable Googe's Autolink feature,
   keeping web site visitors on your web site instead
   of letting them leave through Google Created Links.
   
   Alternatively, if you have an Amazon.com Affiliate
   Id, enter it below and AutoBlink will rewrite the
   Google created links to include YOUR Amazon Affiliate
   Id instead of Google's, so even if people then leave
   your web site, it'll be through Your Affiliate Id
   and you'll earn commissions from their shopping.

   Simply leave the "amazonaffiliate" value blank if you
   want AutoBlink to simply disable the Google Autolinks.

*/

// Enter your Amazon Affiliate Id here:
var amazonaffiliate="diamondresour-20";


/* --------------------------------------------------------- */
/* -------------- DO NOT EDIT BELOW THIS LINE -------------- */
/* --------------------------------------------------------- */
var linkcount;
function checklinks() {
	if (!(linkcount==document.links.length)) {
		// Something changed the links!
		// Iterate for an id of _goog
		for (i=0; i < document.links.length; i++) {
			if (document.links[i].id.substring(0,5)=="_goog") {
				// If we find an id of _goog then do something
				if (amazonaffiliate=="") { 
					// No affiliate id defined so remove the links
					var tr = document.links[i].parentTextEdit.createTextRange();
					tr.moveToElementText(document.links[i]);
					tr.execCommand("Unlink",false);
					tr.execCommand("Unselect",false);
					i--;
				} else {
					// An affiliate id defined so rewrite ISBN links
					if (document.links[i].href.indexOf("isbn")>0) {
						var isbn=document.links[i].href.substring(document.links[i].href.indexOf("text")+5,document.links[i].href.length);
						document.links[i].href="http://www.amazon.com/exec/obidos/external-search?search-type=ss&tag=" + amazonaffiliate + "&keyword=" + isbn + "&index=books";
					}
				}
			}
		}
	}
		linkcount = document.links.length;
		setTimeout("checklinks()",500);
}
if (document.getElementById && document.createElement) {
	linkcount=document.links.length;
	setTimeout("checklinks()",500);
}

