/*****************************************************************\
* Product:   JavaScript Framework                                 *
* File:      element.js                                           *
* Author:    Ties Pull ter Gunne                                  *
* Copyright: (c) 1999 Ties Pull ter Gunne                         *
* License:   No Restrictions                                      *
\*****************************************************************/

//=============== class Element ======================

function Element() {
    this.baseElem = null;
}

Element.prototype.alignLeft = function() {
  return this.align.toUpperCase() == "LEFT";
}

Element.prototype.alignRight = function() {
  return this.align.toUpperCase() == "RIGHT";
}

Element.prototype.alignTop = function() {
  return this.valign.toUpperCase() == "TOP";
}

Element.prototype.alignBottom = function() {
  return this.valign.toUpperCase() == "BOTTOM";
}

Element.prototype.getLeft = function() {
  var elm = this.baseElem;
  var left = 0;
  while (elm != null && elm.tagName.toUpperCase() != "BODY") {
    left += elm.offsetLeft;
    elm = elm.offsetParent;
  }
  return left;
}

Element.prototype.getRight = function() {
  if (this.baseElem != null && this.baseElem.offsetWidth != null)
    return this.getLeft()+this.baseElem.offsetWidth;
  return this.getLeft();
}

Element.prototype.getTop = function() {
  var elm = this.baseElem;
  var tp = 0;
  while (elm != null && elm.tagName.toUpperCase() != "BODY") {
    tp += elm.offsetTop;
    elm = elm.offsetParent;
  }
  return tp;
}

Element.prototype.getBottom = function() {
  if (this.baseElem != null && this.baseElem.offsetHeight != null) 
    return this.getTop()+this.baseElem.offsetHeight;
  return this.getTop();
}

Element.prototype.getWidth = function() {
  return this.baseElem.offsetWidth-2;
}

Element.prototype.getHeight = function() {
  return this.baseElem.offsetHeight;
}
