
BSP = {
	externalAsk: function(h) {
		var ol = document.createElement('div');
		ol.id = 'overlay';
		ol.innerHTML = '<div id="overlay-alpha" onclick="document.body.removeChild(document.getElementById(\'overlay\')); return true;"></div><div id="overlay-ask"><h1>Link to Third Party Web Site</h1><p>You are leaving the Bank Sale Properties/Aliant Bank Web Site and are being directed to a third party website. Do you wish to continue?</p><ul><li><a href="' + h + '" class="no-ask" target="_blank" onclick="document.body.removeChild(document.getElementById(\'overlay\')); return true;">Yes, third party site will open in a new window</a></li><li><a href="#" onclick="document.body.removeChild(document.getElementById(\'overlay\')); return false;">No, return to Bank Sale Properties home page</a></li></ul></div>';
		document.body.appendChild(ol);
	},
	external: function(e) {
		e = e || event;
		var t = e.target || e.srcElement;
		if(t.nodeName.toLowerCase() != 'a') {
			while(t != document.body && t.nodeName.toLowerCase() != 'a') {
				t = t.parentNode;
			}
		}
		if(t.nodeName.toLowerCase() != 'a') {
			return;
		}
		if(!t.href.match(/^https?:\/\/banksaleproperties.com/) && !t.href.match(/^https?:\/\/.*?.banksaleproperties.com/) && !t.href.match(/^http:\/\/maps.google.com/) && !t.href.match(/^mailto/) && t.className.indexOf('no-ask') == -1) {
			BSP.externalAsk(t.href);
			e.returnValue = false;
			if(e.preventDefault) {
				e.preventDefault();
			}
		}
	},
	init: function() {
		if(window.addEventListener) {
			document.body.addEventListener('click', BSP.external, null);
		} else {
			document.body.attachEvent('onclick', BSP.external);
		}
	}
};

BSP.init();
