/**
 * 指定したURLの画面を開く
 * @param winName
 * @param url
 * @param w width
 * @param h height
 */
function openWindow(winName, url, w, h) {

	x = (screen.width  - w) / 2;
	y = (screen.height - h) / 2;

	svname = window.location.hostname;
	winName += "_" + svname;
	while (winName.indexOf(".") != -1) {
		winName = winName.replace(".", "");
	}
	while (winName.indexOf("-") != -1) {
		winName = winName.replace("-", "");
	}
	while (winName.indexOf("%") != -1) {
		winName = winName.replace("%", "");
	}
	while (winName.indexOf(":") != -1) {
		winName = winName.replace(":", "");
	}
	while (winName.indexOf("/") != -1) {
		winName = winName.replace("/", "");
	}
	while (winName.indexOf("?") != -1) {
		winName = winName.replace("?", "");
	}
	while (winName.indexOf("=") != -1) {
		winName = winName.replace("=", "");
	}

	var option = "resizable=yes,scrollbars=yes,status=no,";
	option += "screenX=" + x + ",screenY=" + y + ",";
	option += "left=" + x + ",top=" + y + ",";
	option += "width=" + w + ",height=" + h;

	/*
	var newWin = window.open("", winName, option);
	if (newWin.location.href == "about:blank") {
		newWin.location.href = url;
	}
	*/
	// 2005/10/29
	// MacのブラウザSafariでは、ウィンドウ名なしのエラーとなるため、
	// 上記方法は使用できない。
	var newWin = window.open(url, winName, option);
	newWin.focus(); 

	return false;
}

/**
 * ウィンドウを閉じる
 */
function closeWindow() {
	var msg = "閉じてもよろしいですか？";
	if (confirm(msg)) {
		top.close();
	}
}
