﻿function confirmExit(url) {
	var retString = "You have selected an external link and are now leaving the secure website of Commercial Bank of Minnesota." + '\n\n' + "We provide links to other websites for the use of our visitors. Although we have reviewed the websites prior to creating the link, we are not responsible for the content, product or services provided by the sites." + '\n\n' + "Commercial Bank of Minnesota does not endorse, certify or control these external sites and does not guarantee the accuracy, completeness, efficiency, timeliness, or accurate sequencing of the information contained in them." + '\n\n' + "The privacy policy that these websites have may be different from the privacy policy of Commercial Bank of Minnesota.";
	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:confirmExit('" + anchor.getAttribute("href") + "');" );
			//anchor.onclick = confirmExit;
		}
		//anchor.title += anchor.title ? " (Opens in a new window)" : "Opens in a new window";

	}
}

window.onload = externalLinks;
