/*
ShowHide usage notes -
1) Add two classes to the style list:
	.hiddenOn {display: none;}
	.hiddenOff {display: block;}
2) Create a container with an id and a class:
	<div class="hiddenOn" id="hideexample"></div>
	Elements that share a prefix, 'hide' in this example, will all be toggled as a family.
3) Activate the boxes with js onclicks:
	<a href="#hideexample" onclick="hidetoggleAll('hideexample', 'hide');">open/close the container</a>
	You can also pass a third argument for elements other than divs (headers, paragraphs, spans, etc).
4) The next to last line of code (window.location.hash = "#"+divID;) adds the anchor behavior to the containers. If all the jumping around makes you feel nausea, comment out the line.
5) This was made to make it somewhat easier to view big chunks of text in a small space. It has some accessibility issues in that hidden divs are… well… hidden. Use of this presentation method is considered search engine friendly, however… by most accounts anyway. YMMV.
*/

// Toggles between 'hiddenOn' and 'hiddenOff'
function hidetoggle(divID) {
	var d = document.getElementById(divID);
	if (d.className === 'hiddenOn') {
		d.className = 'hiddenOff';
	} else {
		d.className = 'hiddenOn';
	}
}

// Expands/contracts and changes the tags that begin with the given prefix.
function collapseAll(start, expd, tagName) {
	var cTag = 'div';
	if (tagName !== undefined && tagName !== 'null') {
		cTag = tagName;
	}
	var newClass;
	var expand = expd;
	if (expand) {
		newClass = 'hiddenOff';
	} else {
		newClass = 'hiddenOn';
	}
	var allDivs = document.getElementsByTagName(cTag);
	var i = 0;
	for (i = 0; i < allDivs.length; i++) {
		if (allDivs[i].id.indexOf(start) === 0) {
			allDivs[i].className = newClass;
		}
	}
}

function hidetoggleAll(divID, prefix, tagName) {
	var d = document.getElementById(divID);
	var isHid = d.className === 'hiddenOn';
	collapseAll(prefix, 0, tagName);
	if (isHid) {
		hidetoggle(divID);
	}
	//window.location.hash = "#" + divID;
}
