function foldMenu(sel, optArray) {
	
	/* close all the option divs first */
	for (i in optArray) {
		elem = document.getElementById('option' + optArray[i]);
		if (elem != null) {
			elem.style.display = 'none';
		}
	}
	
	/* open the option div we want */
	
	var ind = sel.selectedIndex;
	var optId = optArray[ind];
	
	elem = document.getElementById('option' + optId);
	if (elem != null) {
		elem.style.display = 'block';
	}
	
}

function toctoggle(cid) {
	toggle = document.getElementById(cid);
	togglevis = document.getElementById(cid + "-content");

	if (toggle.className.indexOf("toc-hil") > -1) {
		tocdehil(toggle);
		tochide(togglevis);
	} else {
		tochil(toggle);
		tocshow(togglevis);
	}

	if (cid != "toc-navigate") {
		tocdehil(document.getElementById("toc-navigate"));
		tochide(document.getElementById("toc-navigate-content"));
	}
	if (cid != "toc-apparatus") {
		tocdehil(document.getElementById("toc-apparatus"));
		tochide(document.getElementById("toc-apparatus-content"));
	}
	if (cid != "toc-about") {
		tocdehil(document.getElementById("toc-about"));
		tochide(document.getElementById("toc-about-content"));
	}
	if (cid != "toc-project") {
		tocdehil(document.getElementById("toc-project"));
		tochide(document.getElementById("toc-project-content"));
	}
	if (cid != "toc-home") {
		tocdehil(document.getElementById("toc-home"));
	}
	if (cid != "toc-search") {
		tocdehil(document.getElementById("toc-search"));
	}
	if (cid != "toc-help") {
		tocdehil(document.getElementById("toc-help"));
	}
}

function tochil(toggle) {
	toggle.className += "  toc-hil";
}

function tocdehil(toggle) {
	toggle.className = toggle.className.replace(/toc-hil/g,"");	
}

function tochide(togglevis) {
	togglevis.style.display = 'none';
}

function tocshow(togglevis) {
	togglevis.style.display = '';
}

function expandNav(pane) {
	var witnessIndex = document.getElementById('witness' + pane).selectedIndex;
	contractAll(pane);
	/*alert(pane + '-' + witnessIndex);*/
	expand(pane + '-' + witnessIndex);
}

function bookNav(sel, pane) {
	var ind = sel.selectedIndex;

	contract(pane + "NavB1");
	contract(pane + "NavB2");
	contract(pane + "NavB3");

	elem = document.getElementById(pane + "NavB" + (ind + 1));
	if (elem != null) {
		elem.style.display = 'block';
	}
}

function contractAll(pane) {
	for (i = 1; i < 26; i ++) {
		contract(pane + '-' + i);
	}
}

function jtoggle(cid) {
	showMe = document.getElementById(cid);
	if (showMe.style.display == 'none') {
		showMe.style.display = '';
	} else {
		showMe.style.display = 'none';
	}
}

function expand(cid) {
	showMe = document.getElementById(cid);
	showMe.style.display = '';
}

function contract(cid) {
	hideMe = document.getElementById(cid);
	if (hideMe) {
		hideMe.style.display = 'none';
	}
}

function toggle(cid) {
	toggleMe = document.getElementById(cid);
	if (toggleMe.className == 'activeblock') {
		toggleMe.className = 'inactiveblock';
	} else {
		toggleMe.className = 'activeblock';
	}
}

function toggleItem(cid) {
	toggleMe = document.getElementById(cid);
	if (toggleMe.className == 'activeitem') {
		toggleMe.className = 'inactiveitem';
	} else {
		toggleMe.className = 'activeitem';
	}
}

function toggleHeader(cid) {
	toggleMe = document.getElementById(cid);
	if (toggleMe.className == 'activeheader') {
		toggleMe.className = 'inactiveheader';
	} else {
		toggleMe.className = 'activeheader';
	}
}

function shade(cid) {
	shadeMe = document.getElementById(cid);
	shadeMe.style.background='#b4c7e0'
}

function unshade(cid) {
	shadeMe = document.getElementById(cid);
	shadeMe.style.background=''
}

