var MAATCheckbox = Class.create({
  _id: null,
  _name: null,
  _style: null,
  _value: 0,
  _checkValue: 1,
  _readOnly: 0,
  _disable: 0,
  generate: function () {
    var check = new Element('input', {type:'checkbox',
                                    style: this._style,
                                    name: this.getName(),
                                    id: this.getId()
                          });

    if(this._readOnly == 1)
        check.writeAttribute({readonly: 'readonly'});
    if(this._disable == 1)
        check.writeAttribute({disabled: 'true'});

    if(this._value == 1) {
        check.setAttribute("checked", true);
        check.setAttribute('defaultChecked', 'defaultChecked');
    } else {
        check.removeAttribute('checked');
    }
    return check;
  },
  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;
  },
  isReadOnly: function (value) {
    this._readOnly = value;
  },
  isDisable: function (value) {
    this._disable = value;
  },
  setCheckValue: function (value) {
    this._checkValue = value;
  },
  setName: function (name) {
    this._name = name;
  },
  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);
  }
});
