/* These functions adds a disclosure to all off site links */
var links;
var areas;			// Added as they use image maps extensively
var linkDisclosure = 	"You have clicked on a link to a third party web site. The linked site is not affiliated with United Financial Credit Union and may offer a different privacy policy and level of security. United Financial Credit Union is not responsible for and does not endorse, guarantee or monitor content, availability, viewpoints, products or services that are offered or expressed on other web sites.";

function addLinkDisclosure () {
	if(!document.getElementsByTagName || !document.domain) return false; // exit if we can't do it
	
	var offSite = new Array; 								// For our links that lead off site
	var domain = document.domain;							// The domain of the current document
	domain = domain.replace('www.', '');					// To make things consistant take out "www."
	var domainRegex = new RegExp(domain+"|mailto|cuanswers\.com|itsme247\.com|cuathome\.org|javascript", "i"); 	// Cuz vars in /regexes/ can be sticky
	links = document.getElementsByTagName('A'); 			// An array of all our page link objects
	areas = document.getElementsByTagName('area');

	//http://www.ufcuonline.com/asp/outside_link.php?to=http://www.carfax.com/cfm/purchase_options.cfm?partner=CNA_0&clickid=&siteid=

	for(var i=0; i<links.length; i++) {
		//if href is not null and not excluded and not containing outside_link.php
		if((links[i].href !="" && !links[i].href.match(domainRegex))  ||  links[i].href.search('outside_link') > 0 ) {
			offSite.push(links[i].href);
			links[i].target = "_blank";
			links[i].onclick = function () {
				return window.confirm(linkDisclosure);
			}
		}
	}

	for(var i=0; i<areas.length; i++) {
		if(!areas[i].href.match(domainRegex)) {
			areas[i].target = "_blank";
			areas[i].onclick = function () {
				return window.confirm(linkDisclosure);
			}
		}
	}
}

//window.onload=addLinkDisclosure; // Only one function to run so direct assignment is ok

