﻿function newWindow(url) {
		window.open(url, null,"");
}

function confirmExit(url) {
	var retString = "You are about to leave the website" + '\n\n' + "Are you sure you wish to do so?";
	var answer = confirm (retString);
	if (answer) {
		window.open(url, null,"");
	}
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.setAttribute("href", "javascript:newWindow('" + anchor.getAttribute("href") + "');" );
			//anchor.setAttribute("href", "javascript:confirmExit('" + anchor.getAttribute("href") + "');" );
		}
		//anchor.title += anchor.title ? " (Opens in a new window)" : "Opens in a new window";

	}
}

window.onload = externalLinks;
