/*
 * External links
 * Runs through all links on a page looking for rel="external" and hijacks 
 * the default function to open a new window with javascript
 **/
var externalLinks = {

	// All links on the page 
	allLinks: null,

	// Find all links with rel="external" and add an onclick event - requires addEvent
	init: function() {
		if (!document.getElementsByTagName) return;
		this.allLinks = document.getElementsByTagName('a');
		for (var i=0; i<this.allLinks.length; i++) {
			if (this.allLinks[i].getAttribute('rel')==='external') {
				addEvent(this.allLinks[i], 'click', this.launchLink);
			}
		}
	},

	// onclick event handler for rel="external" links. Bypasses the default action and opens a new window
	launchLink: function(e) {
		var externalWindow = window.open(this.href);
		externalWindow.focus();
		if (e.preventDefault) {
			e.preventDefault();
        } else {
			e.returnValue = false;
		}
	}

}

// Initiate
externalLinks.init();