/*
 * 同じウインドウからG-BOOKビューアを呼び出す
 */
function ContentsOpen(id) {
	contentsOpenCommon(top, "id", id);
}

/*
 * 別ウインドウからG-BOOKビューア呼び出し
 */
function ContentsOpenOtherWindow(id) {
	contentsOpenCommon(window.opener.top, "id", id);
	window.close();
}

/*
 * G-BOOKビューア呼び出し(URL指定)
 */
function ContentsOpenUrl(url) {
	contentsOpenCommon(top, "url", url);
}

/*
 * 別ウインドウからG-BOOKビューア呼び出し(URL指定)
 */
function ContentsOpenUrlOtherWindow(url) {
	contentsOpenCommon(window.opener.top, "url", url);
	window.close();
}

//function contentsOpenOtherWindowSelectCar(id, select) {
//	window.close();
//	window.opener.top.location.href = "/pc/members/myshortcut/ShortcutAll.asp?id=" + id + "&select=" + select;
//}


function contentsOpenCommon(topPos, key, value) {
	var i;
	var check;

//	window.close();

	check = false;
	for (i = 0; i < topPos.document.all.length; i++) {
		if ("usersite_main" == topPos.document.all(i).name) {
			check = true;
			break;
		}
	}
	if (!check) {
		targetLocation(topPos, key, 0, value);
		return;
	}

	check = false;
	for (i = 0; i < topPos.usersite_main.document.all.length; i++) {
		if ("viewer" == topPos.usersite_main.document.all(i).name) {
			check = true;
			break;
		}
	}
	if (!check) {
		targetLocation(topPos, key, 1, value);
	}
	else {
		targetLocation(topPos, key, 2, value);
	}
}

function targetLocation(topPos, key, mode, value) {
	switch(mode) {
		case 1:
			topPos.usersite_main.location.href = "/pc/members/myshortcut/ShortcutOut.asp?" + key + "=" + value;
			topPos.location.hash="top";
			break;
		case 2:
			topPos.usersite_main.viewer.location.href = "/pc/members/myshortcut/ShortcutIn.asp?" + key + "=" + value;
			topPos.location.hash="top";
			break;
		default:
			topPos.location.href = "/alpha/members/LoginAuth.aspx?" + key + "=" + value;
			break;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var ret;
  ret = window.open(theURL,winName,features);
  ret.focus();
}

function MM_openBrWindow_E(theURL,winName,features) { //v2.0
  var ret;
  ret = window.open(theURL,winName,features);
	x = (screen.width  - 535) / 2;
	y = (screen.height - 530) / 2;
	ret.moveTo(x,y);

  ret.focus();
}

function MM_openBrWindow_P(theURL,winName,features) { //v2.0
  var ret;
  ret = window.open(theURL,winName,features);
	x = (screen.width  - 800) / 2;
	y = (screen.height - 530) / 2;
	ret.moveTo(x,y);

  ret.focus();
}


//function ContentsOpen(id){
//	top.document.location.href = "/alpha/members/LoginAuth.aspx?id=" + id;
//}


// 旧ホロスコープ・旧天気のみで使用。コメントアウト。
//function ContentsOpenP(id,host){
//	sx = screen.width; 
//	sy = screen.height; 
//	x = (sx - 405) / 2; 
//	y = (sy - 298) / 2; 
//	var func = host + "/pc/members/myshortcut/shortcut.asp?id=" + id;
//	password=window.open(func,"viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=405,height=298,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
//	password.focus();
//}

// Gクルーズのみで使用。破棄。
//function ContentsOpenPOtherWindow(id,host){
//	sx = screen.width; 
//	sy = screen.height; 
//	x = (sx - 405) / 2; 
//	y = (sy - 298) / 2; 
//	var func = host + "/pc/members/myshortcut/shortcut.asp?id=" + id;
//	window.name="GbookOpenerOtherWindow";
//	password=window.open(func,"viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=405,height=298,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
//	password.focus();
//}

//function shortcutwindowopen(url){
//	if(url != ""){
//		sx = screen.width; 
//		sy = screen.height; 
//		x = (sx - 405) / 2; 
//		y = (sy - 298) / 2; 
//		var func = "/pc/members/myshortcut/shortcut.asp?url=" + url;
//		password=window.open(func,"viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=405,height=298,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
//		password.focus();
//	}
//}

//members\myshortcut\m_top_9.incで使用？→m_top_9.incが未使用破棄
//function shortcutwindowopenP(url,host){
//	if(url != ""){
//		sx = screen.width; 
//		sy = screen.height; 
//		x = (sx - 405) / 2; 
//		y = (sy - 298) / 2; 
//		var func = host + "/pc/members/myshortcut/shortcut.asp?url=" + url;
//		password=window.open(func,"viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=405,height=298,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
//		password.focus();
//	}
//}

//function WinOpen7()
//{
//	sub = window.open("./simulation/","window1","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=557,height=422");
//	x = (screen.width  - 557) / 2;
//	y = (screen.height - 422) / 2;
//	sub.moveTo(x,y);
//}

// 旧バージョンの認証処理。不要
function idPass(func){
	sx = screen.width; 
	sy = screen.height; 
	x = (sx - 320) / 2; 
	y = (sy - 255) / 2; 
	password=window.open(func,"password","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=320,height=255,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
	password.focus();
}

//function contents(){
//sx = screen.width; 
//sy = screen.height; 
//x = (sx - 405) / 2; 
//y = (sy - 298) / 2; 
//password=window.open("/pc/viewer/frame.asp","viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=405,height=298,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
//password.focus();
//}

//function contentsP(func){
//sx = screen.width; 
//sy = screen.height; 
//x = (sx - 405) / 2; 
//y = (sy - 298) / 2; 
//password=window.open(func,"viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=405,height=298,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
//password.focus();
//}

//function LinkSelect(form, sel){
//c = sel.selectedIndex;
//adrs = sel.options[c].value;
//if (adrs != "-" ){
//LinkWin=window.open("","_top");
//LinkWin.location.href=adrs;
//}
//}

//function contents2(){
//sx = screen.width; 
//sy = screen.height; 
//x = (sx - 405) / 2; 
//y = (sy - 298) / 2; 
//password=window.open("/pc/viewer/frame.asp","viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=405,height=298,dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
//password.focus();
//}

	//ヒストリーバック時の不具合に対応
function openUsersite(target){
	top.document.all("usersite_main").src=target+"?back=2";
}

/*
 * 別ウインドウを開く 2004.3.17 ideaSync
 */
function popWin(loc, w, h) {
	if (!w) w = 650;
	if (w > screen.availWidth - 16) w = screen.availWidth - 16;
	if (!h) h = 750;
	if (h > screen.availHeight - 96) h = screen.availHeight - 96;
	l = screen.availWidth / 2 - w / 2 - 8;
	t = screen.availHeight / 2 - h / 2 - 24;
	newWin = window.open(loc, 'window' + (new Date()).getTime(), 'left=' + l + ',top=' + t + ',width=' + w + ',height=' + h + ',toolbar=no,location=no,directoryies=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no');
	return false;
}

/*
 * 既にウィンドウが開いているか判断、開いていなければ新規ウィンドウで開く
 * 開いていればフォーカスを移す。
 */
function wopen(wurl,wn,feat){
	if (wn == "") {
		//opener.focus();
	} else {
		var w = window.open('',wn,feat);
		if (w.location.href == "about:blank") {
			window.open(wurl,wn,feat);
		}else{
			w.focus();
		}
	}
}

function MM_openBrWindow_M(theURL,winName,features) { //v2.0
  var ret;
  sx = screen.width; 
  sy = screen.height; 
  x = 0; 
  y = 0; 
  ret = window.open(theURL,winName,features + ",dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);

  ret.focus();
}
