var MAATMiniButton = Class.create({
  _id: null,
  _name: null,
  _style: null,
  _value: null,
  _url: null,
  _image: null,
  _onClick: null,
  generate: function () {
    var min = new Element('img', {'src' : this._image,
                                  'style': 'float: left; cursor: pointer;'+this._style,
                                  'name': this.getName(),
                                  'id': this.getId()//,
                                  //'onclick': this._onClick
                         });
    if (this._url) {
        var a = new Element('a', {'href' : this._url, 'class' : 'ahide'});
        a.insert(min).insert(this._value);
        min = a;
    }
//    if (this._onClick) {
//        //min.stopObserving('click', this._onClick);
//        //Event.stopObserving(min, 'click', this._onClick);
//        this.addObservator(min, 'click', this._onClick);
//    }

    return min;
  },
  getName: function () {
    if (this._name == null) {
      return this.getId();
    } else {
      return this._name;
    }
  },
  getId: function () {
    return this._id;
  },
  setStyle: function (style) {
    this._style = style;
  },
  setValue: function (value) {
    this._value = value;
  },
  setName: function (name) {
    this._name = name;
  },
  setOnClick: function (onClick) {
    this._onClick = onClick;
  },
  setUrl: function (url) {
    this._url = url;
  },
  setImage: function (image) {
    this._image = image;
  },
  setId: function (id) {
    id.sub(/[^0-9a-zA-Z_]+/, '');
    this._id = id;
  },
  addObservator: function(eventName, action) {
      $(this._id).observe(eventName, function (event) {
            var element = event.element();
            eval(action);
      });
  },
  setEvent: function(eventName, action) {
      this.addObservator(eventName, action);
  }
});
