Index: modules/user/access_control.js
===================================================================
RCS file: modules/user/access_control.js
diff -N modules/user/access_control.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/user/access_control.js	4 Oct 2006 15:33:54 -0000
@@ -0,0 +1,34 @@
+// $Id$
+
+/**
+ * Callback function that is attached to a change of a checkbox of the "anonymous user" column.
+ * It changes the state of all custom roles to that particular state.
+ */
+Drupal.accessControlToggle = function() {
+  var roles = Drupal.settings.user.roles, name = this.id.substr(7);
+  
+  for (var i in roles) {
+    if (roles[i] > 2) {
+      var checkbox = document.getElementById('edit-' + roles[i] + '-' + name);
+      checkbox.disabled = checkbox.checked = this.checked;
+    }
+  }
+};
+
+/**
+ * Attaches a onchange callback to each checkbox of the "anonymous user" column.
+ */
+Drupal.accessControlAttach = function() {
+  $('#permissions input').each(function() {
+    if (/^edit-2-.*$/i.test(this.id)) { // authenticated user
+      $(this).change(Drupal.accessControlToggle);
+      Drupal.accessControlToggle.apply(this);
+    }
+  });
+};
+
+
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.accessControlAttach);
+}
+
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.685
diff -u -d -F^\s*function -r1.685 user.module
--- modules/user/user.module	4 Oct 2006 06:20:38 -0000	1.685
+++ modules/user/user.module	4 Oct 2006 15:34:01 -0000
@@ -1801,6 +1801,9 @@ function user_admin_perm($str_rids = NUL
     $form['role_names'][$rid] = array('#type' => 'markup', '#value' => l($name, 'admin/user/access/'. $rid), '#tree' => TRUE);
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
+  
+  drupal_add_js(array('user' => array('roles' => array_keys($role_names))), 'setting');
+  drupal_add_js(drupal_get_path('module', 'user') .'/access_control.js', 'module');
 
   return $form;
 }
