$(document).ready( evReady );

function evReady() {
	//$("a[href^='http']").unbind().click( evClickExternal );
	//displayExternal();

	jQuery("a[target='int']").click(clickExternalPopup);
	jQuery("a[target='int_same']").click(clickExternal);
}

function evClickExternal( objSource ) {
	if( $(this).attr("href") != 'https://www2.netteller.com/beaconfederal' ) {
		objSource.preventDefault();
		document.location.href = cp + '/leaving-site.html?r=' + $(this).attr("href");
	}
}

function clickExternal() {
	var message = "You are about to leave the site. Please confirm that you want to continue to the URL below.\n\n" +
	this.href;

	//return window.confirm(message);
	if(window.confirm(message)) {
		document.location.href = this.href;
	}

	return false;
}


function clickExternalPopup() {
	var message = "You are about to leave the site. Please confirm that you want to continue to the URL below.\n\n" +
	this.href;

	if(window.confirm(message)) {
		this.target = "_blank";

		return true;
	}

	return false;
//return window.confirm(message);
}



function displayExternal() {

	var addr = $("span.externalAddress");
	
	if( addr.length > 0 ) {
		var href = getHref();
		addr.html( "<b>" + href + "</b>" );
		$("a.externalConfirm").click( function(obj) {
			obj.preventDefault();
			document.location.href=href;
			return false;
		} );
	}
}

function getHref() {
	var qs = document.location.search;
	if( qs != null && qs != "" ) {
		return (qs.split("?r=")[1]).replace("<", "&lt;").replace(">", "&gt;");
	}
	
	return "#";
}
