Nav = Class.create();
Nav.prototype = {
  initialize: function(nid, ntag, nclass) {
    this.n = $$(nid,ntag,nclass);
    this.ns = 's1';
    this.n.each(function(ni,i) {
      ni.onmouseover = function() {
        this.clear();
        $(this.ns).className = $(this.ns).className.replace(/\son/,'');
        this.ns = ni.className.match(/s\d/);
        ni.className += ' on';
        $(this.ns).className += ' on';
      }.bind(this);
    }.bind(this));
  },
  clear: function() {
    for (i=0; i<this.n.length; i++) {
      this.n[i].className = (!this.n[i].className.match(/on/)) ? this.n[i].className : this.n[i].className.replace(/\son/,'');
    }
  }
}

window.onload = function() {
  var s = new Nav('sidebar','span','nav');
}