//anntena Hide and Show
//version 0.5.2
//last updated 2005/12/13 03:30
//made by Higeorange
//http://www14.plala.or.jp/operairc/

if((location.href.indexOf('http://a.hatena.ne.jp/') == 0) && (location.href.indexOf('http://a.hatena.ne.jp/include') !=0))
	document.addEventListener('load',antennaHideShow,false);

function antennaHideShow() {

	var ol;
	var ols = document.getElementsByTagName('ol');
	for(i=0;i<ols.length;i++) {
		if(ols[i].getAttribute('start'))
			ol = ols[i]
	}

	var col_all_ul = document.createElement('ul');
	var col_all_li = {
		'item' :[{
			'func' : 'showAll()',
			'txt': 'Show all'
		},
		{
			'func' : 'hideAll()',
			'txt' : 'Hide all'
		}]
	}


	li = ol.getElementsByTagName('li');
	var def = false;

//詳細を展開するリンクを追加
	for(j=0;j<li.length;j++) {
		var ps = li[j].getElementsByTagName('p')[0];
		if(ps != null) {
			ps.setAttribute('id','showhide'+[j]);
			ps.style.display = 'none';

			var span = document.createElement('span');
			var anc = document.createElement('a');
			anc.style.fontSize = '12px';
			anc.style.textDecoration = 'none';
			anc.href = 'javascript:void(0)';
			anc.id = 'sa' + [j];
			anc.onclick = 'showHide('+[j]+')';
			anc.innerHTML = 'Show';
			span.appendChild(anc);
			li[j].insertBefore(span,ps);
			def = true;
		}
	}

	if(def) {
		for(i=0;i<col_all_li.item.length;i++) {
			var col_all_lis = document.createElement('li');
			col_all_lis.style.display = 'inline';
			col_all_lis.style.margin = '0 3px';
			var col_all_anc = document.createElement('a');
			col_all_anc.style.fontSize = '12px';
			col_all_anc.href = 'javascript:void(0)';
			col_all_anc.onclick = col_all_li.item[i].func;
			col_all_anc.innerHTML = col_all_li.item[i].txt;
			col_all_lis.appendChild(col_all_anc);
			col_all_ul.appendChild(col_all_lis);
		}
	}
	document.body.insertBefore(col_all_ul,ol);
}

function showHide(num) {
	var shs =document.getElementById('showhide'+num);
	a = document.getElementById('sa'+num);
	if(shs.style.display=='none'){
		shs.style.display = 'block';
		a.innerHTML = 'Hide';
	} else {
		shs.style.display='none';
		a.innerHTML = 'Show';
	}
}

function showAll() {
	for(i=0;i<li.length;i++) {
		var shanc = li[i].getElementsByTagName('a')[4];
		if(!shanc)
			shanc = li[i].getElementsByTagName('a')[3];
		var ps = li[i].getElementsByTagName('p')[0];
		if(ps != null) {
			if(ps.style.display == 'none')
				ps.style.display = 'block';
				shanc.innerHTML = 'Hide';
		}
	}
}

function hideAll() {
	for(i=0;i<li.length;i++) {
		var shanc = li[i].getElementsByTagName('a')[4];
		if(!shanc)
			shanc = li[i].getElementsByTagName('a')[3];
		var ps = li[i].getElementsByTagName('p')[0];
		if(ps != null) {
			if(ps.style.display == 'block')
				ps.style.display = 'none';
				shanc.innerHTML = 'Show';
		}
	}
}
