/*

Modular website, open links with rel="external" tag in a new window
Script should be placed in the head tag of the desired document(s)

*/

function externalLinks() {
	if (!document.getElementsByTagName) {
		/* Old browsers - IE4, Netscape 4 that don't support Document Object Model 1.0 */
		/*   Note: Pages opened in the same window, not big loss really */
		return;
	}
	
	/* Each element in the array will represent an <a> tag in the document */
	var anchors = document.getElementsByTagName("a");
	
	for (var i=0; i<anchors.length; i++) {
		/* Isolate the tag with which we are currently concerned */
		var anchor = anchors[i];
		
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			/* New-window link successfully found */
			anchor.target = "_blank";
		}
	}
}

/* Used without a global onload hander - see init.js */
/* window.onload = externalLinks; */