function grlButton(arg) {
 grlWidget(this,arg);
 if(!this.on) this.on=Number(1);
 else this.on=Number(this.on);

 this.image = grl_getIm(this.id, this.id+"_img");
 
 if(this.up==null) {
  this.up=this.image.src;
   var pic=this.up.slice(0,-4);
  this.down=pic+"d.png";
  this.over=this.up;
 }

 this.image.src=this.down;
 this.image.src=this.over;
 this.image.src=this.up;

 this.value=null;
 this.attr=null;
 this.target=null;
}

grlButton.prototype.trackAttr=function(target, attr, value) {
 this.target=target;
 this.attr=attr;
 this.value=value;
}

grlButton.prototype.roll=function() {
 if(!this.on)
  this.image.src=this.over;
}

grlButton.prototype.draw=function() {
 if(this.target)  {
//  alert(this.id + " tracks: " + this.attr + " val: " + this.target[this.attr]); 
   this.on = Number(this.target[this.attr] == this.value);
}

 if(this.on) this.image.src=this.down;
 else this.image.src=this.up;
}

function grlImage(arg) {
 grlWidget(this, arg);
}

