// Disable Select

function noSelect() {
	// define content area in which specified elements should have selection disabled
	var section = document.getElementById("centercontent");
	// define array of page elements that need selection disabled on them
	// (will override onmousedown/onmouseup so only use on items that don't rely on these handlers)
	var elements = ["p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "dl", "table", "a", "img", "address", "pre"];
	for (h=0; h<elements.length; h++) {
		var currentElement = section.getElementsByTagName(elements[h]);
		for (var i=0; i<currentElement.length; i++) {
			var e = currentElement[i];
			// Mozilla
			e.style.MozUserSelect = "none";
			e.style.KhtmlUserSelect = "none";
			e.style.UserSelect = "none";
			// IE
			e.onselectstart = new Function ("return false")
			e.ondragstart = new Function ("return false")
			// Netscape
			e.onmousedown="return false"
			e.onmouseup="return true"
		}
	}
}

//------------------------------------------------------------------------------------------------------
// Escape from frames

function frameEscape()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}
//------------------------------------------------------------------------------------------------------
// AutoBlink

// Puts Google's Autolink on the Blink :)
// (c) 2005 Chris Ridings   http://www.searchguild.com
// Redistribute at will but leave this message intact
// -
// 5th March - Implemented speed enhancement suggested by the guy who wrote
// http://www.dougaltoolbar.com/
// -
// 5th March - Added additional elements to reduce machine load
// 5th March - Added option to not remove links but to 
// rewrite ISBN links as amazon affiliate links!
// Fill in the following
// if you wish to do this. e.g.  var amazonaffiliate="goodlookingco-20"
// Leave as is to remove links in the normal way
var amazonaffiliate="consoledataba-20";

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);
}

//------------------------------------------------------------------------------------------------------
// Load Handlers

if (document.all&&window.attachEvent) {
	// IE-Win 
	window.attachEvent("onload", noSelect);
	window.attachEvent("onload", frameEscape);
	
} else if (window.addEventListener) {
	// Gecko, Safari, Konqueror and Standard
	window.addEventListener("load", noSelect, false);
	window.addEventListener("load", frameEscape, false);
	
} else if (document.addEventListener) {
	// Opera 7
	document.addEventListener("load", noSelect, false);
	document.addEventListener("load", frameEscape, false);
	
} else {
	// IE-Mac
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			noSelect();
			frameEscape();
		}
	} else {
		window.onload = function() {
			noSelect();
			frameEscape();
		}
	}
}
