/**
 *  !!!REQUIRES ADDLOADEVENT FUNCTION!!!
 */

/**
 * Open links in new windows using XHTML standards compliant markup.
 * This version of the function considers elements on the local domain to not
 * be external no matter what rel is set to and they will not open in a new 
 * window.
 */
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	var hostRegEx = new RegExp(window.location.hostname);
	var jsRegEx = new RegExp("java");
	
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			if (!hostRegEx.test(anchor.href)) anchor.target = "_blank";
			if (jsRegEx.test(anchor.href)) anchor.target = "_top";
		}
	}
}

// Load the link-fixer
addLoadEvent(externalLinks); 
