// from: http://www.netlobo.com/div_hiding.html
function toggleLayer(whichLayer) {
    if (document.getElementById) {
        // this is the way the standards work
        var elem = document.getElementById(whichLayer);
        elem.style.display = (elem.style.display == "none") ? "block" : "none";
    } else if (document.all) {
        // this is the way old msie versions work
        var elem = document.all[whichLayer];
        elem.style.display = (elem.style.display == "none") ? "block" : "none";
    } else if (document.layers) {
        // this is the way nn4 works
        var elem = document.layers[whichLayer];
        elem.style.display = (elem.style.display == "none") ? "block" : "none";
    }

	return true;
}

// from: http://www.netlobo.com/div_hiding.html
function toggleNavLayer(whichLayer) {
	var parentName = whichLayer.substring(0,4);

	toggleLayer(whichLayer);

	if (document.getElementById) {
		// this is the way the standards work
		var elem = document.getElementById(whichLayer);
		document.getElementById(parentName).className = (elem.style.display == "none" || elem.style.display == "") ? "divBoxLevel1" : "divBoxLevel1Selected";
	} else if (document.all) {
		// this is the way old msie versions work
		var elem = document.all[whichLayer];
		document.all[whichLayer].className = (elem.style.display == "none" || elem.style.display == "") ? "divBoxLevel1" : "divBoxLevel1Selected";
	} else if (document.layers) {
		// this is the way nn4 works
		var elem = document.layers[whichLayer];
		document.layers[whichLayer].className = (elem.style.display == "none" || elem.style.display == "") ? "divBoxLevel1" : "divBoxLevel1Selected";
	}
}


function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = (strTag == '*' && document.all && !window.opera) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

// To cover IE 5.0's lack of the push method
Array.prototype.push = function(value) {
  this[this.length] = value;
}


function initStaff() {
	var layers = getElementsByClassName("divStaffLevel2Body");

	for (var i = 0; i < layers.length; i++) {
		layers[i].style.display="none";
	}

	return true;
}


function initNav() {
	var layers = getElementsByClassName("divSub");

	for (var i = 0; i < layers.length; i++) {
		layers[i].style.display="none";
	}

	return true;
}


function initAll() {
	initNav();
	initStaff();
}


/*
 * Make Mozilla fire the initAll event immediately after the content is read.
 * This window.onload only fires after everything (including images) are loaded.
 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", initAll, false);
}

window.onload=initAll;
