var popup_done   = false;

/*
function update_link()

Replaces all the OnClick event handers with a new one defined in the 
callback parameter. The new event handler will call the callback and
after executes the original OnClick event handler (if any).
*/

function update_links(callback, just_one) {

	just_one = (typeof just_one == "undefined") ? true : just_one;
	
	var links;
	if (document.all) {
		links = document.all.tags('a');
	} else if (document.getElementsByTagName) {
		links = document.getElementsByTagName('a');
	}
	
	if (links) {
		for(var i = 0; i < links.length; i++) {
			links[i].onclickold = links[i].onclick;
			links[i].onclick = function onclick() {
				if (!popup_done) {
					callback();
				}
				this.onclickold();
				popup_done = (just_one) ? true : popup_done;
			}
		}
	}
}
