/*
This Script is COPYRIGHTED by DIAPHONI A/S Denmark.
Contact us at webmaster@diaphoni.dk
*/
var mi = false
var n6 = false
var op = 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
}
if (navigator.appVersion.indexOf('Macintosh') >= 1) {
	mac = 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=30
var n2off=5
var adress=""
var last=""
var previous=""
var t
var y
var h
var ob="'"
var str=""
var scroll=true
var winwidth1 = ""
var cu = false
var menualign = "left"
var space = 0 //space in backfill if menualign = right
var borderSepWidth = 1
var firstSubXoffset = -1
var CurrentN1Active

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)
	}
	document.getElementById(layname).style.visibility = "visible"
}

function hide(layername) {
	document.getElementById(layername).style.visibility = "hidden"
}

function mouseover(name,showthis){
	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")
	}
}

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 changeClassName(num,status) {
	if (document.getElementById("Mn1_left_" + num)) { document.getElementById("Mn1_left_" + num).className = status + "n1_left n1color_" + num }
	if (document.getElementById("Mn1_center_" + num)) { document.getElementById("Mn1_center_" + num).className = status + "n1 n1color_" + num }
	if (document.getElementById("Mn1_right_" + num)) { document.getElementById("Mn1_right_" + num).className = status + "n1_right n1color_" + num }
}

function callbackfill(name,fillwidth){
	items[hereto]=name
	space = fillwidth
	var content=""
	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+'">&nbsp;</td></tr></table></div>')
	hereto++
}
function startmenuitem(name){
	topelemwidth[0] = xoffsubs
	items[hereto]=name
	str += ('<div id="'+name+'" style="position:absolute;visibility:hidden;left:'+xoffsubs+';Z-Index:20;"><table border="0" 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 = "center"
	} else {
		topelemwidth[h] = width
		thisalign = "center"
	}
	if (h > 1) {
		str += ('<td class="outn1" style="background-image:url(custom/design/saga_menu_splitter.gif); width:2px;"><img src="custom/design/blank1x1.gif" border="0" alt="" width="2" height="1"></td>')
	}
	if (h == CurrentN1Active) {
		//str += ('<td id="Mn1_left_' + h + '" class="overn1_left n1color_' + h + '">&nbsp;</td>')
		str += ('<td id="Mn1_center_' + h + '" class="activen1" width="'+topelemwidth[h]+'" align="'+thisalign+'" height="'+heightn1+'" onMouseOver='+ob+'mouseover("'+name+'","'+subname+'")'+ob+' onMouseOut='+ob+'mouseout("'+name+'")'+ob+' onClick='+ob+'presure("'+href+'")'+ob+'>'+caption+'</td>')
		//str += ('<td id="Mn1_right_' + h + '" class="overn1_right n1color_' + h + '">&nbsp;</td>')
	} else {
		//str += ('<td id="Mn1_left_' + h + '" class="outn1_left n1color_' + h + '">&nbsp;</td>')
		str += ('<td id="Mn1_center_' + h + '" class="outn1" width="'+topelemwidth[h]+'" align="'+thisalign+'" height="'+heightn1+'" onMouseOver='+ob+'changeClassName(' + h + ',"over") ; mouseover("'+name+'","'+subname+'")'+ob+' onMouseOut='+ob+'changeClassName(' + h + ',"out") ; mouseout("'+name+'")'+ob+' onClick='+ob+'presure("'+href+'")'+ob+'>'+caption+'</td>')
		//str += ('<td id="Mn1_right_' + h + '" class="outn1_right n1color_' + h + '">&nbsp;</td>')
	}
	topelemwidth[h] += borderSepWidth
	h++
}
function endmenuitem(){
	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 = firstSubXoffset //0
	for ( i=0 ; i <= h ; i++) {
		xdist += topelemwidth[i]
	}
	xdist += h * borderSepWidth + 1
	subelempos[h] = xdist
	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:2px solid #FFFFFF;">')
	hereto++
	h++
}
function makesubitem(name,subname,caption,href){
	var sub1num = name.charAt(3) + name.charAt(4)
	if (subname==""){
		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:7px;"><img src="custom/design/saga_menu_dots.gif" border="0" align="absmiddle">&nbsp;&nbsp;'+caption+'</td></tr>')
	} else {
		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:7px;"><img src="custom/design/saga_menu_dots.gif" border="0" align="absmiddle">&nbsp;&nbsp;'+caption+'<img src="'+adress+'" width="7" height="7" border="0" style="position : absolute ; left : ')
		str += ((width-12)+' ; top : ')
		temp = ((parseInt("0"+subname.charAt(5)+subname.charAt(6),10)-1)*height)+(height/2-1)
		str += (temp+'"></td></tr>')
	}
}
function endsubitem(){
	str += ('</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 + 1
	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:2px solid #FFFFFF;">')
	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 += ('</table></div>')
}
function setmenu(){
	if ( last=="" ) {
		startsubitem("sub01")
		endsubitem()
	}
	if ( previous=="" ) {
		startsubsubitem("sub0101")
		endsubsubitem()
	}
	//alert(str)
	document.write(str)
}
function makestatic(){
	var byoff = 0
	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)
		}
	}
	if (menualign != "left") {
		alignmenu()
	}
	if ( scroll ){
		setTimeout("makestatic()",50)
	}
}

function refresh(){
	location.reload()
}

function alignmenu() {
	mostleft = parseInt(topelemwidth[0],10)
	mostright = mostleft + parseInt(space,10)
	itemswidth = borderSepWidth

	for (i=1;i<=topelemwidth.length-1;i++) {
		itemswidth += (topelemwidth[i] + borderSepWidth)
	}

	level1count = 0
	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) {
			document.getElementById(items[i]).style.left = level1off
		}
		else if (items[i].length == 5) {
			document.getElementById(items[i]).style.left = level1off
			level1dists[level1count] = level1off + width //save position
			level1off += parseInt(topelemwidth[i-1],10) + borderSepWidth //add width and borderwidth
			level1count++
		}
		else if (items[i].length == 7) {
			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()
}

window.onresize=refresh