function ToggleNavi(obj) {

  this.obj = obj;
  this.Cur = null;
  this.LIs = this.obj.getElementsByTagName('li');

  // Only useful for ul and ol lists at the moment
  if (!this.obj.tagName || (this.obj.tagName.toLowerCase() != 'ul' &&
                            this.obj.tagName.toLowerCase() != 'ol')) return;

  // Traverse through li elements
  for (var i = 0; i < this.LIs.length; ++i) {

    // If there are no links in the current li element
    if (this.LIs[i].getElementsByTagName('a').length == 0) {

      // Temporarily remove it
      this.Cur = this.LIs[i].parentNode.removeChild(this.LIs[i]);
    }

    // Hide all the other li elements
    this.LIs[i].className = 'hidden';
  }
  
  // Put it back at the beginning of the list
  this.obj.insertBefore(this.Cur, this.obj.childNodes[0]);

  // Set up toggle functionality
  this.Cur.t = true;
  this.Cur.LIs = this.LIs;
  this.Cur.onclick = function() {

    // Set class name depending on current toggle status
    this.className = (this.t ? 'selected' : '');

    // Same for the other elements
    for (var i = 1; i < this.LIs.length; i++) {

      this.LIs[i].className = (this.t ? 'visible' : 'hidden');
    }
    // Toggle
    this.t = !this.t;
  };

  this.toggle = function() {
 
    this.Cur.onclick();
 };

  this.show = function() {

    this.Cur.t = true;
    this.toggle();
  };

  this.hide = function() {

    this.Cur.t = false;
    this.toggle();
  };
}
