﻿(function ($) {
  $.fn.check = function () {
    return this.each(function () {
      var input = $(this);
      input.attr("checked", true);
    });
  };
  $.fn.uncheck = function () {
    return this.each(function () {
      var input = $(this);
      input.attr("checked", false);
    });
  };
  $.fn.toggleCheck = function () {
    return this.each(function () {
      var input = $(this);
      if (input.is(":checked"))
        input.uncheck();
      else
        input.check();
    });
  };
  $.fn.enable = function () {
    return this.each(function () {
      var input = $(this);
      input.attr("disabled", "");
    });
  };
  $.fn.disable = function () {
    return this.each(function () {
      var input = $(this);
      input.attr("disabled", "disabled");
    });
  };
  $.fn.fixStack = function () {
    var nextIndex = 999;
    return this.each(function () {
      var element = $(this);
      element.css('z-index', nextIndex);
      nextIndex -= 1;
    });
  };
})(jQuery);
