var toc =
'<li class="directory">\r\n' +
' <span class="dirsign">+</span><a class="dirlink" href="javascript:toggleToc(\'root:\')">/</a><br />\r\n' +
' <ul id="root:" class="invisible">\r\n' +
'  <li class="pagelink"><a href="/index.html">index.html</a><br />ホーム</li>\r\n' +
'  <li class="pagelink"><a href="/about.html">about.html</a><br />自己紹介</li>\r\n' +
'  <li class="pagelink"><a href="/diary/">diary</a><br />雑記帳</li>\r\n' +
'  <li class="directory">\r\n' +
'   <span class="dirsign">+</span><a class="dirlink" href="javascript:toggleToc(\'root:26:\')">26/</a><br />\r\n' +
'   <ul id="root:26:" class="invisible">\r\n' +
'    <li class="pagelink"><a href="/26/index.html">index.html</a><br />にじふろく ―26のはこ</li>\r\n' +
'   </ul>\r\n' +
'  </li>\r\n' +
' </ul>\r\n' +
'</li>\r\n' +
'\r\n' +
"";

function toggleToc(ulid) {
	var togglingList = document.getElementById(ulid);
	var span;
	if (togglingList) {
		span = togglingList.parentNode.getElementsByTagName("span")[0];
		if (togglingList.className == "visible") {
			togglingList.className = "invisible";
			if (span) {
				span.innerHTML = "+";
			}
		} else {
			togglingList.className = "visible";
			if (span) {
				span.innerHTML = "-";
			}
		}
	}
}

function writeToc(divid, initpath) {
	divid.innerHTML = toc;
	path_id = "root" + initpath.replace(/\//g, ":");
	if (path_id.charAt(path_id.length - 1) != ":") {
		path_id = path_id.substring(0, path_id.lastIndexOf(":") + 1);
	}
	while (path_id) {
		toggleToc(path_id);
		if (path_id.charAt(path_id.length - 1) == ":") {
			path_id = path_id.substring(0, path_id.length - 1);
		}
		path_id = path_id.substring(0, path_id.lastIndexOf(":") + 1);
	}
}

