dojo.provide("parus.gridFormatConditionDialog");

dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");

dojo.require("parus.parus8");
dojo.require("parus.dialog");

dojo.declare("parus.gridFormatConditionDialog", [parus.Dialog], {


  fieldsAsOptions: null,

  postCreate: function() {
    this.inherited(arguments);
    this.colorSelect.attr("options", parus.parus8.colorOptions());
    this.fieldSelect.attr("options", this.fieldsAsOptions);
  },

  modeChanged: function() {
    this.maskEdit.attr("disabled", !this.useMask.checked);
    this.fromEdit.attr("disabled", this.useMask.checked);
    this.toEdit.attr("disabled", this.useMask.checked);


    if (!this.useMask.checked) {
      dojo.addClass(this.maskLabel, "balanceReadOnlyHeader");
      dojo.removeClass(this.fromLabel, "balanceReadOnlyHeader");
      dojo.removeClass(this.toLabel, "balanceReadOnlyHeader");
    }
    else {
      dojo.removeClass(this.maskLabel, "balanceReadOnlyHeader");
      dojo.addClass(this.fromLabel, "balanceReadOnlyHeader");
      dojo.addClass(this.toLabel, "balanceReadOnlyHeader");
    }

    if (this.maskEdit.disabled) this.maskEdit.attr("value", "");
    if (this.fromEdit.disabled) this.fromEdit.attr("value", "");
    if (this.toEdit.disabled) this.toEdit.attr("value", "");

  },

  validate: function() {
    var valid = this.inherited(arguments);
    if (valid && this.useRange.checked) if (!this.fromEdit.value && !this.toEdit.value) valid = false;
    return valid;

  }

});