function Toggle(id) {
  this.id = id;
  this.onToggle = function(ctrl){};  
}

Toggle.prototype.toggle = function() {
  var ctrl = this.getCtrl();
  this.setDisplay(ctrl.style.display == 'none' ? '' : 'none');
};

Toggle.prototype.setDisplay = function(display) {
  var ctrl = this.getCtrl();
  if (ctrl.style.display != display) {
    ctrl.style.display = display;
    this.onToggle(ctrl);    
  }
};

Toggle.prototype.getCtrl = function() {
  return document.getElementById(this.id);
};

function ControlGroup(id) {
  this.id = id;
  this.controls = new Array();
  this.current = null;
  this.adjustControls = function(tgl) {
    this.current = tgl;
    for(var i=0; i<this.controls.length; i++) {
      var ctrl = this.controls[i];
      if (ctrl != tgl) {
        ctrl.setDisplay('none');
      }
    }
  }
}

ControlGroup.prototype = new Toggle;
ControlGroup.prototype.constructor = ControlGroup;

ControlGroup.prototype.activate = function(tgl) {
  for(var i=0; i<this.controls.length; i++) {
    var ctrl = this.controls[i];
    if (ctrl != tgl) {
      ctrl.setDisplay('none');
    }
  }
  tgl.toggle();
}

ControlGroup.prototype.doToggle = function(tgl) {
  this.adjustControls(tgl);
  tgl.toggle();
}

ControlGroup.prototype.doActivate = function(tgl, display) {
  this.adjustControls(tgl);
  tgl.setDisplay(display);
}


ControlGroup.prototype.addControl = function(tgl) {
  this.controls[this.controls.length] = tgl;
}

function Button(id, lbl, href) {
  this.id = id;
  this.lbl = lbl;
  this.href = href;
}

function openW(url, name, w, h, features) {
  var winl = 0;
  var wint =0;
  if(screen.width) {
    winl = (screen.width  - w)/2;
    wint = (screen.height - h)/2;
  }
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  return window.open(url, name, settings);
}