function TimerLabel(id, classid, text, direction, time) {
  this.id = id;
  this.count = 0;
  this.classid = classid;
  this.time = time;
  this.text = text;
  this.direction = direction;
  this.msgnode = null;
  this.isPrinted = false;
  this.container = null;
}

TimerLabel.prototype.setText = function(text) {
  this.text = text;
  this.msgnode.innerHTML = this.text;
}

TimerLabel.prototype.getText = function() {
  return this.text;
}

TimerLabel.prototype.setContainer = function(c) {
  this.container = c;
}

TimerLabel.prototype.getID = function() {
  return this.id;
}

TimerLabel.prototype.getMsgNode= function() {
  return this.msgnode;
}

TimerLabel.prototype.print = function(txt) {
  if (this.isPrinted) return;
  var refNode = document.getElementById(this.id);
  if (refNode) {
    var l = getAbsoluteLeft(this.id);
    var t = getAbsoluteTop(this.id);
    if (this.container != null) {
      l = getRelativeLeft(this.id, this.container.id);
      t = getRelativeTop(this.id, this.container.id);
    } else if (document.getElementById('divBody') != null) {
      l = getRelativeLeft(this.id, 'divBody');
      t = getRelativeTop(this.id, 'divBody');
    }
    var left = l;
    var top = t;
    var width = refNode.offsetWidth;
    if (width <= 100) {
      width = 100;
    }
    if (this.direction == 'top') {
    } else {
      top = top + refNode.offsetHeight;
      top = top - 5;
    }

    this.msgnode = createNode('div', {'id':'msg_' + this.id, 'class':this.classid});
    if (txt != null) {
      this.msgnode.innerHTML = txt + this.text;
      if (isFireFox()) {
        width = width - parseInt(getStyle(this.msgnode, 'padding-left'));
      }
      this.msgnode.style['width'] = width+'px';
    } else {
      this.msgnode.innerHTML = this.text;
    }
    this.msgnode.style['position'] = 'absolute';
    //this.msgnode.style['position'] = 'relative';
    this.msgnode.style['left'] = left;
    this.msgnode.style['top'] = top;
    this.msgnode.style['zindex'] = 200;
    //this.msgnode.style['background'] = '#eeeeee';
    this.isPrinted = true;

    var outer = this.container;
    if (outer == null) {
      outer = document.getElementById('divBody');
    }
    if (outer != null) {
      outer.appendChild(this.msgnode);
    } else {
      document.body.appendChild(this.msgnode);
    }
    if (this.time > 0) {
      var instance = this;
      this.count++;
      var ccount = this.count;
      setTimeout(function() {remove(instance, ccount);}, this.time);
      registerObjEvent(this.msgnode, 'click', function() {remove(instance, ccount);}, false);
    }
  }
}

TimerLabel.prototype.toclose = function() {
  if (this.isPrinted) {
    if (document.getElementById('msg_' + this.id)) {
      var outer = this.container;
      if (outer == null) {
        outer = document.getElementById('divBody');
      }
      if (outer != null) {
        outer.removeChild(document.getElementById('msg_' + this.id));
      } else {
        document.body.removeChild(document.getElementById('msg_' + this.id));
      }
    }
  }
  this.isPrinted = false;
}

function remove(tl, count) {
  if (tl.isPrinted == true && tl.count == count) {
    tl.toclose();
  }
}

