//	しらぎく折り畳みスクリプト	第1.01版
//	平成18年 5月12日　しらぎくさいと
//	Copyright (c)2006 MINOBE Hiroyuki, Saitama, JAPAN.
//	Copyright (c)2006 Marguerite Site, Saitama, JAPAN.
//	   www.marguerite.jp

anchor_front='HANC';		//	表示切替を行うアンカーはここで指定した文字列で始まるID属性を付けた要素とします。
block_front='HBLK';		//	表示切替するブロックはここで指定した文字列で始まるID属性を付けます。
//　表示切替を行うアンカーの文字列。
anchor_str_open='表\示する';
anchor_str_close='非表\示にする';

//　以下変更しないで下さい。
hc_o6=(navigator.userAgent.indexOf('Opera/5.')>=0) || (navigator.userAgent.indexOf('Opera 5.')>=0 ||
    navigator.userAgent.indexOf('Opera/6.')>=0) || (navigator.userAgent.indexOf('Opera 6.')>=0 || (navigator.userAgent.indexOf('MSIE 4.')>=0 && !window.opera));
if ((document.all || document.getElementById) && !hc_o6) hc_onload=window.onload, window.onload=hc_init;
function hc_init() {
	if (!document.all && !document.getElementById || hc_o6) return;
	var i,idn,j,k,eles;

	if (document.all && !window.opera) eles=document.all; else eles=document.getElementsByTagName('*');

	i=-1;
	while (++i<eles.length) {
		idn=eles[i].getAttribute('id');
		if (!idn) continue;
		//アンカー？
		if (idn.indexOf(anchor_front)==0) {
			j=idn.substring(anchor_front.length,idn.length);
			if (!document.getElementById(block_front+j)) continue;	//対象となるブロックが無い。
			k=eles[i].innerHTML; k+=' (<a id="'+anchor_front+'_'+j+'" href="javascript:hc_open_close(\''+j+'\')">'+anchor_str_open+'</a>)';
			eles[i].innerHTML=k;
			continue;
			}
		//対象ブロック？
		if (idn.indexOf(block_front)==0) {
			j=idn.substring(block_front.length,idn.length);
			if (!document.getElementById(block_front+j)) continue;	//操作するアンカーが無い。
			eles[i].setAttribute('defaultDisplay',eles[i].style.display);
			eles[i].style.display='none';
			}
		}
	if (hc_onload) { hc_onload(); hc_onload=''; }
}

function hc_open_close(idn) {
	if (!document.all && !document.getElementById || hc_o6) return;

	var i,j,anc,blc;

	if (document.all) anc=document.all[anchor_front+'_'+idn],blc=document.all[block_front+idn];
	else anc=document.getElementById(anchor_front+'_'+idn),blc=document.getElementById(block_front+idn);
	if (!blc || !anc) return;

	//表示オン。
	if (blc.style.display=='none') {
		blc.style.display=blc.getAttribute('defaultDisplay');
		anc.innerHTML=anchor_str_close;
		return;
		}
	//表示オフ。
	blc.style.display='none';
	anc.innerHTML=anchor_str_open;
	return;
}
