/*
This Script is COPYRIGHTED by DIAPHONI A/S Denmark.
Contact us at webmaster@diaphoni.dk
*/
var mi = false
var ns = false
var n6 = false
var op = false
var sa = false
var mac = false
if (navigator.appName.charAt(0)=="M"){
	if (window.innerWidth > 0) {
		op = true
	} else {
		mi = true
	}
}
else if (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko") || navigator.appName=="Opera") {
	n6 = true
}
else {
	ns=true
}
if (navigator.appVersion.indexOf('Macintosh') >= 1) {
	mac = true
}
if (navigator.vendor == 'Apple Computer, Inc.') {
	sa = true
}

var items = new Array()
var topelemwidth = new Array()
var subelempos = new Array()
var xoff=0
var xoffsubs=0
var yoff=0
var hereto=0
var width=100
var height=20
var heightn1=20
var n2off=5
var adress=""
var last=""
var previous=""
var t
var y
var h
var ob="'"
var str=""
var scroll=true
var date=true
var overcolor = ""
var outcolor = ""
var winwidth1 = ""
var cu = false
var menualign = "left"
var space = 0
var borderSepWidth = 3

function remlast() {
	hide(last)
	hide(previous)
}

function remprevious() {
	hide(previous)
}

function timer(what){
	if ( what == "set"){
		t = setTimeout("remlast()",50)
	}
}

function timerpre(what){
	if ( what == "set"){
		y = setTimeout("remprevious()",50)
	}
}

function cleartimer(){
		clearTimeout(t)
}

function cleartimerpre(){
		clearTimeout(y)
}

function show(layname) {
	if ( layname.length == 7 ){
		hide(previous)
	}
	else {
		hide(last)
		hide(previous)
	}
	if (ns) {
		document.layers[layname].visibility = "show"
	}
	else if (mi || op || n6) {
		document.getElementById(layname).style.visibility = "visible"
	}
}

function hide(layername) {
	if (ns) {
		document.layers[layername].visibility = "hide"
	}
	else if (mi || op || n6) {
		document.getElementById(layername).style.visibility = "hidden"
	}
}

function mouseover(name,showthis){
	showHideFormElements()
	if ( name.length > 2 || showthis != "" )
		cleartimer()
	if ( name.length == 7 && showthis.length == 7 )
		cleartimerpre()
	if ( name.length >= 9 )
		cleartimerpre()
	if ( showthis!="" ){
		show(showthis)
		if ( showthis.length == 7 ){
			previous=showthis
		}
		else {
			last=showthis
		}
	}
	if ( showthis.length == 7 )
		previous=showthis
}

function mouseout(name){
	timer("set")
	if (name.length < 9){
		timerpre("set")
	}
	showHideFormElements()
}

function presure(gowhere){
	if(gowhere.indexOf("opentipafriend") >= 0) {
		tipenven()
	}
	else if(gowhere.indexOf("openprinter") >= 0) {
		openprinter()
	}
	else if(gowhere.indexOf("opensitemap") >= 0) {
		opensitemap()
	}
	else if(gowhere.indexOf("openpopup") >= 0) {
		gowhere = gowhere.replace("openpopup","")
		var newwin = window.open(gowhere, 'popup', 'menubar,toolbar,location,scrollbars,status,resizable')
	}
	else if(gowhere!="") {
		if (cu == "ja"){
			afslutgem(gowhere)
		} else {
			location.href = gowhere;
		}
	}
}

function callbackfill(name,fillwidth){
	items[hereto]=name
	space = fillwidth
	var content=""
	if (date){
		var dnew = new Date()
		content = dnew.getDay()
		if (content==0){content="Sunday"}
		if (content==1){content="Monday"}
		if (content==2){content="Tuesday"}
		if (content==3){content="Wednesday"}
		if (content==4){content="Thursday"}
		if (content==5){content="Friday"}
		if (content==6){content="Saturday"}
		content += (" " + dnew.getDate() + "/" + (dnew.getMonth()+1))
	}
	str += ('<div id="'+name+'" style="Position:Absolute;visibility:hidden;left:'+xoff+';Z-Index:10"><table border="0" width="'+fillwidth+'" cellpadding="0" cellspacing="0"><tr><td class="back" align="right" width="'+fillwidth+'" height="'+heightn1+'">'+content+'&nbsp;</td></tr></table></div>')
	hereto++
}
function startmenuitem(name){
	topelemwidth[0] = xoffsubs
	items[hereto]=name
	if (mi || n6 || op)
		str += ('<div id="'+name+'" style="Position:Absolute;visibility:hidden;left:'+xoffsubs+';Z-Index:20"><table border="0" id="menuLevel1Table" cellpadding="0" cellspacing="0"><tr>')
	if (ns){
		str += ('<div id="'+name+'" style="Position:Absolute;visibility:hidden;left:'+xoffsubs+';Z-Index:20;"><table border="1" cellpadding="0" cellspacing="0"><tr>')
	}
	hereto++;
	h = 1
}
function makemenuitem(name,subname,caption,href,thiswidth){
	if (parseInt(thiswidth,10) > 1) {
		topelemwidth[h] = parseInt(thiswidth,10)
		thisalign = "left"
	} else {
		topelemwidth[h] = width
		thisalign = "left"
	}
	if (mi || n6 || op)
		if (h > 1) {
			str += ('<td class="outn1">&nbsp;</td>')
		}
		str += ('<td class="outn1" width="'+topelemwidth[h]+'" align="'+thisalign+'" height="'+heightn1+'" onMouseOver='+ob+'className="overn1" ; mouseover("'+name+'","'+subname+'")'+ob+' onMouseOut='+ob+'className="outn1" ; mouseout("'+name+'")'+ob+' onClick='+ob+'presure("'+href+'")'+ob+' style="padding-left:3px;">'+caption+'</td>')
	if (ns)
		str += ('<td class="outn1" height="'+heightn1+'"><ILAYER><LAYER height="'+height+'" width="'+topelemwidth[h]+'" onfocus='+ob+'presure("'+href+'")'+ob+' onmouseover='+ob+'this.bgColor="'+overcolor+'";mouseover("'+name+'","'+subname+'")'+ob+' onmouseout='+ob+'this.bgColor="'+outcolor+'";mouseout("'+name+'")'+ob+'>'+caption+'</layer></ilayer></td>')
	if (mi || op) { topelemwidth[h] += borderSepWidth }
	if (n6) { topelemwidth[h] += borderSepWidth }
	h++
}
function endmenuitem(){
	if (!ns) { str += ('<td class="outn1">&nbsp;</td>') }
	str += ('</tr></table></div>')
	h = 0
}
function startsubitem(name){
	items[hereto]=name
	last = name
	h = parseInt("0"+name.charAt(3)+name.charAt(4),10)
	h -= 1
	var xdist=0
	for ( i=0 ; i <= h ; i++) {
		xdist += topelemwidth[i]
	}
	xdist += h * borderSepWidth + 1
	if (xdist + width > (parseInt(space,10)+parseInt(xoff,10))) { xdist = (parseInt(space,10)+parseInt(xoff,10)) - width }
	subelempos[h] = xdist
	if (mi || n6 || op){
		str += ('<div id="'+name+'" style="visibility: hidden; cursor:hand; Position : Absolute ; left : '+xdist+' ; Z-Index : 20"><table width="'+width+'" cellpadding="0" cellspacing="0"><tr><td><table border="0" width="'+width+'" cellpadding="0" cellspacing="0">')
	}
	if (ns){
		xdist += h
		str += ('<div id="'+name+'" style="visibility: hidden; Position : Absolute ; left : '+xdist+' ; top : '+yoff+'px ; Z-Index : 20"><table cellpadding="0" cellspacing="0" border=1"><tr><td><table border="0" cellpadding="0" cellspacing="0">')
	}
	hereto++
	h++
}
function makesubitem(name,subname,caption,href){
	if (subname==""){
		if (mi || n6 || op)
			str += ('<tr><td class="out" height="'+height+'" onMouseOver='+ob+'className="over" ; mouseover("'+name+'","")'+ob+' onMouseOut='+ob+'className="out" ; mouseout("'+name+'")'+ob+' onClick='+ob+'presure("'+href+'")'+ob+' style="padding-left:3px;">'+caption+'</td></tr>')
		if (ns)
			str += ('<tr><td class="out" height="'+height+'"><ILAYER><LAYER height="'+height+'" width="'+width+'" onfocus='+ob+'presure("'+href+'")'+ob+' onmouseover='+ob+'this.bgColor="'+overcolor+'";mouseover("'+name+'","")'+ob+' onmouseout='+ob+'this.bgColor="'+outcolor+'";mouseout("'+name+'")'+ob+'>&nbsp;'+caption+'</layer></ilayer></td></tr>')
	} else {
		if (mi || n6 || op){
			str += ('<tr><td class="out" height="'+height+'" onMouseOver='+ob+'className="over" ; mouseover("'+name+'","'+subname+'")'+ob+' onMouseOut='+ob+'className="out" ; mouseout("'+name+'")'+ob+' onClick='+ob+'presure("'+href+'")'+ob+' style="padding-left:3px;">'+caption+'<img src="'+adress+'" width="9" height="10" border="0" style="position : absolute ; left : ')
			str += ((width-16)+' ; top : ')
			temp = ((parseInt("0"+subname.charAt(5)+subname.charAt(6),10)-1)*height)+(height/3-2)
			str += (temp+'"></td></tr>')
		}
		if (ns){
			str += ('<tr><td class="out" height="'+height+'"><ILAYER><LAYER height="'+height+'" width="'+width+'" onfocus='+ob+'presure("'+href+'")'+ob+' onmouseover='+ob+'this.bgColor="'+overcolor+'";mouseover("'+name+'","'+subname+'")'+ob+' onmouseout='+ob+'this.bgColor="'+outcolor+'";mouseout("'+name+'")'+ob+'>&nbsp;'+caption+'&nbsp;<img src="'+adress+'" width="9" height="10" border=0></layer></ilayer></td></tr>')
		}
	}
}
function endsubitem(){
	str += ('</td></tr></table></table></div>')
}
function startsubsubitem(name){
	items[hereto]=name
	previous = name
	h = parseInt("0"+name.charAt(3)+name.charAt(4),10)
	h -= 1
	var xdist = subelempos[h]
	xdist += width
	if (mi) {
		if ( xdist+width > document.body.clientWidth )
			xdist -= (2*width+2)
	}
	else {
		if ( xdist+width > window.innerWidth )
			xdist -= (2*width+2)
	}
	str += ('<DIV ID="'+name+'" style="visibility: hidden; cursor:hand; Position : Absolute ; left : '+xdist+' ; Z-Index : 20"><table border="0" width="'+width+'" cellpadding="0" cellspacing="0" style="border-top:1px solid #A6A5A3;">')
	hereto++;
}
function makesubsubitem(name,caption,href){
	var sub1num = name.charAt(3) + name.charAt(4)
	str += ('<tr><td class="out" height="'+height+'" width="'+width+'" onMouseOver='+ob+'className="over" ; mouseover("'+name+'","")'+ob+' onMouseOut='+ob+'className="out" ; mouseout("'+name+'")'+ob+' onClick='+ob+'presure("'+href+'")'+ob+' style="padding-left:5px;">'+caption+'</td></tr>')
}
function endsubsubitem(){
	str += ('</td></tr></table></table></div>')
}
function setmenu(){
	if ( last=="" ) {
		startsubitem("sub01")
		endsubitem()
	}
	if ( previous=="" ) {
		startsubsubitem("sub0101")
		endsubsubitem()
	}
	//alert(str.length)
	document.write(str)
}
function makestatic(){
	var byoff = 0
	if (n6 || mi || op) {
		if ( scroll && n6 )
			byoff = window.pageYOffset
		else if (scroll && (mi || op))
			byoff = document.body.scrollTop
		var temp = ""
		for ( var i = 0; i < hereto; i++ ) {
			temp = items[i]
			elm = document.getElementById(temp).style
			if ( temp.charAt(6) ){
				elm.top = byoff + yoff + ((parseInt("0"+temp.charAt(5)+temp.charAt(6),10)-1)*height) + heightn1 + n2off
			} else if ( temp.charAt(4) ){
				elm.top = (byoff + yoff + heightn1)
			} else {
				elm.visibility = "visible"
				elm.top = (byoff + yoff)
			}
		}
	}
	else if (ns) {
		if ( scroll )
			byoff = window.pageYOffset
		for ( var i = 0; i < hereto; i++ ) {
			var temp1 = items[i]
			if ( temp1.charAt(6) ){
				document.layers[temp1].top = (byoff + (yoff + ((parseInt("0"+temp1.charAt(5)+temp1.charAt(6),10)-1)*height)) + heightn1 ) + n2off
			}	else if ( temp1.charAt(4) ){
				document.layers[temp1].top = (byoff + yoff + heightn1)
			}	else {
				document.layers[temp1].visibility = "show"
				document.layers[temp1].top = (byoff + yoff)
			}
		}
	}
	if (menualign != "left") {
		alignmenu()
	}
	if ( scroll ){
		setTimeout("makestatic()",50)
	}
}

function refresh(){
	location.reload()
}

function alignmenu() {
	mostleft = parseInt(topelemwidth[0],10) //48
	mostright = mostleft + parseInt(space,10) //968
	itemswidth = borderSepWidth //531

	for (i=1;i<=topelemwidth.length-1;i++) {
		itemswidth += (topelemwidth[i]) //borderSepWidth is added in setmenuitem
	}

	document.getElementById("menuLevel1Table").style.width = itemswidth
	
	level1count = 0
	var menuBoxesCount = 1 //make sure subitems are positioned correct in x
	var level1dists = new Array()
	if (menualign == "right") {
		level1off = mostright - itemswidth
	}
	else if (menualign == "center") {
		level1off = (( mostright - itemswidth - mostleft ) / 2 ) + mostleft
	}
	for (i=1;i<=items.length-1;i++) {
		if (items[i].length == 1) { //level1
			document.getElementById(items[i]).style.left = level1off
		}
		else if (items[i].length == 5) { //level2
			temp1 = (parseInt("0"+items[i].charAt(3)+items[i].charAt(4),10))
			for (var t = menuBoxesCount; t < temp1; t++) {
				level1off += parseInt(topelemwidth[t],10) //+ borderSepWidth
				menuBoxesCount++
			}
			document.getElementById(items[i]).style.left = level1off
			level1dists[temp1] = level1off + width //save position for subsubs
			level1count++
		}
		else if (items[i].length == 7) { //level3
			temp1 = (parseInt("0"+items[i].charAt(3)+items[i].charAt(4),10))//-1)
			xdist = level1dists[temp1] //+ 1
			if (mi) {
				if ( xdist+width > document.body.clientWidth )
					xdist -= (2*width+2)
			}
			else {
				if ( xdist+width > window.innerWidth )
					xdist -= (2*width+2)
			}
			document.getElementById(items[i]).style.left = xdist
		}
	}
	menualign = "left" //this prevents alignmenu to be run again if scroll=true
	putpostit()
}

function showHideFormElements() {
	for (var intI = 0; intI < document.forms.length; intI++) {
		for (var i=0 ; i < document.forms[intI].elements.length ; i++) {
			if (document.forms[intI].elements[i].tagName == "SELECT") {
				if (document.forms[intI].elements[i].style.visibility == "hidden") {
					document.forms[intI].elements[i].style.visibility = "inherit"
				} else {
					document.forms[intI].elements[i].style.visibility = "hidden"
				}
			}
		}
	}
}

window.onresize=refresh
