function clientHeight(){
  if ( (document.documentElement) &&
       (    document.documentElement.clientHeight 
         >= document.body.clientHeight            ) ) {
    return(document.documentElement.clientHeight);
  } else {
    return(document.body.clientHeight);
  }
}

function isMenuable(){
  return(document.body.clientWidth > 400);
			/* 幅が 400px 以上あるなら
         メニューを表示しても閲覧性を損なわないので True */
}

function isMenuFixed(){
  return(clientHeight() > 95 + 10 * 25);
			/* 高さが 95 + メニュー項目数 * 25 px 以上あるなら
         メニューを全て表示できるので True */
}

function isCurrent(path){
  current = window.location.pathname;
  current.match(/(^.*\/)([^\/]*$)/);
  return(RegExp.$2 == path);
}

function write_li(href, title, txt){
  if (isCurrent(href)) {
    document.writeln(   '	<li class="Current" title="' 
                      + title + '">' + txt + '</li>'   );
  } else {
    document.writeln(   '	<li><a href="' + href 
                      + '" title="' + title + '">' 
                      + txt + '</a></li>'          );
  }
}

function menuConstructor(){
	if (! isMenuable()) { return; }

  if (isMenuFixed()) {
    document.writeln('<div class="LeftMenu">');
  } else {
    document.writeln('<div class="LeftMenu" style="position:absolute;">');
  };

	document.writeln('<ul>');
	write_li(	"index.html", 
						"トップページ", 
						"トップページ");
	write_li(	"info.html", 
						"センターからのお知らせ、センターに関係する出来事など", 
						"お知らせ"    );
	write_li(	"outline.html", 
						"センターの設立経緯や目的と、簡単な紹介", 
						"センター概要");
	write_li(	"equipment.html", 
						"センターにある測定機器の紹介", 
						"測定機器");
	write_li(	"permit.html", 
						"センターで使うことの出来る放射性同位元素", 
						"使用可能核種");
	write_li(	"procedure.html", 
						"センターの使用や証明書の発行手続き", 
						"各種手続"    );
	write_li(	"access.html", 
						"RIセンターの連絡先と位置", 
						"アクセス方法");
	write_li(	"floor.html", 
						"建物内の平面図と実験室等の案内", 
						"部屋の案内"  );
	write_li(	"glossary.html", 
						"RIに関する用語の解説", 
						"用語解説"  );
	write_li(	"link.html", 
						"関連するサイトへのリンク", 
						"関連リンク"  );
	document.writeln('</ul>');

	document.writeln('</div><div class="LeftMenuedContents">');

}

function menuDestructor(){
	if (! isMenuable()) { return; }

	document.writeln('</div>');
}



