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";
	}
	//alert("hid "+layerName)
}

function delayedhide(layerName) {
	if (!getIsHidingLayer (layerName)) {
		setIsHidingLayer (layerName)
		setTimeout("Javascript:dodelayedhide('"+layerName+"')",500)	
	}
}

function delayed2hide(layerName) {
	if (!getIsHidingLayer (layerName)) {
		setIsHidingLayer (layerName)
		setTimeout("Javascript:dodelayedhide('"+layerName+"')",500)	
	}
}

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>



function bildescript(bilde) {

 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = screen.availWidth;
    myHeight = screen.availHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = screen.availWidth;
    myHeight = screen.availHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = screen.availWidth;
    myHeight = screen.availHeight;

    bildebredde = (myWidth/2) - (640/2)
    bildehoyde = (myHeight/2) - (530/2)
  }

var bildevindu = window.open("", "bildevindu", "width=640,height=530"); // window object
//alert(bildebredde)
//alert(bildehoyde)

bildevindu.document.open("text/html", "replace");
bildevindu.document.write("<HTML><HEAD><TITLE>Bildevindu</TITLE></HEAD><BODY marginwidth=0 marginheight=0 topmargin=0 leftmargin=0><center><img src='gfx/referanser/" + bilde + "'><br><form><input type='button' onClick='Javascript:self.close()' value='Lukk vindu'></form></center></BODY></HTML>");
bildevindu.document.close();
bildevindu.moveTo(bildebredde,bildehoyde)
bildevindu.focus()

}




