    function initPopup() {

        window.blur();

        if (!document.all) {
            window.sizeToContent();
            window.sizeToContent(); // for reasons beyond understanding,
                        // only if we call it twice we get the
                        // correct size.
//            window.addEventListener("unload", myclose, true);
            // center on parent
            var px1 = opener.screenX;
            var px2 = opener.screenX + opener.outerWidth;
            var py1 = opener.screenY;
            var py2 = opener.screenY + opener.outerHeight;
            var x = (px2 - px1 - window.outerWidth) / 2;
            var y = (py2 - py1 - window.outerHeight) / 2;
            window.moveTo(x, y);
            var body = document.body;
            window.innerHeight = body.offsetHeight;
            window.innerWidth = body.offsetWidth;

        } else {

            var body = document.body;
            var contentblock = document.getElementById('contentblock');

            var winW = body.clientWidth;
            var winH = body.clientHeight;

            var popW = contentblock.clientWidth + 29;
            var popH = contentblock.clientHeight + 38;

            if (popW > window.screen.width) {
                popW = window.screen.width - 75;
            }

            if (popH > window.screen.height) {
                popH = window.screen.height - 75;
            }

            var leftPos = (window.screen.width - popW) / 2;
            var topPos = (window.screen.height - popH) / 2;

            window.resizeTo(popW + 10, popH + 40);
            if (window.screenLeft < 10 && window.screenLeft > 0) {
                window.moveTo(leftPos, topPos);
            }

        }

        window.focus();

    };

function showPopup(url, resizable, windowname) {
    if (! resizable) {
        resizable='yes';
    }
    if (! windowname) {
        windowname='dialog_window';
    }
    var body = window.document.body;
    window.open(url, windowname, 'toolbar=no,location=no,directories=no,status=yes,menubar=no, scrollbars=yes,resizable=' + resizable + ',width=' + body.clientWidth + ',height=' + body.clientHeight + ',left=0,top=0');
}

function closePopup(url) {

	if (url != null) {
		window.location = url;
	}

	window.close();

}