function DivObj(name, id) {
  this.name = name;
  this.elem = null;
  this.id = id;
  this.incstep = 20;
  this.speed = 50;
  this.opacity = 0;
  this.minopacity = 0;
  this.visiblemode = "display";
  this.onOpened = null;
  this.width = null;
  this.height = null;
  this.slidedir = "vertical";
  this.beforeShow = null;
  this.visible = false;

  this.reset = function() {
    this.elem = null;
  }

  this.getElem = function() {
    if (this.elem == null) this.elem = document.getElementById(this.id);
    return this.elem;
  }

  this.setContent = function(html) {
    this.getElem().innerHTML = html;
  }

  this.slideOut = function() {
    if (this.beforeShow) this.beforeShow(this);
    if (this.getElem()) {
      if (this.visiblemode == "visibility") this.getElem().style.visibility = "visible";
      else this.getElem().style.display = "block";
      if (this.slidedir == "vertical") {
        this.getElem().style.height = "0px";
        this.incHeight();
      }
      else {
        this.getElem().style.width = "0px";
        this.incWidth();
      }
    }
  }

  this.slideIn = function() {
    if (this.getElem()) {
      if (this.slidedir == "vertical") {
        this.getElem().style.height = this.height + "px";
        this.decHeight();
      }
      else {
        this.getElem().style.width = this.width + "px";
        this.decWidth();
      }
    }
  }

  this.getCurrSize = function(type) {
    var aStr = (type == "width" ? this.getElem().style.width : this.getElem().style.height);
    return parseInt(aStr.substring(0, aStr.length-2));
  }

  this.incHeight = function() {
    var currHeight = this.getCurrSize("height");
    if (currHeight < this.height) {
      currHeight += this.incstep;
      if (currHeight > this.height) currHeight = this.height;
      this.getElem().style.height = currHeight + "px";
      setTimeout(this.name + ".incHeight()", this.speed);
    }
    else {
      if (this.onOpened) eval(this.onOpened + "()");
      this.visible = true;
    }
  }

  this.decHeight = function() {
    var currHeight = this.getCurrSize("height");
    if (currHeight > 0) {
      currHeight -= this.incstep;
      if (currHeight <= 0) {
        currHeight = 0;
        if (this.visiblemode == "visibility") this.getElem().style.visibility = "hidden";
        else this.getElem().style.display = "none";
      }
      this.getElem().style.height = currHeight + "px";
      setTimeout(this.name + ".decHeight()", this.speed);
    }
    else
      this.visible = false;
  }

  this.incWidth = function() {
    var currWidth = this.getCurrSize("width");
    if (currWidth < this.width) {
      currWidth += this.incstep;
      if (currWidth > this.width) currWidth = this.width;
      this.getElem().style.width = currWidth + "px";
      setTimeout(this.name + ".incWidth()", this.speed);
    }
    else {
      if (this.onOpened) eval(this.onOpened + "()");
      this.visible = true;
    }
  }

  this.decWidth = function() {
    var currWidth = this.getCurrSize("width");
    if (currWidth > 0) {
      currWidth -= this.incstep;
      if (currWidth < 0) {
        currWidth = 0;
        if (this.visiblemode == "visibility") this.getElem().style.visibility = "hidden";
        else this.getElem().style.display = "none";
      }
      this.getElem().style.width = currWidth + "px";
      setTimeout(this.name + ".decWidth()", this.speed);
    }
    else
      this.visible = false;
  }

  this.show = function() {
    if (this.beforeShow) this.beforeShow(this);
    if (this.getElem()) {
      if (this.visiblemode == "visibility") this.getElem().style.visibility = "visible";
      else this.getElem().style.display = "block";
    }
    this.visible = true;
  }

  this.hide = function() {
    if (this.getElem()) {
      if (this.visiblemode == "visibility") this.getElem().style.visibility = "hidden";
      else this.getElem().style.display = "none";
    }
    this.visible = false;
  }

  this.fadeIn = function() {
    if (this.beforeShow) this.beforeShow(this);
    if (this.getElem()) {
      this.opacity = 0;
      if (this.visiblemode == "visibility") this.getElem().style.visibility = "visible";
      else this.getElem().style.display = "block";
      this.incOpacity();
    }
  }

  this.fadeOut = function() {
    if (this.getElem()) {
      this.opacity = 100;
      this.decOpacity();
    }
  }

  this.setOpacity = function() {
    this.getElem().style.filter = "alpha(opacity:"+this.opacity+")";
    this.getElem().style.KHTMLOpacity = this.opacity/100;
    this.getElem().style.MozOpacity = this.opacity/100;
    this.getElem().style.opacity = this.opacity/100;
  }

  this.incOpacity = function() {
    if (this.opacity < 100) {
      this.opacity += this.incstep;
      if (this.opacity > 100) this.opacity = 100;
      this.setOpacity();
      setTimeout(this.name + ".incOpacity()", this.speed);
    }
    else {
      if (this.onOpened) eval(this.onOpened + "()");
      this.visible = true;
    }
  }

  this.decOpacity = function() {
    if (this.opacity > this.minopacity) {
      this.opacity -= this.incstep;
      if (this.opacity <= this.minopacity) {
        this.opacity = this.minopacity;
        if (this.minopacity == 0) {
          if (this.visiblemode == "visibility") this.getElem().style.visibility = "hidden";
          else this.getElem().style.display = "none";
        }
      }
      this.setOpacity();
      setTimeout(this.name + ".decOpacity()", this.speed);
    }
    else
      this.visible = false;
  }
}
