var ua = navigator.userAgent;       // ユーザーエージェント
var bStd = (document.compatMode && document.compatMode=="CSS1Compat");// 標準モードかどうか

// DreamWeaver書き出し
function MM_preloadImages() { //v3.0
  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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// オリジナル
function H_openwin(num) {
  H_win=window.open("sub_win/"+num+".html","subcustom","scrollbars=yes,resizable=yes,width=670");
  H_win.focus();
}

function H_openwinsp(num,w,h) {
  H_win=window.open(num,"subcustom","toolbar=no,width="+w+",height="+h+",status=no,menubar=no,scrollbars=no,resizable=no");
  H_win.focus();
}

function H_openwinsb(num) {
  myleft = screen.width/2 -660/2 ;
  mywidth = screen.height-56;//ウインド上部56pxタスクバー28px

  H_win=window.open(num,"subcustom","toolbar=no,top=0,left="+myleft+",width=660,height="+mywidth+",status=no,menubar=no,scrollbars=yes,resizable=no");
  H_win.focus();
}

function H_openimage(num) {
  H_win=window.open("sub_win/images/"+num+".jpg","subimage","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=660,height=500");
  H_win.focus();
}

function H_patapta(id,act) {
	if(document.all) {
		obj = document.all(id+"x").style;
		imgobj = document.all(id);
	} else if(document.getElementById) {
		obj = document.getElementById(id+"x").style;
		imgobj = document.getElementById(id);
	}
	if (obj) {
		if (act==1) {
			imgobj.src = 'images/'+id+'_f2.gif';
			obj.display='block';
		} else {
			imgobj.src = 'images/'+id+'.gif';
			obj.display='none';
		}
	}
}

function H_topmenu_sub(id,x) {
	var mysubs = "menu_"+id+"_subs";
	var myimg = "topmenu_"+id;
	if(document.all) {
		obj = document.all(mysubs).style;
		imgobj = document.all(myimg);
	} else if(document.getElementById) {
		obj = document.getElementById(mysubs).style;
		imgobj = document.getElementById(myimg);
	}
	if (obj) {
		if (x!=-1) {
			imgobj.src = 'images/topmenu_'+id+'_f2.gif';
			obj.display='block';
			obj.left = (GetWindowWidth(845)-836)/2+x;
			obj.top = 447;
		} else {
			imgobj.src = 'images/topmenu_'+id+'.gif';
			obj.display='none';
		}
	}
}

function H_topmenu_sub2(id,x) {
	var mysubs = "menu_"+id+"_subs";
	var myimg = "topmenu_"+id;
	if(document.all) {
		obj = document.all(mysubs).style;
		imgobj = document.all(myimg);
	} else if(document.getElementById) {
		obj = document.getElementById(mysubs).style;
		imgobj = document.getElementById(myimg);
	}
	if (obj) {
		if (x!=-1) {
			imgobj.src = 'images/topmenu_'+id+'_f2.gif';
			obj.display='block';
			obj.left = (GetWindowWidth(845)-836)/2+x;
			obj.top = 315;
		} else {
			imgobj.src = 'images/topmenu_'+id+'.gif';
			obj.display='none';
		}
	}
}

function GetWindowWidth(limit){
	var ret = limit;
	if (ua.indexOf("MSIE")!=-1) {
		if (bStd) ret = document.documentElement.clientWidth;
		else ret = document.body.clientWidth;
	} else if (window.opera) {
		ret = document.body.clientWidth;
	} else if (ua.indexOf("Firefox")!=-1) {
		if (bStd) ret = document.documentElement.clientWidth-document.documentElement.scrollWidth;
		else ret = document.body.clientWidth-document.body.scrollWidth;
//		if (ua.indexOf("Mac")!=-1) ret = document.documentElement.clientWidth;
		if (ret==0) {
			if (bStd) ret = document.documentElement.clientWidth;
			else ret = document.body.clientWidth;
		}
	} else if (ua.indexOf("Safari")!=-1) {
		ret = document.body.clientWidth;
	} else if (document.all) {
		ret = document.body.clientWidth;
	} else if (document.layers) {
		ret = innerWidth;
	}
	if (ret < limit) ret = limit;
	return(ret);
}

function H_flash(url, w, h, name, bgcolor, flashvars){
	switch (arguments.length) { 
		case 3: name = 'flash'; 
		case 4: bgcolor = '#000000'; 
		case 5: flashvars = ''; 
	}
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + w + '" height="' + h + '" id="' + name + '" align="">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="' + url + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="' + bgcolor + '" />');
	if (flashvars != "") document.write('<param name=FlashVars value="' + flashvars + '" />');
	document.write('<embed src="' + url + '" quality="high" bgcolor="' + bgcolor + '" width="' + w + '" height="' + h + '" name="' + name + '"');
	if (flashvars != "") document.write(' FlashVars="' + flashvars + '"');
	document.write(' align="" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function H_flash2(url, w, h, name, bgcolor, flashvars ,wmode){
	switch (arguments.length) { 
		case 3: name = 'flash'; 
		case 4: bgcolor = '#000000'; 
		case 5: flashvars = ''; 
		case 6: wmode = 'transparent';
	}
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + w + '" height="' + h + '" id="' + name + '" align="">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="' + url + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="' + bgcolor + '" />');
	document.write('<param name="wmode" value="transparent" />');
	if (flashvars != "") document.write('<param name=FlashVars value="' + flashvars + '" />');
	document.write('<embed src="' + url + '" quality="high" bgcolor="' + bgcolor + '" width="' + w + '" height="' + h + '" wmode="' + wmode + '" name="' + name + '"');
	if (flashvars != "") document.write(' FlashVars="' + flashvars + '"');
	document.write(' align="" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function H_macie(){
	if ((ua.indexOf("Mac")!=-1)&&(ua.indexOf("MSIE")!=-1)) {
		var menus = ["nex","manual","research","society","tools","large_sum"]; 
		for (i=0;i<6;i++){
			id=menus[i];
			var mysubs = "menu_"+id+"_subs";
			var myimg = "topmenu_"+id;
		imgobj = document.getElementById(myimg);
				imgobj.src = 'images/topmenu_'+id+'.gif';
		}
	}
}

function H_swapImage(onoff) {
	if (onoff == "ooo"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split00.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split00.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03.gif";
	} else if (onoff == "oox"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split00.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split01.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03_f2.gif";
	} else if (onoff == "oxo"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split01.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02_f2.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split10.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03.gif";
	} else if (onoff == "oxx"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split01.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02_f2.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split11.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03_f2.gif";
	} else if (onoff == "xoo"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01_f2.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split10.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split00.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03.gif";
	} else if (onoff == "xox"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01_f2.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split10.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split01.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03_f2.gif";
	} else if (onoff == "xxo"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01_f2.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split11.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02_f2.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split10.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03.gif";
	} else if (onoff == "xxx"){
		document.getElementById("nex_kijo_btn01").src="images/nex_kijo_btn01_f2.gif";
		document.getElementById("nex_kijo_btn_split01").src="images/nex_kijo_btn_split11.gif";
		document.getElementById("nex_kijo_btn02").src="images/nex_kijo_btn02_f2.gif";
		document.getElementById("nex_kijo_btn_split02").src="images/nex_kijo_btn_split11.gif";
		document.getElementById("nex_kijo_btn03").src="images/nex_kijo_btn03_f2.gif";
	}
}