var sections = new Array();

function Section(link) {
  this.link       = link;
  this.name       = this.link.hash.substr(1);
  this.item       = this.link.parentNode;

  this.show = function() {
    if (this.item.className == 'active') {
      this.item.className = 'inactive';
    } else {
      this.item.className = 'active';
    }
  }
  this.hide = function() {
    this.item.className = 'inactive';
  }

  this.link.Section = this;
  this.link.onclick = function() {
    toggleSections(this.Section.name);
  }
}

function toggleSections(section) {
  for (var i = 0, n = sections.length; i < n; i++) {
    if (section == sections[i].name) {
      sections[i].show();
    } else {
      sections[i].hide();
    }
  }
}

addLoadEvent( function() {
  var section = (location.hash.substr(1)) ? location.hash.substr(1) : null;

  if (document.getElementById('content')) {
    var links = document.getElementById('content').getElementsByTagName('a');

    for (var i = 0, n = links.length; i < n; i++) {
      sections[i] = new Section(links[i]);
    }

    toggleSections(section);
  }
} );

