﻿/// ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
///
/// 共通関数
///
/// ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
/// ***************************************************************************
/// <summary>
/// オブジェクトの検索
/// </summary>
/// <param name="theObj">オブジェクトの識別子</param>
/// <param name="theDoc">再起用に使用され最初の呼び出しは指定しない</param>
/// ***************************************************************************
function findObj(theObj, theDoc) {
	var p, i, foundObj;

	if(!theDoc) theDoc = document;
	if( (p = theObj.indexOf("?")) > 0 && parent.frames.length) {
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
	if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
	for (i=0; !foundObj && i < theDoc.forms.length; i++) 
		foundObj = theDoc.forms[i][theObj];
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
		foundObj = findObj(theObj,theDoc.layers[i].document);
	if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

	return foundObj;
}

/// ***************************************************************************
/// <summary>
/// URL のファイル名を取得します。
/// </summary>
/// <param name="url">検索するURL</param>
/// ***************************************************************************
function GetFileName(url) {
	var seg = url.split("/");
	var fileName = seg[seg.length - 1].replace(".asp", "");
	fileName = fileName.replace(".htm", "");
	
	return fileName;
}

/// ***************************************************************************
/// <summary>
/// 現在の表示ページに応じたメニューの表示を行います。
/// </summary>
/// ***************************************************************************
function DisplayMenu() {
	var lnks = new Array(
		findObj("lnk_index"),
		findObj("lnk_about_us"),
		findObj("lnk_record"),
		findObj("lnk_document"),
		findObj("lnk_structure"),
		findObj("lnk_information"));
		
	var fileName = GetFileName(document.location.pathname);
	var lnk = findObj("index");
	for (i = 0; i < lnks.length; i++) {
		if (lnks[i].name.replace("lnk_", "") == fileName) {
			lnk = lnks[i];

			/*リンクの設定*/
			lnk.style.color="black";
			lnk.style.fontWeight="bold";
		
			/*画像の設定*/
			var img;
			
			if (fileName == "document" || fileName == "structure" || fileName == "information") {
				img = findObj("img_iso");
			} else {
				if (fileName.indexOf("record", 0) >= 0) {
					img = findObj("img_record");
				} else {
					img = findObj("img_" + lnk.name.replace("lnk_", ""));
				}
			}
			
			if (img != null) img.src = img.src.replace(".gif", "_on.gif");

			break;
		}
	}
}

/// ***************************************************************************
/// <summary>
/// ISO情報サブメニューの表示/非表示を切り替えます。
/// </summary>
/// ***************************************************************************
function SwitchSubMenu() {
	var objMenu = findObj("menu_iso");

	if (objMenu == null) return;

	if (objMenu.style.display=='none' || objMenu.style.display=='') {
		objMenu.style.display='block';
	} else {
		objMenu.style.display='none';
	}
}

/// ***************************************************************************
/// <summary>
/// Injformation の表示
/// </summary>
/// <param name="valYear">表示するテーブルID</param>
/// ***************************************************************************
function ShowInfo(id) {
	//初回読み込み時
	if (id == null) {
		id = "tbl_press";
		//タブメニューの表示
		findObj("tbl_tab").style.display = "block";
		//各タイトルの非表示
		findObj("tr_press").style.display	= "none";
		findObj("tr_news").style.display	= "none";
		findObj("tr_booklet").style.display = "none";
	} else {
		id = "tbl_" + id;
	}
	
	var tbl = findObj(id);
	var cssNormal	= "td_tab";
	var cssSelected = "td_tab_selected";
	
	if (tbl == null) return;
	
	findObj(id).style.display = "block";

	switch (id) {
		case "tbl_press":
			findObj("tbl_news").style.display 		= "none";
			findObj("tbl_booklet").style.display 	= "none";
			findObj("td_tab_press").className		= cssSelected;
			findObj("td_tab_news").className		= cssNormal;
			findObj("td_tab_booklet").className		= cssNormal;
			break;
			
		case "tbl_news":
			findObj("tbl_press").style.display 		= "none";
			findObj("tbl_booklet").style.display 	= "none";
			findObj("td_tab_press").className		= cssNormal;
			findObj("td_tab_news").className		= cssSelected;
			findObj("td_tab_booklet").className		= cssNormal;
			break;
			
		case "tbl_booklet":
			findObj("tbl_press").style.display 		= "none";
			findObj("tbl_news").style.display 		= "none";
			findObj("td_tab_press").className		= cssNormal;
			findObj("td_tab_news").className		= cssNormal;
			findObj("td_tab_booklet").className		= cssSelected;
			break;
	}
}
