I wrote the following to hide and show layers a few weeks back. This will work in NS4, NS6, IE4, IE5, and IE5.5 NS6 and IE5.5 will use the same branch of logic.
The shoCat takes the name of a layer that will be shown. It then takes the LastLayer and sets it to hidden so that you have only one call to make. So something like this is how it would be used. You first need to set the LastLater to a real div name, start by setting all of your divs to hidden. The following will show the div Content2 and hide the Content1 layer it if it is not hidden when you clicked on the link.
<a href="javascript: showCat('Content2')">Link</a>
<script language="javascript">
LastLayer = "Content1";
function showCat(theLayer){
if (document.getElementById) { // if it's IE5 or NS6 use this syntax to access the visiblity attribute
eval('document.getElementById(\"' + LastLayer + '\").style.visibility = "hidden"')
eval('document.getElementById(\"' + theLayer + '\").style.visibility = "visible"')
LastLayer = theLayer;
}
if(document.layers) { // if it's NS4 use this syntax to access the visiblity attribute
eval('document.layers[\"' + LastLayer + '\"].visibility = "hidden"')
eval('document.layers[\"' + theLayer + '\"].visibility = "visible"')
LastLayer = theLayer;
}
if (document.all) { // if it's IE4 use this syntax to access the visiblity attribute
eval(LastLayer + '.style.visibility = "hidden"')
eval(theLayer + '.style.visibility = "visible"')
LastLayer = theLayer;
}
}
</script>