/*
Accessible links which opens the target in a new browser window [modified].

The original script and more information is available on:
http://www.456bereastreet.com/archive/200605/opening_new_windows_with_javascript_version_11/
*/

var newWindowClassName = "newWindow";

/*
Create the new window
*/
function openInNewWindow(e) {
	var event;
	if (!e) event = window.event;
	else event = e;
	// Abort if a modifier key is pressed
	if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) {
		return true;
	}
	else {
		// Change "_blank" to something like "newWindow" to load all links in the same new window
	    var newWindow = window.open(this.getAttribute('href'), '_blank');
		if (newWindow) {
			if (newWindow.focus) {
				newWindow.focus();
			}
			return false;
		}
		return true;
	}
}

/*
Adds the openInNewWindow function to the onclick event of links with a class name of newWindowClassName
*/
function getNewWindowLinks() {
	// Check that the browser is DOM compliant
	if (document.getElementById && document.createElement && document.appendChild) {
		// Find all links
		var links = document.getElementsByTagName('a');
		var link;
		for (var i = 0; i < links.length; i++) {
			link = links[i];
			// Find all links with a class name of newWindowClassName (defined above)
			if (link.className == newWindowClassName) {
				link.onclick = openInNewWindow;
			}
		}
	}
}

// Register the getNewWindowLinks function to run on page load
addEvent(window, 'load', getNewWindowLinks);