
_popup_firstload = true;

function process_opener_links () {
	if (_popup_firstload == false) { return; }
	_popup_firstload = false;
	if (!window.opener) { return; }
	var l = document.getElementsByTagName('a');
	for (var i = 0; i < l.length; i++) {
		if (l[i].target) { continue; }
		l[i].onclick = function() {
			link_opener(this);
			return false;
		}
	}
}

function link_opener ( obj ) {
	if (window.opener && !window.opener.closed) {
		if (confirm('Navigating to the selected page will close this popup window.\nAre you sure you want to continue?')) {
			window.opener.document.location = obj.href;
			window.close();
			window.opener.focus();
		}
	} else {
		document.location = obj.href;
	}
}

window.addEvent('domready', function(){
	process_opener_links();
});
add_load_event(process_opener_links);


