//ブラウザ判別
var browser;
if (navigator.appName.indexOf('Micr') != -1) {
	browser = 0;
} else {
	browser = 1;
}
var x = 0;			//x座標
var y = 0;			//y座標
var m_obj;			//メニューオブジェクト
var b_obj;			//元メニューオブジェクト
var menu_num = 6;	//メインメニューの個数(正しく設定しないとエラーが出ます)
var on_continue = 0;

//サブメニュー表示
function view_menu(m,b,f) {
	if (document.getElementById) {
		m_obj = document.getElementById(m);
		b_obj = document.getElementById(b);
		x = get_x(b_obj);
		y = get_y(b_obj);
		y += b_obj.offsetHeight;
		//以下が親メニューの座標に対するサブメニューの表示座標となるので、
		//ずれているような場合はここで微調整する。
		//---ズレ調節------------------
		y -= 2;
//		x += 9;
		//macIE用ズレ調整
		if (navigator.userAgent.toLowerCase().indexOf("mac") >= 0 && navigator.appName != "Netscape") {
			x += 4;
			y += 1;
		}
		//---ズレ調節・ここまで--------
		m_obj.style.left = x + "px";
		m_obj.style.top = y + "px";
		m_obj.style.zIndex = "1";
		m_obj.style.visibility = "visible";
	} else if (document.layers) {
		document.layers[m].visibility = "show";
		if (f == 1) {
			document.layers['sub0'].visibility = "show";
		}
	}
}
//サブメニュー消去
function delete_sub() {
	if (document.getElementById) {
		var sub_str;
		for (i=1;i<=menu_num;i++) {
			sub_str = "sub" + i;
			document.getElementById(sub_str).style.visibility = "hidden";
			document.getElementById(sub_str).style.zIndex = "0";
		}
	} else if (document.layers) {
		if (document.layers['sub0'].visibility != "show") {
			for (i=1;i<=menu_num;i++) {
				sub_str = "sub" + i;
				document.layers[sub_str].visibility = "hide";
			}
		}
	}
}
//メニューポジション(x軸)
function get_x(menu) {
	x = menu.offsetLeft;
	if (menu.offsetParent != null) {
		x += get_x(menu.offsetParent);
	}
	return x;
}
//メニューポジション(y軸)
function get_y(menu) {
	y = menu.offsetTop;
	if (menu.offsetParent != null) {
		y += get_y(menu.offsetParent);
	}
	return y;
}
//サブメニューの背景色変化
function bg_change(id,key) {
	if (document.getElementById) {
		obj = document.getElementById(id);
		if (key == 0) {
			obj.style.backgroundColor="#FF1105";
		} else if (key == 1) {
			obj.style.backgroundColor="#ffffff";
		} else if (key == 2) {
			obj.style.backgroundColor="#FFFF00";
		} else if (key == 3) {
			obj.style.backgroundColor="#4FC100";
		} else if (key == 4) {
			obj.style.backgroundColor="#0090FF";
		} else if (key == 5) {
			obj.style.backgroundColor="#FF8A00";
		} else if (key == 6) {
			obj.style.backgroundColor="#946EFF";
		} else if (key == 7) {
			obj.style.backgroundColor="#FFDCDA";
		} else if (key == 8) {
			obj.style.backgroundColor="#FFFFD9";
		} else if (key == 9) {
			obj.style.backgroundColor="#E5F6D9";
		} else if (key == 10) {
			obj.style.backgroundColor="#CCE9FF";
		} else if (key == 11) {
			obj.style.backgroundColor="#FFEED9";
		} else if (key == 12) {
			obj.style.backgroundColor="#E4DBFF";
		}
	} else if (document.layers) {
		if (key == 0) {
			document.layers[id].bgColor="#FF1105";
		} else if (key == 1) {
			document.layers[id].bgColor="#ffffff";
		} else if (key == 2) {
			document.layers[id].bgColor="#FFFF00";
		} else if (key == 3) {
			document.layers[id].bgColor="#4FC100";
		} else if (key == 4) {
			document.layers[id].bgColor="#0090FF";
		} else if (key == 5) {
			document.layers[id].bgColor="#FF8A00";
		} else if (key == 6) {
			document.layers[id].bgColor="#946EFF";
		} else if (key == 7) {
			document.layers[id].bgColor="#FFDCDA";
		} else if (key == 8) {
			document.layers[id].bgColor="#FFFFD9";
		} else if (key == 9) {
			document.layers[id].bgColor="#E5F6D9";
		} else if (key == 10) {
			document.layers[id].bgColor="#CCE9FF";
		} else if (key == 11) {
			document.layers[id].bgColor="#FFEED9";
		} else if (key == 12) {
			document.layers[id].bgColor="#E4DBFF";

		}
	}
}
//指定URLへジャンプ
function go_url(str) {
	location.href = str;
}

//POPUP用 2003/10/20
function subOpen(url,iheight){
	sc = "no";
	sx = screen.width; 
	sy = screen.height; 
	if(iheight >= 480 ){
		iheight = 480;
		sc = "yes";
	}
	x = (sx - 520) / 2; 
	y = ((sy - iheight) / 2) + 30; 
	subWindow = window.open(url,"sub","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+sc+",resizable=no,width=520,height="+iheight+",dependent=yes,left="+ x +",top="+ y + ",screenX="+ x +",screenY="+ y);
	subWindow.focus();
}

//2003/10/9 MGA追加 スワップイメージに関する関数

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  window.name="GbookOpenerWindow";
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
