var okURL = new Array();
//okURL[next position in array] = Array(link,scope) ...scope = "all" for any site under url else "" for only url
okURL[okURL.length]=["50below.com","all"];
okURL[okURL.length]=["50belowinc.com","all"];
okURL[okURL.length]=["rbcdain.com","all"];
okURL[okURL.length]=["rbcfc.com","all"];
okURL[okURL.length]=["drconnect.com","all"];
okURL[okURL.length]=["m...google.com","all"];
okURL[okURL.length]=["rbcwm-usa.com","all"];
okURL[okURL.length]=["rbcwmconnect.com","all"];
okURL[okURL.length]=["rbc.com","all"];

//store the current domain into the OK list
var curURL = window.location.href;
var domainMatch = curURL.match(/http:..([^\/$]+)/i);

if(domainMatch && domainMatch.length > 1){
	okURL[okURL.length]=[domainMatch[1].replace(/www\./i,""),"all"];		
}

	
function CheckHref(TheLink) {
	for(var i=0; i < okURL.length; i++) {
		if(okURL[i][1].match(/all/i))
			myReg = new RegExp("^https?://[^\.]*."+okURL[i][0]+"|^https?://"+okURL[i][0]+"|^javascript|^mailto","i");
		else
			myReg = new RegExp("^https?://[^\.]*."+okURL[i][0]+"/?$|^https?://"+okURL[i][0]+"/?$|^javascript|^mailto","i");		
		if(TheLink.match(myReg)) return true;
	}
	return false;
}

var dom = (document.getElementsByTagName) ? true : false;
var ie5 = (document.getElementsByTagName && document.all) ? true : false;

function test(e) {	
	var tmp;
	if (ie5)
		tmp = event.srcElement;
	else if (dom)
		tmp = e.target;
	else return false;
	
	var TheLink = tmp.href	
	for(var run=0; run<10; run++){
		if(TheLink == null || tmp.src == TheLink){
			try{
			tmp = tmp.parentNode;			
			TheLink = tmp.href;
			}catch(e){
				return;
				//just let it go.
			}
		}
	}
		
	if(TheLink != null && TheLink !="" && !CheckHref(TheLink) )	{		 //to go to \" "+TheLink+" \"
		alert("You are leaving the RBC Wealth Management financial consultant website. \n\nThis link to a third party website is provided only as a convenience. The inclusion of this link is not an endorsement by RBC Wealth Management, implied or otherwise, of the linked site or any products or services offered through such site, and no information in the linked site has been endorsed or approved by RBC Wealth Management. The linked site is not under the control of RBC Wealth Management, and RBC Wealth Management is not responsible for the contents of such site or any link contained in the linked site. No information accessed through the linked site, or any link contained in the linked site, constitutes a recommendation, offer, or solicitation of an offer by RBC Wealth Management to buy, sell, or hold any security, financial product or instrument discussed therein.");
	}
	else{
		window.title = TheLink;
	}
}

document.onclick = test;