var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}

//confirm("isDHTML = " + isDHTML + "\nisLayers = " + isLayers + "\nisAll = " + isAll + "\nisID = " + isID);

function findDOM(objectID,withStyle) {
	if (withStyle == 1) {
		if (isID) { return (document.getElementById(objectID).style) ; }
		else { 
			if (isAll) { return (document.all[objectID].style); }
		else {
			if (isLayers) { return (document.layers[objectID]); }
		};}
	}
	else {
		if (isID) { return (document.getElementById(objectID)) ; }
		else { 
			if (isAll) { return (document.all[objectID]); }
		else {
			if (isLayers) { return (document.layers[objectID]); }
		};}
	}
}

var pastStart = false;

function toggleMenu(objectID) {
	//confirm("toggleMenu: " + objectID + "; arrTOC = " + arrTOC);
	var domStyle = findDOM(objectID,1);
	
	if (isAll || isID) {
		//confirm("object: " + objectID + ", display=" + domStyle.display);
		domStyle.display = (domStyle.display=='block') ? 'none' : 'block';
		if (!pastStart) domStyle.display = 'none';		// collapse groups at startup
	} else {
		// Netscape 4--Lots more work to do
		domStyle.visibility = (domStyle.visibility=='show') ? 'hidden' : 'show';
		var dom = findDOM(objectID, 0);
		var objHeight = dom.clip.height;		// height of TOC item
		if (domStyle.visibility=="hide") objHeight *= -1;	// to move items upwards
		
		var bBelowObj = false;					// are we below the TOC item?

		for (var i=0; i<arrTOC.length; i++) {
			//confirm(arrTOC[i] + " =? " + objectID);
			if (arrTOC[i] == objectID) {
				bBelowObj = true;				// found item; set flag
			} else if (bBelowObj) {
				var tStyle = findDOM(arrTOC[i],1);		// style object of other item
				tStyle.moveBy(0,objHeight);				// move other item up/down
			}
		}
	}
}

function collapseGroups() {
	// hides group members
	for (var i=0; i<arrGroups.length; i++) {
		var TOCitem = arrGroups[i] + "Group";
		toggleMenu(TOCitem);
	}
	pastStart = true;
}