
// the following functions provide collapsed menus

// collect functions to execute when page is loaded
function addLoadEvent(func) {
 var oldonload = window.onload;
 if (typeof window.onload != 'function') {
  window.onload = func;
 } else {
  window.onload = function() {
   oldonload();
   func();
  }
 }
}

// collapses a menu create as <ul>-list
function menuCollapse( node ) {
 if (!node) return false;
 
 if (node.childNodes.length > 0) {
  for (var i=0; i < node.childNodes.length; i++) {
   var child = node.childNodes[i];
   if (child.nodeName == "UL") {
     child.style.display = "none";
   }
   menuCollapse( child );
  }		
  // add onclick event handler to open/close the menu
  node.onclick = function() {
   menuToggle( this );
   return false;
  }
 }
}

// toggle show/hide of a menu
function menuToggle( node ) {
 var ul = this.parentNode.getElementsByTagName("UL")[0];
 // if there are no submenus just pass link
 if (!ul) location.href = node.href;
 
 if (ul.style.display == "") {
  ul.style.display = "none";
 } else {
  ul.style.display = "";
 }
 alert(  ul.style.display );
 return false;
 
}


// decrypt hidden email-adress and open mailer
function cmailto( cryptedaddr ) {
  var str = unescape( cryptedaddr );
  var url = "mailto:";
  for ( var i=0; i < str.length; i++ ) {
    var char = str.charCodeAt(i) + i + 1;
    url = url.concat( unescape( "%" + char.toString( 16 ) ) );
  }
  location.href = url;
}






