/*
This code is based on a code example from the article "Javascript navigation - cleaner, not meaner" by Christian Heilmann
URL: http://www.evolt.org/article/Javascript_navigation_cleaner_not_meaner/17/60273/index.html
Revised by http://www.bobbyvandersluis.com/articles/unobtrusiveshowhide.php
Further Adapted by http://www.ProjectRake.com/sponsors/contributers.asp
*/

// If there is enough W3C DOM support for all our show/hide behavior:
// 1. Call the stylesheet that by default hides all toggleable sections 
// 2. Apply the show/hide behavior by calling the initialization function
if (document.getElementById && document.getElementsByTagName && document.createTextNode) 
	{
	window.onload = initShowHide;
	}
	
	function initShowHide() {
		//hide();
		var toggle = document.getElementById('toggle');
		var as = toggle.getElementsByTagName('a');
		for (var i = 0; i < as.length; i++) {
			as[i].onclick = function() {
				swap(this);
				return false;
			}
		}
	}

	function swap(s) 
		{
		var id = s.href.match(/#(\w.+)/)[1];
		var offon = document.getElementById(id).style.display
		if (offon == 'none')
			{
				show(s);
			}
			else
			{			
				hide(s);
			}
		}

	function show(s) {	
		var id = s.href.match(/#(\w.+)/)[1];
		document.getElementById(id).style.display = 'block';
	}

	function hide(s) {
		var id = s.href.match(/#(\w.+)/)[1];
		document.getElementById(id).style.display = 'none';
		
		//var toggleable = document.getElementById('toggleable').getElementsByTagName('div');
		//for (var i = 0; i < toggleable.length; i++) {
		//	toggleable[i].style.display = 'none';
		//}
	}
