var url = window.location.pathname;
var host = window.location.hostname;
// var dir = url.replace(/^\/investors\/([^\/]+\/)*([^\/]+)\/(index\.html)?$/,"$2");
// var dir = url.replace(/^\/([^\/]+\/)*([^\/]+)\/(index\.html)?$/,"$2");
var dir = url.split("/");
var param = location.search;
var anchor = location.hash;
var is_btn = false;

if (param.indexOf('size=') != -1){
	var fs_prm = param.charAt(param.indexOf('size=') + 5);
}else{
	var fs_prm = 1;
}


dirNameL0 = new Array();
	dirNameL0[1] = "investors";

cntNameL0 = new Array();
	cntNameL0[dirNameL0[1]] = "投資家情報";

dirNameL1 = new Array();
	dirNameL1[1] = "ceo";
	dirNameL1[2] = "corporate";
	dirNameL1[3] = "highlight";
	dirNameL1[4] = "stockholder";
	dirNameL1[5] = "stock-rating";
	dirNameL1[6] = "event";
	dirNameL1[7] = "library";
	dirNameL1[8] = "calendar";
	dirNameL1[9] = "mail";
	dirNameL1[10] = "sitemap";
	dirNameL1[11] = "caution";
	dirNameL1[12] = "faq";

cntNameL1 = new Array();
	cntNameL1[dirNameL1[1]] = "CEOメッセージ";
	cntNameL1[dirNameL1[2]] = "会社案内";
	cntNameL1[dirNameL1[3]] = "財務ハイライト";
	cntNameL1[dirNameL1[4]] = "株主様へ";
	cntNameL1[dirNameL1[5]] = "株式・社債・格付情報";
	cntNameL1[dirNameL1[6]] = "IRイベント";
	cntNameL1[dirNameL1[7]] = "IR資料室";
	cntNameL1[dirNameL1[8]] = "IRカレンダー";
	cntNameL1[dirNameL1[9]] = "IRメールサービス";
	cntNameL1[dirNameL1[10]] = "IRサイトマップ";
	cntNameL1[dirNameL1[11]] = "免責事項";
	cntNameL1[dirNameL1[12]] = "FAQ";

dirNameL2 = new Array();
	dirNameL2[1] = "notice";
	dirNameL2[2] = "filings";
	dirNameL2[3] = "meeting";
	dirNameL2[4] = "investor-meeting";
	dirNameL2[5] = "asia-meeting";
	dirNameL2[6] = "financialresult";
	dirNameL2[7] = "reports";
	dirNameL2[8] = "annualreport";
	dirNameL2[9] = "kabunushi-tsushin";
	dirNameL2[10] = "governance";
	dirNameL2[11] = "directors";
	dirNameL2[12] = "stock";

cntNameL2 = new Array();
	cntNameL2[dirNameL2[1]] = "公告";
	cntNameL2[dirNameL2[2]] = "証券取引所提出資料";
	cntNameL2[dirNameL2[3]] = "決算説明会";
	cntNameL2[dirNameL2[4]] = "北米・欧州 IR ロードショー";
	cntNameL2[dirNameL2[5]] = "アジア事業説明会";
	cntNameL2[dirNameL2[6]] = "決算資料";
	cntNameL2[dirNameL2[7]] = "レポート";
	cntNameL2[dirNameL2[8]] = "レポート";
	cntNameL2[dirNameL2[9]] = "株主通信・事業報告書";
	cntNameL2[dirNameL2[10]] = "コーポレートガバナンス";
	cntNameL2[dirNameL2[11]] = "代表取締役・専務取締役";
	cntNameL2[dirNameL2[12]] = "株価";

dirParent = new Array();
	dirParent[dirNameL2[1]] = dirNameL1[4];
	dirParent[dirNameL2[2]] = dirNameL1[5];
	dirParent[dirNameL2[3]] = dirNameL1[6];
	dirParent[dirNameL2[4]] = dirNameL1[6];
	dirParent[dirNameL2[5]] = dirNameL1[6];
	dirParent[dirNameL2[6]] = dirNameL1[7];
	dirParent[dirNameL2[7]] = dirNameL1[7];
	dirParent[dirNameL2[8]] = dirNameL1[7];
	dirParent[dirNameL2[9]] = dirNameL1[7];
	dirParent[dirNameL2[10]] = dirNameL1[7];
	dirParent[dirNameL2[11]] = dirNameL1[7];
	dirParent[dirNameL2[12]] = dirNameL1[5];

window.onload = function(){
	setParameter(fs_prm);
}

function writeHeader() {
	var h = '';
	//h += url + '<br />';	// PATH 表示用
	//h += host + '<br />';	// HOST 表示用
	//h += param + '<br />';	// パラメタ 表示用
	//h += anchor + '<br />';	// ハッシュ 表示用
	//h += fs_prm + '<br />';	// 引数 表示用
	//for (i = 0; i < dir.length; i++) { h += i + '=>' + dir[i] + '<br />'; }	// ディレクトリ確認表示用
	h += '<table border="0" cellpadding="0" cellspacing="0" width="660" height="36">\n';
	h += '	<tr>\n';
	if(dir.length <= 3){
		//	トップページの処理：Englishリンク表示、タイトル非リンク
		h += '		<td align="right"><img src="/investors/image200607/ln-english.gif" border="0" width="63" height="36" alt="" usemap="#english"><map name="english"><area href="http://world.honda.com/investors/" coords="1,16,62,29" shape="rect" alt="ENGLISH"></map></td>\n';
		h += '	</tr>\n';
		h += '</table>\n';
		h += '<table border="0" cellpadding="0" cellspacing="0" width="660" height="40">\n';
		h += '	<tr>\n';
		h += '		<td background="/investors/image200607/titleback-g1.gif" width="125">\n';
		h += '			<img src="/investors/image200607/title-l1-home.gif" border="0" width="125" height="40" alt="投資家情報"></td>\n';
		h += '		<td background="/investors/image200607/titleback-g2.gif" width="323">\n';
	}else{
		//	トップページ以外
		h += '		<td><img src="/investors/image/space.gif" border="0" alt="" width="10" height="36"></td>\n';
		h += '	</tr>\n';
		h += '</table>\n';
		h += '<table border="0" cellpadding="0" cellspacing="0" width="660" height="40">\n';
		h += '	<tr>\n';
		h += '		<td background="/investors/image200607/titleback-g1.gif" width="125">\n';
		h += '			<a href="/investors/">\n';
		h += '			<img src="/investors/image200607/title-l1-home.gif" border="0" width="125" height="40" alt="投資家情報"></a></td>\n';
		h += '		<td background="/investors/image200607/titleback-g2.gif" width="323">\n';
		if(cntNameL1[dir[2]]){
			if(dir.length <= 4){
				//	第2階層の8つのどれか（dir.length < 4はあり得ない）
				h += '			<img src="/investors/image200607/title-l2-'+dir[2]+'.gif" border="0" width="320" height="40" alt="'+cntNameL1[dir[2]]+'">';
			}else{
				//	第2階層の8つのさらに下
				h += ' 			<a href="/investors/' + dir[2] + '/">\n';
				h += '			<img src="/investors/image200607/title-l2-'+dir[2]+'.gif" border="0" width="320" height="40" alt="'+cntNameL1[dir[2]]+'"></a>';
			}
		}else if(dirParent[dir[2]]){
			h += ' 			<a href="/investors/' + dirParent[dir[2]] + '/">\n';
			h += '			<img src="/investors/image200607/title-l2-'+dirParent[dir[2]]+'.gif" border="0" width="320" height="40" alt="'+cntNameL1[dirParent[dir[2]]]+'"></a>';
		}else{
			// 想定外の階層にあるディレクトリ
			// h += '			●●●処理未定●●●';
			h += '			$nbsp;';
		}
	}
	h += '</td>\n';
	h += '		<td background="/investors/image200607/titleback-g3.gif" width="212">\n';
	h += '			<table border="0" cellpadding="0" cellspacing="0" width="212">\n';
	h += '				<tr>\n';
	for (i = 10; i <= 12; i++) {
		h += '					<td>\n';
		if(dir[2] == dirNameL1[i]){
			h += '						<img src="/investors/image200607/ln-l1-navi-' + dirNameL1[i] + '-on.gif" border="0" alt="' + cntNameL1[dirNameL1[i]] + '">';
		}else{
			h += '						<a href="/investors/' + dirNameL1[i] + '/">';
			h += '						<img src="/investors/image200607/ln-l1-navi-' + dirNameL1[i] + '.gif" border="0" alt="' + cntNameL1[dirNameL1[i]] + '"></a>';
		}
		h += '</td>\n';
		h += '					<td><img src="/investors/image/spacer-336666.gif" border="0" alt="" width="5" height="10"></td>\n';
	}
	h += '				<tr>\n';
	h += '			</table></td>\n';
	h += '	</tr>\n';
	h += '</table>\n';
	document.write(h);
}

fontsizeCSS = new Array('','文字サイズ：小','文字サイズ：中','文字サイズ：大');
if (document.images) {
	fontBtn = new Array();
	fontBtnOn = new Array();
	for (i = 1; i <= 3; i++) {
		fontBtn[i] = new Image(); fontBtn[i].src = '/investors/image200607/fontsize' + i + '.gif';
		fontBtnOn[i] = new Image(); fontBtnOn[i].src = '/investors/image200607/fontsize' + i + 'on.gif';
	}
}

function writePnaviFontBtn(btn) {
	var pnavi = '';
	pnavi += '<table border="0" cellpadding="0" cellspacing="0" width="660" height="25">\n';
	pnavi += '	<tr>\n';
	pnavi += '		<td background="/investors/image200607/titleback-lb1.gif" width="539"><span  class="Pnavi">\n';

	// パン屑ナビ
	// トップページ
	if(dir.length <= 3){
		pnavi += 'トップページ';
	}else{
		pnavi += '<a href="/investors/">トップページ</a>';

		if(cntNameL2[dir[2]]){
			pnavi += ' &gt; <a href="/investors/' + dirParent[dir[2]] + '/">' + cntNameL1[dirParent[dir[2]]] + '</a>';
			if(dir[2] == 'annualreport'){
				pnavi += ' &gt; <a href="/investors/reports/">' + cntNameL2[dir[2]] + '</a>';
			}else if(dir.length == 4){
				pnavi += ' &gt; '+ cntNameL2[dir[2]];
			}else{
				pnavi += ' &gt; <a href="/investors/' + dir[2] + '/">' + cntNameL2[dir[2]] + '</a>';
			}
		}else if(cntNameL1[dir[2]]){
			if(dir.length == 4){
				pnavi += ' &gt; '+ cntNameL1[dir[2]];
			}else if(dir[2] == 'ceo' && dir[3] == 'message'){
				pnavi += ' &gt; <a href="/investors/' + dir[2] + '/">'+ cntNameL1[dir[2]] + '</a>';
				pnavi += ' &gt; 全文';
			}else if(dir[2] == 'mail' && dir[3] == 'form'){
				pnavi += ' &gt; <a href="/investors/' + dir[2] + '/">'+ cntNameL1[dir[2]] + '</a>';
				pnavi += ' &gt; 新規登録';
			}else{
				pnavi += ' &gt; <a href="/investors/' + dir[2] + '/">'+ cntNameL1[dir[2]] + '</a>';
				// pnavi += ' &gt; ●●●/ceo/message/、/mail/form/等、処理未定';
				// pnavi += ' &gt; /mail/form/等、処理未定';
				pnavi += '&nbsp;';
			}
		}
	}
	pnavi += '</span></td>\n';
	pnavi += '		<td background="/investors/image200607/titleback-lb2.gif" width="121">\n';

	if (document.styleSheets && btn) {
		pnavi += getFontBtn();
		is_btn = true;
	}else if (window.opera && btn){
		pnavi += getFontBtn();
		is_btn = true;
	}

	pnavi += '</td>\n';
	pnavi += '	</tr>\n';
	pnavi += '</table>\n';
	pnavi += '<table border="0" cellpadding="0" cellspacing="0" width="660" height="1">\n';
	pnavi += '	<tr><td><img src="/investors/image200607/titleback-lg.gif" width="660" height="1" alt=""></td></tr>\n';
	pnavi += '</table>\n';
	document.write(pnavi);
	if(is_btn){
		alterCSS(fs_prm);
	}
}

function getFontBtn() {
	f_btn = '<table border="0" cellpadding="0" cellspacing="0">\n';
	f_btn += '	<tr>\n';
	f_btn += '		<td><img src="/investors/image200607/fontsize.gif" width="64" height="20" alt="文字サイズ"></td>';
	f_btn += '		<td><a href="#" onClick="return setFontSize(1)"><img name="fontsize1" src="/investors/image200607/fontsize1.gif" border="0" width="19" height="20" alt="小"></a></td>\n';
	f_btn += '		<td><a href="#" onClick="return setFontSize(2)"><img name="fontsize2" src="/investors/image200607/fontsize2.gif" border="0" width="19" height="20" alt="中"></a></td>\n';
	f_btn += '		<td><a href="#" onClick="return setFontSize(3)"><img name="fontsize3" src="/investors/image200607/fontsize3.gif" border="0" width="19" height="20" alt="大"></a></td>\n';
	f_btn += '	</tr>\n';
	f_btn += '</table>\n';
	return f_btn;
}

function writeFontBtn() {
	if (document.styleSheets) {
		document.write(getFontBtn());
	}else if (window.opera){
		document.write(getFontBtn());
	}
	alterCSS(fs_prm);
}

function alterCSS(n) {
	if (document.images) {
		for (var i = 1; i <= 3; i++) {
			document.images['fontsize' + i].src = (n == i) ? fontBtnOn[i].src : fontBtn[i].src;
		}
	}
	if(navigator.userAgent.indexOf("Safari") == -1){
		if (document.styleSheets && n) {
			var f     = false;
			var sS    = document.styleSheets;
			var sSlen = sS.length;
			for (i = 0; i < sSlen; i++) {
				if (sS[i].title != '') {
					if (sS[i].title != fontsizeCSS[n]) {
						sS[i].disabled = true;
					} else {
						sS[i].disabled = false;
					}
				} 
			}
		} else if (window.opera && n){ // for Opera
			for (i = 0; i < document.getElementsByTagName("link").length; i++) {
				lnk = document.getElementsByTagName("link")[i].href;
				if (lnk.indexOf('fs') != -1) {
					lnk_n = lnk.replace(/(fs)\d(.css)$/,"$1" + n + "$2");
					setTimeout('document.getElementsByTagName("link")['+i+'].href = "' + lnk_n + '";',100);
				}
			}
		}
	} else { // for Safari
		if (n) {
			for (var fs in fSwitch) {
				if (fs == n) {
					fSwitch[fs].enable();
				} else {
					fSwitch[fs].disable();
				}
			}
		}
	}
}

function _in(nam,num) {
	if(navigator.appVersion.charAt(0) >= "3") {
		document.images[nam].src = img[num].src;
	} else { }
}

function _out(nam,num) {
	document.images[nam].src = img[num].src;
}

function setParameter(n){
	var elmA = document.getElementsByTagName("a");
	for (var i = 0; i < elmA.length; i++) {
		var r      = elmA[i].href;
		var anchor = '';
		if(r.match(/#[^\/]*$/)){
			anchor = r.replace(/.*(#[^\/]*$)/,"$1");
			r = r.replace(/(.*)#[^\/]*$/,"$1");
		}
		if (r.indexOf('?size=') != -1){
			r = r.replace(/\?size=[1-3]/,"");
		}
		var arr = r.split("/");
		if(r.match(/\.html$|\/$/) && arr[2] == host && arr[3] == 'investors'){
			prm = '?size=' + n + anchor;
			elmA[i].href = r.concat(prm);
		}
	}
}

function setFontSize(n){
	alterCSS(n);
	setParameter(n);
	return false;
}
