# hide_section.rb
# Copyright (C) 2005  Michitaka Ohno <elpeo@mars.dti.ne.jp>
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

@hide_section_anchor_hide = "&#9650;"
@hide_section_anchor_show = "&#9660;"

@conf.mobile_agent? || add_header_proc do
	<<-HTML
	<style type="text/css"><!--
	a.hide_section {
		border-style: solid;
		border-width: 1px;
		font-size: medium;
		text-decoration: none;
	}
	a.hide_section:hover {
		text-decoration: none;
	}
	--></style>
	<script type="text/javascript"><!--
	function section_view(e,visible){
		var n=e.parentNode.parentNode.childNodes;
		for(var i=0;i<n.length;i++){
			if(n[i].nodeType==1&&n[i]!=e.parentNode){
				n[i].style.display=visible?"":"none";
			}
		}
		e.onclick=function(){section_view(this,!visible)};
		e.innerHTML=visible?'#{@hide_section_anchor_hide}':'#{@hide_section_anchor_show}';
	}
	function allsection_view(e,visible){
		var n=e.parentNode.parentNode.getElementsByTagName("div")[0].getElementsByTagName("a");
		for(var i=0;i<n.length;i++){
			if(n[i].className=="hide_section"){
				section_view(n[i],visible);
			}
		}
		e.onclick=function(){allsection_view(this,!visible)};
		e.innerHTML=visible?'#{@hide_section_anchor_hide}':'#{@hide_section_anchor_show}';
	}
	// --></script>
	HTML
end

@conf.mobile_agent? || add_title_proc do |date, title|
	<<-HTML
	#{title} <a class="hide_section" href="javascript:void(0)" onclick="allsection_view(this,false)">#{@hide_section_anchor_hide}</a>
	HTML
end

@conf.mobile_agent? || add_subtitle_proc do |date, index, subtitle|
	<<-HTML
	#{subtitle} <a class="hide_section" href="javascript:void(0)" onclick="section_view(this,false)">#{@hide_section_anchor_hide}</a>
	HTML
end
