// open window function
function openWindow(url, name, x, y, width, height, params) {
	if (name != null) name = name.replace(/ /g,"");
	if (!isNaN(x) && x > 0) params += ",left=" + x;
	if (!isNaN(y) && y > 0) params += ",top=" + y;
	if (!isNaN(width) && width > 0) params += ",width=" + width;
	if (!isNaN(height) && height > 0) params += ",height=" + height;
	if (params != null && params.charAt(0) == ",") params = params.substring(1);
	var win = window.open(url, name, params);
	if (win) win.focus();
}

function handleWindow(destUrl, doOpener, doClose, doFocus, name, x, y, width, height, params) {
 if (doOpener != null && doOpener == "1") {
 // URL in opener - at least IE does not set opener to null if closed
 if ((top.opener != null) && (typeof top.opener.closed == 'boolean') && (top.opener.closed == false)) {
 top.opener.location.href = destUrl;
 if (doFocus != null && doFocus == "1") {
 top.opener.focus();
 }
 if (doClose != null && doClose == "1") {
 top.close();
 }
 }
 else {
 openWindow(destUrl);
 if (doClose != null && doClose == "1") {
 top.close();
 } // ignore doFocus
 }
 }
 else {
 // URL in this window or new window
 if (name != null || params != null) {
 openWindow(destUrl, name, x, y, width, height, params);
 if (doClose != null && doClose == "1") {
 top.close();
 } // ignore doFocus
 }
 else {
 window.location.href = destUrl; // ignore doClose + doFocus
 }
 }
}