// set up the variables used var hasLayers = false; var objPrefix = "D"; if (document.layers) { hasLayers = true; objPrefix="L" } // preload the images - need this for IE 6 var imgArray = new Array(); imgArray[0] = new Image(30,20); imgArray[1] = new Image(30,20); imgArray[0].src = "/icons/expand.gif"; imgArray[1].src = "/icons/collapse.gif"; function hideDivs() { // if order for the divs to show in NS 4.7x, they cannot be hidden using style="display:none" so, in dom2 browsers // (IE 5 and above, NS 6.2) we need to programmatically hide them when the page is first loaded. Note that // this can be very slow in NS 6.2 if (hasLayers == false) { var divArray = document.getElementsByTagName("DIV"); for (var i=0; i < divArray.length; i++) { divArray[i].style.display="none"; } } } // end of hideDivs() function hideShow(name) { //try { var imgName = name + "Img"; var imgObj; var toggle; var isOnDisplay = true; if (hasLayers == false) { imgObj = document.images[imgName]; // this gets the div since its id is "D" + the category name (objPrefix is defined above) toggle=document.getElementById(objPrefix + name); isOnDisplay = toggle.style.display==""; toggle.style.display = isOnDisplay ? "none" : ""; } // end of if does NOT use layers else { imgObj = document.layers[name].document.images[imgName]; // this gets the inner layer since its id is "L" + the category name (objPrefix is defined above) toggle = document.layers[name].document.layers[objPrefix + name]; isOnDisplay = toggle.visibility == "show"; toggle.visibility = isOnDisplay ? "hide" : "show"; // to give the appearance of expanding and collapsing the layer, I am actually moving all the // layers below the selected one up or down on the page. When I expand a category, the //subsequent layers move down, when I collapse a category the subsequent layers move up. //This technique can be slow so it is not appropriate for very large views. // get amount to adjust layers below this one - if the layer is visible it means we are going to be // hiding it so the yOffset must be negative so subsequent layers are moved up yOffset = isOnDisplay ? -toggle.clip.height : toggle.clip.height; // find the index of the current outer layer object // Go throught the array of outer layers looking for the one with the correct name numLayers = window.document.layers.length; var layerObj = null; var index=null; for (var i =0; i < numLayers; i++) { layerObj = document.layers[i]; if (layerObj.name == name) { index = i; break; } } // end of for to find index // next move all subsequent layers by yOffset for(var j=index+1; j < numLayers; j++) { layerObj = document.layers[j]; // move remaining objects up or down layerObj.moveBy(0,yOffset); } } // end of else // update the image based on the value of isOnDisplay //imgObj.src=isOnDisplay ? imgArray[0].src : imgArray[1].src; //"expand.gif" : "collapse.gif"; } // end of hideShow