// CONFIGURABLE POPUP WINDOW
function popup(strUrl, iWidth, iHeight, iLeft, iTop, blnCenter, strName, strScroll, strMenus, strTools, strResize, strLocate)
{
	if ( blnCenter )
	{
		iLeft = (screen.width - iWidth) / 2;
		iTop = (screen.height - iHeight) / 2;
	}
	
	var winprops = 	"location=" + strLocate + ",scrollbars=" + strScroll + ",menubar=" + strMenus + ",toolbar=" + strTools + ",resizable=" + strResize + ",left=" + iLeft + ",top=" + iTop + ",width=" + iWidth + ",height=" + iHeight;		

	var popup = window.open(strUrl,strName,winprops);
	popup.focus();
}

// EXTERNAL LINKS HANDLER
function confirmExit(url) {
	var retString = "You have selected an external link and are now leaving the secure website of Risk Management Partners, Inc." + '\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;

// EMAIL LINKS HANDLER
// Open status message onclick event for email addresses,
// if user clicks "Confirm", then proceed to email.
function confirmExit(url) {
	var retString = "Please realize contacting the agency via email is not secure and is not encrypted." + '\n\n' + "Please do not send account numbers, social security numbers, passwords or other sensitive information via email.  If you need to discuss something of a private nature, please call us at (507) 793-2335. Thank you." + '\n\n' + "To proceed with sending your email, please click 'Ok'.";
	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") == "email") {
			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;
