function OpenWindow(url, width, height, target) {
	var left = (window.screen.width - width) / 2;
	var top = (window.screen.height - height) / 2;
	var options = 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no';
	window.open(url, target, options);
}

function OpenScrollWindow(url, width, height, target) {
	var left = (window.screen.width - width) / 2;
	var top = (window.screen.height - height) / 2;
	var options = 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes';
	window.open(url, target, options);
}

function ResizeDialogWindow(ctlFormWidth, ctlFormHeight, closeOnEscape) {
	_ResizeDialogWindow(ctlFormWidth, ctlFormHeight, 0, 0, closeOnEscape);
}

function ResizeDialogWindowWithMaxHeight(ctlFormWidth, ctlFormHeight, maxHeight, closeOnEscape) {
	_ResizeDialogWindow(ctlFormWidth, ctlFormHeight, 0, maxHeight, closeOnEscape);
}

function _ResizeDialogWindow(ctlFormWidth, ctlFormHeight, maxWidth, maxHeight, closeOnEscape) {
	var ctlFormWidth = document.getElementById(ctlFormWidth);
	var ctlFormHeight = document.getElementById(ctlFormHeight);
	var w = ctlFormWidth.offsetWidth;
	var h = ctlFormHeight.offsetHeight;
	if ((maxWidth > 0) && (w > maxWidth)) {w = maxWidth;}
	if ((maxHeight > 0) && (h > maxHeight)) {h = maxHeight;}
	if (w > window.screen.width) {w = window.screen.width - 60;}
	if (h > window.screen.height) {h = window.screen.height - 60;}
	window.resizeTo(w + 60, h + 60);
	if (closeOnEscape) {document.onkeypress = WindowKeyPress;}
}

function WindowKeyPress(e) {
	var key = Helper.UI.getKey(e);
    if (key == 27) {window.close(); return true;}
	return;
}

function CloseDialog() {
	if (window.opener) {window.opener.focus();} 
	window.close();
}