function clearPopup() {
	var popupObj = document.getElementById('popup');
	var msgObj = document.getElementById('popupmsg');
	var buttonOkObj = document.getElementById('popupok');

	if ( popupObj && msgObj && buttonOkObj ) {
		popupObj.style.display = 'none';
		msgObj.style.display = 'none';
		buttonOkObj.style.display = 'none';
	}
}

function doPopup(msgtext, oktext) {
	var popupObj = document.getElementById('popup');
	var msgObj = document.getElementById('popupmsg');
	var buttonOkObj = document.getElementById('popupok');

	if ( popupObj && msgObj && buttonOkObj ) {
		if ( typeof msgtext == 'string' ) {
			msgObj.innerHTML = msgtext;

			if ( typeof oktext == 'string' ) {
				buttonOkObj.innerHTML = oktext;
				buttonOkObj.style.display = 'block';
			} else {
				buttonOkObj.style.display = 'none';
			}

			popupObj.style.display = 'block';
			msgObj.style.display = 'block';

			buttonOkObj.onclick = clearPopup;
		}
	}
}

function initPopup() {
	var anchors = document.getElementsByTagName('a');

	window.onunload = clearPopup;
	for ( var i = 0; i < anchors.length; i++ ) {
		if ( anchors[i].className == 'report' ) {
				anchors[i].onclick = function () {
					doPopup('Running report.  Please wait...');
				};
		}
	}
}
