var W3C = document.getElementById? true : false;
var NN4 = document.layers? true : false; //Netscape Navigator 4.x.
var IE4 = document.all? true : false; // IE version 4 and above.
var isHiding = false
var shownLayers = new Array(20) 
var shownLayersIndex = 0
var hidingLayers = new Array(20) 

for (i=0;i<20;i++) {
	shownLayers[i] = ""
}

function getIsHidingLayer (layerName) {
	if (isInShownLayers (layerName)) {
		//alert(indexInShownLayers (layerName) + " is " + hidingLayers [indexInShownLayers (layerName)])
		return hidingLayers [indexInShownLayers (layerName)]
	}
	
}

function setIsHidingLayer (layerName) {
	if (isInShownLayers (layerName)) {
		hidingLayers [indexInShownLayers (layerName)] = true
		//alert(indexInShownLayers (layerName) + "set to true")
	}
	
}

function clearIsHidingLayer (layerName) {
	if (isInShownLayers (layerName)) {
		hidingLayers [indexInShownLayers (layerName)] = false
		//alert(indexInShownLayers (layerName) + "set to false")
	}
	
}

function putInShownLayers (layerName) {
	if (!isInShownLayers (layerName)) {
		shownLayers[shownLayersIndex] = layerName
		shownLayersIndex = shownLayersIndex  + 1
	}
	
}

function isInShownLayers (layerName) {
	var isIn = false
	for (i=0;i<20;i++) {
		if (shownLayers[i] == layerName) {
			isIn = true
		}
	}
	return isIn
}

function indexInShownLayers (layerName) {
	var isIn = 0
	for (i=0;i<20;i++) {
		if (shownLayers[i] == layerName) {
			isIn = i
		}
	}
	return isIn
}

function hideAllExcept (layerName) {
	for (i=0;i<20;i++) {
		if (shownLayers[i] != "") {
			if (shownLayers[i] != layerName) {
				hide(shownLayers[i])
			}
		}
	}
}

function display(layerName) {
	putInShownLayers (layerName)
	//hideAllExcept (layerName)
	clearIsHidingLayer (layerName)
	if (W3C) {
		document.getElementById(layerName).style.visibility = "visible";
	} else if (IE4) {
		document.all[layerName].style.visibility = "visible";
	} else if(NN4) {
		document.layers[layerName].visibility = "show";
	}
}

function hide(layerName) {
	if (W3C) {
		document.getElementById(layerName).style.visibility = "hidden";
	} else if (IE4) {
		document.all[layerName].style.visibility = "hidden";
	} else if (NN4) {
		document.layers[layerName].visibility = "hidden";
	}
}

function delayedhide(layerName) {
	if (!getIsHidingLayer (layerName)) {
		setIsHidingLayer (layerName)
		setTimeout("Javascript:dodelayedhide('"+layerName+"')",1500)	
	}
}

function delayed2hide(layerName) {
	if (!getIsHidingLayer (layerName)) {
		setIsHidingLayer (layerName)
		setTimeout("Javascript:dodelayedhide('"+layerName+"')",800)	
	}
}

function dodelayedhide(layerName) {
	if (getIsHidingLayer (layerName)) {
		hide(layerName)
	}
}

function hideAll() {
alert(0)

	for (i=0;i<20;i++) {
		if (shownLayers[i] != "") {
				hide(shownLayers[i])
		}
	}
}

// <a href="javascript:void()" onMouseOver="display('meny1')" onMouseOut="delayedhide('meny1')">Display</a>
// <a href="javascript:void()" onMouseOver="hide('meny1')">Hide</a>
// <div id="meny1" name="meny1" style="VISIBILITY:hidden; position:absolute; left:130; top:149;" onMouseOver="display('meny1')">Test layer</div>

