dojo.provide("parus.controlActions");

dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.Select");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.SimpleTextarea");
dojo.require("dijit.form.NumberTextBox");

dojo.require("parus.parus8");
dojo.require("parus.dialog");
dojo.require("parus.treeDialog");
dojo.require("parus.groupBox");
dojo.require("parus.dictEdit");
dojo.require("parus.formats");


if (!parus) parus = {};

if (!parus.controlActions) dojo.mixin(parus, {
  controlActions: {}
});


dojo.mixin(parus.controlActions, {

  setDisabled: function(control, disabled) {
    control.attr("disabled", disabled);
    if (disabled) {
      if (control.isInstanceOf(dijit.form.CheckBox))
        control.attr("checked", false);
      else if (control.isInstanceOf(parus.dictEdit))
        control.attr("value", null);
      else if (control.isInstanceOf(dijit.form.ValidationTextBox) || control.isInstanceOf(dijit.form.SimpleTextarea))
        control.attr("value", null);
      else if (control.isInstanceOf(dijit.form.Select))
        control.attr("value", 0);
      else if (control.isInstanceOf(dijit.NumberTextBox))
        control.attr("value", 0);
    }
  }

});