/*----------------------------------------*/
/*  breadCrumb.js ( 2009/5/6 )
/*  http://tshinobu.com/lab/breadCrumbJs/
/*  readcrumb (topicpath) generator by javascript
/*----------------------------------------*/

breadCrumbJsData = function(){
	/*----------------------------------------*/
	/*  index.html をパンくずリスト生成に含めるかどうか定義します。
	/*  false … index.html を無視する
	/*  true … index.html を無視しない
	/*----------------------------------------*/
	this.indexMatch = false;
	/*----------------------------------------*/
	/*  パンくずリストに表示する名前を定義してください。
	/*  （書式） "ディレクトリ名" : "表示名"
	/*----------------------------------------*/
	this.contentName = {
		"home" : "KOTONOHA HOME", // この行は残してください。
		"/~koto_portable/" : "kotonohaPortable TOPへ",
		"/~koto_portable/hori_42.html" : "ホリエモン",
		"" : "" //この行は残してください。
	};
	/*----------------------------------------*/
	/*  パンくずリスト生成検索処理
	/*----------------------------------------*/
	this.funcIndexSearch = function(){
		keyword = breadCrumbJsData.contentName[arguments[0]];
		if(keyword == undefined){
			return arguments[0].match(/(.*?)\//g).pop().replace("/","");
		} else{
			return keyword;
		}
	};
}
var breadCrumbJsData = new breadCrumbJsData();

function breadCrumbJs(){
	/*----------------------------------------*/
	/*  以下条件分岐 / 表示処理部分
	/*----------------------------------------*/
	var thisURL = window.location.pathname.match(/(.*?)\//g);
	var fileName =  window.location.pathname.match(/([^¥/]+?)$/);
	if ( fileName && (!( fileName[0].match("index") && !breadCrumbJsData.indexMatch )) ){ thisURL.push( fileName[0] ); }
	var drw = document.getElementById("breadCrumb");
	var rootingPath = "";
	if ( drw.tagName == "P" | drw.tagName == "DIV" ){
		for( i=0; i<thisURL.length; i++){
			rootingPath += thisURL[i];
			if ( i == 0 ){
				drw.innerHTML = '<a href="/">' + breadCrumbJsData.funcIndexSearch('home') + '</a>';
			} else if ( i == thisURL.length - 1 ){
				drw.innerHTML += ' &gt; <strong>' + breadCrumbJsData.funcIndexSearch(rootingPath) + '</strong>';
			} else {
				drw.innerHTML += ' &gt; <a href="'+rootingPath+'">' + breadCrumbJsData.funcIndexSearch(rootingPath) + '</a>';
			}
		}
	}
	if ( drw.tagName == "UL" | drw.tagName == "OL" ){
		for( i=0; i<thisURL.length; i++){
			rootingPath += thisURL[i];
			if ( i == 0 ){
				drw.innerHTML = '<li><a href="/">' + breadCrumbJsData.funcIndexSearch('home') + '</a></li>';
			} else if ( i == thisURL.length - 1 ){
				drw.innerHTML += ' <li class="active"><strong>' + breadCrumbJsData.funcIndexSearch(rootingPath) + '</strong></li>';
			} else {
				drw.innerHTML += ' <li><a href="'+rootingPath+'">' + breadCrumbJsData.funcIndexSearch(rootingPath) + '</a></li>';
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", breadCrumbJs, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", breadCrumbJs);
}
