function errSubsys() {
  this.$_errorcontainer = $('#errorcontainer');
  this.$_errorbar = $('#errorbar');
  this.$_errorbarghost = $('#errorbarghost');
  this.clearErrs();
  
  this.LIST_ID   = 0;
  this.LIST_NAME = 1;
  this.LIST_MSG  = 2;
}

errSubsys.prototype.show = function() {
  if (this.errList.length > 0) {
    this.makeList();
    this.$_errorcontainer.slideDown('slow');
    hdrHeight = $('#errorbar').height();
    $('#errorbarghost').animate({height: hdrHeight});
    $('.hdradjust').css('top', -hdrHeight);
  } else {
    this.hide();
  }
}

errSubsys.prototype.hide = function() {
  this.clearErrs();
  this.$_errorcontainer.slideUp('slow');
  this.$_errorbarghost.animate({height: 0}, 'slow');
  $('#errorlist').html('');
  $('div.errmsg').remove();
  $('input.error').removeClass('error');
}

errSubsys.prototype.addErr = function(formID, fldName, errMsg) {
  this.errList[this.errList.length] = [formID, fldName, errMsg];
}

errSubsys.prototype.clearErrs = function() {
  if (typeof(this.errList) != 'undefined') {
    // remove existing errors from form
    var sz = this.errList.length;
    for (var i = 0; i < sz; ++i) {
      formID = this.errList[i][this.LIST_ID];
      fldName = this.errList[i][this.LIST_NAME];
      var $_el = $('#' + formID + ' input[name=' + fldName + ']');
      $_el.removeClass('error');
      $('#' + formID + ' .errmsg').remove();
    }
  }
  this.errList = new Array();
}

errSubsys.prototype.makeList = function() {
  var sz = this.errList.length;
  var s = '<ul>';
  for (i = 0; i < sz; ++i) {
    formID = this.errList[i][this.LIST_ID];
    fldName = this.errList[i][this.LIST_NAME];
    msg = this.errList[i][this.LIST_MSG];
    id_name = formID + '_' + fldName;
    s += '<li><a href="' + location.href + '#' + id_name + '">' + msg + '</a></li>';
    var $_el = $('#' + formID + ' input[name=' + fldName + ']');
    var $_div = $_el.parent();
    $_el.addClass('error');
    if ($('div.errmsg', $_el.parent()).text() == '') {
      $_el.before('<div class="errmsg">' + msg + '</div>');
      $_div.before('<div id="' + id_name + '" class="hdradjust"></div>');
    }
  }
  s += '</ul>';
  $('#errorlist').html(s);
}

