///////////////// TOGGLE CONTENTS /////////////////

function toggleContents() {
	tIcon = tIcons[this.tId];
	tHeading = tHeadings[this.tId];
	tContent = tContents[this.tId];
	tContent.style.display = (tContent.style.display=='none') ? 'block' : 'none';
	tIcon.innerHTML = (tContent.style.display=='none') ? showSymbol : hideSymbol;
	
	matchColumns();
}

showFirst = false;
function initToggleContents() {
	tData = document.getElementById('toggleData');
	if (tData) {
		showSymbol = '+';
		hideSymbol = '&ndash;';
		tHeadings = new Array();
		tContents = new Array();
		tIcons = new Array();
		tId = -1;
		for (i=0;i<tData.childNodes.length;i++) {
			child = tData.childNodes[i];
			if (child.className=='toggleHeading' || child.className=='toggleIcon') {
				if (child.className=='toggleIcon') {
					tId++;
					child.tId = tId;
					tIcons[tId] = child;
					child.innerHTML = (showFirst && !tId) ? hideSymbol : showSymbol;
				} else tHeadings[tId] = child;
				child.tId = tId;
				child.style.cursor = 'pointer';
				child.title = 'Click to show/hide';
				child.onclick = toggleContents;
			} else if (child.className=='toggleContents') {
				child.style.display = (showFirst && !tId) ? '' : 'none';		
				child.tId = tId;
				tContents[tId] = child;
			}
		}
		// CHECK FOR REQUESTED ITEM VISIBILITY
		qs = location.href.split('?')[1];
		if (qs) {
			qsParts = qs.split('&');
			for(i=0;i<qsParts.length;i++) {
				part = qsParts[i].split('=');
				if (part[0]=='toggle') {
					if (t = parseInt(part[1])) {
						tId = 0;
						for (i=0;i<tData.childNodes.length;i++) {
							child = tData.childNodes[i];
							if (child.className=='toggleHeading') {
								tId++;
								if (tId==t) child.onclick();
							}
						}
					}
				}
			}
		}
		matchColumns();
	}
}




function toggleEl(elId) {
	el = document.getElementById(elId);
	el.style.display = (el.style.display=='block') ? 'none' : 'block';
	matchColumns();
}
