var MAATSelect = Class.create({
  _id: null,
  _name: null,
  _style: null,
  _value: null,
  _elements: {},
  _complex: [],
  generate: function () {
    var select = new Element('select', {'id': this.getId()});
    if (this._elements) {
        for (var key in this._elements) {
            var option = new Element('option', {'value' : key}).update(this._elements[key]);
            var copxObj = this._complex[key];
            for (var it in copxObj) {
                option.writeAttribute(it, copxObj[it]);
            }
            option.selected = (key == this._value) ? true: false;
            select.insert(option);
        }
    }
    return select;
  },
  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;
  },
  setElements: function (elements) {
    if(typeof(elements) == 'object')
        this._elements = elements;
    else {
        if(typeof(elements) == 'string') {
            if(elements.isJSON())
                this._elements = elements.evalJSON();
        }
    }
  },
  setComplexElements: function (elements) {
    if(typeof(elements) == 'object') {
        if(Object.isArray(elements)) {
            this._complex = elements;
        }
    }
  },
  setName: function (name) {
    this._name = name;
  },
  setId: function (id) {
    id.sub(/[^0-9a-zA-Z_]+/, '');
    this._id = id;
  }
});
