
//venstre menu
if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

	var menu = "DCMenuSelection";
	var link = "DCMenuLink";

window.onload = function () {
	hs = new Array();
	uniq = 0;
	for(i=0; i<document.links.length; i++) { 
		//if (document.links[i].onclick == null)
		document.links[i].onclick=saveLink;
		id = document.links[i].id;
		if (id == '') {
			id = document.links[i].href;
			id = id.replace(/&DCMenuSelection=.*/,'');
		} 
		while (hs[id] != null) {id += uniq++;}
		hs[id]++;
		document.links[i].id = id;
	}
	SwitchMenu(null , null);
 }



function saveLink() {
	res = this.id.match(/setmenu-(.*)/);
	if (res) SetCookie(menu, res[1], null, '/');
	SetCookie(link, this.href, null, '/');
//	alert("in savelink: " + res[1] + " - " + this.href);
}

function SwitchMenu(objp,redp){
	 obj = objp;
	 red = redp;
	if (obj == null) {
		res = window.location.search.match(/&DCMenuSelection=([^&]*)/) ;
		if (res != null) {
			obj = res[1];
		}
	}
	if (red == null) {
		res = window.location.search.match(/&DCMenuLink=([^&]*)/) ;
		if (res != null) {
			red = res[1];
		}
	}
	if (obj == null) obj = GetCookie(menu);
	if (red == null) red = GetCookie(link);
	if (red != null) red = red.replace(/&DCMenuSelection=.*/,'');
	SetCookie(menu, 'nomenu', null, '/');
	SetCookie(link, 'nored', null, '/');
	if(document.getElementById){
		var el = document.getElementById(obj);
		if (el == null) { return;}
		var on = el.style.display == "block" && objp != null;
		var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
		for (var i=0; i<ar.length; i++) {
				if (ar[i].className=="submenu") ar[i].style.display = "none";
		}
		if (obj != null) {
			if (on) {
				el.style.display = "none";
				return;			
			}
			el.style.display = "block";
			//alert("in Switch: " + red);
			var as = document.getElementById(red);
			if (as != null) {
				as.style.color = "red";
				SetCookie(link, red, null, '/');
			}
			SetCookie(menu, obj, null, '/');
		}
	}
//	alert("exiting Switchmenu: " + GetCookie(menu) + objp + " - " + GetCookie(link) + redp);
}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
 

/*  top.consoleRef=window.open('','myconsole', */
/*   'width=350,height=250' */
/*    +',menubar=0' */
/*    +',toolbar=1' */
/*    +',status=0' */
/*    +',scrollbars=1' */
/*    +',resizable=1'); */
/*     */
/*  top.consoleRef.document.writeln( */
/*   '<html><head><title>Console</title></head>' */
/*    +'<body bgcolor=white onLoad="self.focus()">'); */

//top menu
if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.submenutop{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenutop(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdivtop").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenutop") 
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
		
		
	}
}

