//<script> 
// <script type="text/javascript" src="updateMenu.js"> 
/* (c) Copyright Gaute Sandvik 2007, 2008             
    This script is only needed in framesets.  */


// create event:  body.onload=initMenu() 
var oldonload = window.onload;
var NewLoad = function(){initMenu();}
if (typeof(NewLoad) != 'function') NewLoad=function(){};
if (typeof(oldonload) == 'function')
 window.onload = function(){oldonload(); NewLoad()};
else window.onload = function(){NewLoad()};


function collapseMenu(){
 var L=Anchors.length;
 for(var i=0; i<L; i++){
  var E = Anchors.item(i);
  var found=false;
  while( !found && E.nextSibling ){
   E = E.nextSibling; 
   if ( E.nodeType == 1 && E.tagName == "UL" ){
    E.className="hide"
    found=true;
   }
  }
 }
}

function openBranch(element){
 var parent=element.parentNode;
 if(parent.nodeType==1 && parent.tagName=="UL" ){
  parent.className="activeparent"
 }
 if(parent.id!="menu_vert") openBranch(parent);
}

var currentPage=null;
function updateMenu(pagename){
 if(pagename!=currentPage){
  collapseMenu();
  for(var i=0; i<Anchors.length; i++){
   var A = Anchors.item(i);
   A.className="normal"; 
   if (A.pagename == pagename ){
    currentPage = pagename;
    A.className="currentpage";
    openBranch(A);
    // show children:
    var found=false;
    var E=A
    while (!found && E.nextSibling ){
     E = E.nextSibling; 
     if (E.nodeType == 1 && E.tagName == "UL" ){
      E.className="show";
 	    found=true;
	    }
   	} 
   }	
  }
 }
}

// onload:
var Anchors = new Array();
function initMenu(){

 var MENU_VERT=document.getElementById("menu_vert"); 
 Anchors = MENU_VERT.getElementsByTagName("a");
 
 for(var i=0; i<Anchors.length; i++){
  var A = Anchors.item(i);
  var SP= A.href.split("/")
  A.pagename= SP[SP.length-1];
 }
 
 var hash = location.hash;
 if (hash.charAt(0)=="#") hash=hash.substring(1,hash.length);
 
 if (hash!='')
  updateMenu(hash); 
 else{
  var BSL=String.fromCharCode(92);
  var FSL=String.fromCharCode(47);
  var hrefString = top.mainframe.location.href;
  var hrefArray  = hrefString.split(BSL);
  var pathString = hrefArray.join(FSL); 
  var pathArray  = pathString.split(FSL);
  var fileName   = pathArray.pop();
  
  if(fileName)  
   updateMenu(fileName);   
  else
   updateMenu("mainpage.html");
 }
}



// reload menu after login or logout
function logIn(logged){
  location.hash=currentPage;
  location.reload();
}

//end updateMenu.js





