// JavaScript Document

// Script to create target="_blank" tags for external links
// For this to work add the attribute rel="external" to all links that should open in a new window

// Script based on artical by Kevin Yank at http://www.sitepoint.com/article/standards-compliant-world

// check to make sure that we can get elements by tag name. If not then return without doing anything
// This script will only work in standards complient browsers (of course with JS on)
function ExternalLinks() {
	if (!document.getElementsByTagName) return;

	// get a list of all the anchors in the page
	var anchors = document.getElementsByTagName("a");
	
	// loop through anchors array to find links with out rel="external" attibute
	for (var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		
		// find only a tags with both an href and out rel="external" attributes
		if (anchor.getAttribute("href") &&
			anchor.getAttribute("rel") == "external") {
			
			// set the anchors target attribute
			anchor.target = "_blank";
		}
	}
}

window.onload = ExternalLinks;
