//  Vars:
//    divName is the name of the surrounding div (prefixed to rowname)
//    defSel is the rowId to be selected at startup
//
function itemHandler(divName, w, h) {
  // initialize the member variables for this instance
  if (divName != null) {
     this.name = divName;
  } else { alert("Item Handler Must have a name."); }


  this.leftVal = 0;
  this.topVal = 0;
  this.width = w;
  this.height = h;

  // initialize the member function references
  this.decLeft = decLeft;
  this.decTop = decTop;

  this.setLeft = setLeft;
  this.setTop = setTop;

  this.getLeft = getLeft;
  this.getTop = getTop;

  this.setSize = setSize;
  this.getWidth = getWidth;
  this.getHeight = getHeight;
  this.setVisible = setVisible;
  this.init = init;
  this.setImage = setImage;



function setImage(nImage) {
     if (document.getElementById(this.name) != null) {
         document.getElementById(this.name).style.background = 'url("'  + nImage + '")';
     }
}


function init() {
     if (document.getElementById(this.name) != null) {
         this.width = document.getElementById(this.name).style.width;
         this.height = document.getElementById(this.name).style.height;
     } else { alert("Item: " + this.name + " not found!"); }
}

function setVisible(isVis) {
  if (isVis == 1) {
     if (document.getElementById(this.name) != null) {
         document.getElementById(this.name).style.visibility = "visible";
     }
  } else {
     if (document.getElementById(this.name) != null) {
         document.getElementById(this.name).style.visibility = "hidden";
     }
  }
}


function getHeight() {
   return this.height;
}

function getWidth() {
   return this.width;
}

function setSize(wVal, hVal) {
   this.width = wVal;
   if (document.getElementById(this.name) != null) {
      document.getElementById(this.name).style.width = this.width;
   }
   this.height = hVal;
   if (document.getElementById(this.name) != null) {
      document.getElementById(this.name).style.height = this.height;
   }
}

function getLeft() {
   return this.leftVal;
}

function getTop() {
   return this.topVal;
}

function setLeft(lVal) {
   this.leftVal = lVal;
   if (document.getElementById(this.name) != null) {
      document.getElementById(this.name).style.left = this.leftVal;
   }
}

function setTop(tVal) {
   this.topVal = tVal;
   if (document.getElementById(this.name) != null) {
      document.getElementById(this.name).style.top = this.topVal;
   }
}

function decLeft(decVal) {
   this.leftVal = this.leftVal - decVal;
   if (document.getElementById(this.name) != null) {
      document.getElementById(this.name).style.left = this.leftVal;
   }
}

function decTop(decVal) {
   this.topVal = this.topVal - decVal;
   if (document.getElementById(this.name) != null) {
      document.getElementById(this.name).style.top = this.topVal;
   }
}


} // close the class
