/**
 * 打开新窗口
 * @ mode : 窗口模式（normal, dialogbox, fullscreen）
 */
function openWindow(url, name, mode, width, height, topSpace, leftSpace, scrolls, resizable) {
	if (url == null || name == null) return;
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	var parameter = "";
	switch (mode) {
		case "normal" :
			parameter = "channelmode, width=" + (width || screenWidth) + ", height=" + (height || screenHeight) + ", "
					+ "top=" + (topSpace || "0") + ", left=" + (leftSpace || "0") + ", "
					+ "screenx=" + (topSpace || "0") + ", screeny=" + (leftSpace || "0") + ", "
					+ "menubar=yes, location=yes, toolbar=yes, scrollbars=yes, resizable=yes, status=yes";
			break;
		case "dialogbox" :
			var dialogBoxWidth = width || screenWidth;
			var dialogBoxHeight = height || screenHeight;
			var dialogBoxTop = parseInt((screenHeight - dialogBoxHeight)/2);
			var dialogBoxLeft = parseInt((screenWidth - dialogBoxWidth)/2);
			parameter = "width=" + dialogBoxWidth + ", height=" + dialogBoxHeight + ", "
					+ "top=" + (topSpace || dialogBoxTop) + ", left=" + (leftSpace || dialogBoxLeft) + ", "
					+ "screenx=" + (topSpace || dialogBoxTop) + ", screeny=" + (leftSpace || dialogBoxLeft) + ", "
					+ "menubar=no, location=no, toolbar=no, scrollbars=" + (scrolls || "no") + ", resizable=" + (resizable || "no") + ", status=no";
			break;
		case "window" :
			if (isIE) //IE special
				parameter = "channelmode, ";
			else
				parameter = "width=" + screenWidth + ", height=" + screenHeight + ", ";
			parameter += "top=0, left=0, screenx=0, screeny=0, menubar=no, location=no, toolbar=no, scrollbars=no, resizable=yes, status=yes";
			break;
		default :
			parameter = "width=" + (width || screenWidth) + ", height=" + (height || screenHeight) + ", "
					+ "top=" + (topSpace || "0") + ", left=" + (leftSpace || "0") + ", "
					+ "screenx=" + (topSpace || "0") + ", screeny=" + (leftSpace || "0") + ", "
					+ "menubar=yes, location=yes, toolbar=yes, scrollbars=yes, resizable=yes, status=yes";
	}
	var newWindow = window.open(url, name, parameter);
	if (!window.childWindow || !(window.childWindow instanceof Array)) {
		window.childWindow = new Array();
	}
	window.childWindow.push(newWindow);
	return newWindow;
}

//关闭子窗口
window.closeChild = function() {
	if (window.childWindow) {
		for (var i = 0; i < window.childWindow.length; i++) {
			if (!window.childWindow[i].closed) {
				if (!window.childWindow[i].hold) {
					try {
						window.childWindow[i].close();
					} catch (ex) {}
				}
			}
		}
	}
}
