diff -aur support.orig/support.module support/support.module
--- support.orig/support.module	2011-11-30 16:51:41.000000000 -0200
+++ support/support.module	2011-12-29 19:14:55.484814429 -0200
@@ -191,6 +191,12 @@
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
+  $items['support/update_ticket'] = array(
+    'page callback' => 'support_update_ticket_js',
+    // TODO: implement real access control
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
   $items['admin/support'] = array(
     'title' => 'Support ticketing system',
     'description' => 'Manage the support ticket system.',
@@ -339,25 +345,43 @@
  */
 function support_autocomplete_assigned($clid = 0, $string = '') {
   $matches = array();
-  if ($string) {
-    if ($clid) {
-      $client = db_result(db_query('SELECT name FROM {support_client} WHERE clid = %d', $clid));
-      // retrieve all roles giving permission to access current tickets
-      $result = db_query("SELECT rid FROM {permission} WHERE perm LIKE '%%%s%%' OR perm LIKE '%%%s%%'", "access $client tickets", 'administer support');
-    }
-    $roles = array();
-    while ($role = db_fetch_object($result)) {
-      $roles[$role->rid] = $role->rid;
-    }
-    // also get people with administer support permissions
-    $result = db_query("SELECT rid FROM {permission} WHERE perm LIKE '%%%s%%'", 'administer support');
-    while ($role = db_fetch_object($result)) {
-      $roles[$role->rid] = $role->rid;
-    }
-    if (!empty($roles)) {
-      $result = db_query_range("SELECT u.name FROM {users} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid IN (%s) AND u.status = 1 AND LOWER(name) LIKE LOWER('%s%%')", implode(', ', $roles), $string, 0, 10);
-      while ($user = db_fetch_object($result)) {
-        $matches[$user->name] = check_plain($user->name);
+  if (!empty($string) && $clid) {
+    $client = db_result(db_query('
+      SELECT name
+        FROM {support_client}
+        WHERE clid = %d',
+      $clid
+    ));
+    if ($client) {
+      $roles = array();
+      $result = db_query("
+        SELECT rid
+          FROM {permission}
+          WHERE perm LIKE '%%%s%%'
+            OR perm LIKE '%%%s%%'",
+        "access $client tickets",
+        'administer support'
+      );
+      while ($role = db_fetch_object($result)) {
+        $roles[$role->rid] = $role->rid;
+      }
+      if (!empty($roles)) {
+        $result = db_query_range("
+          SELECT u.name
+            FROM {users} u
+              LEFT JOIN {users_roles} r
+                ON u.uid = r.uid
+            WHERE r.rid IN (%s)
+              AND u.status = 1
+              AND LOWER(name) LIKE LOWER('%s%%')",
+          implode(', ', $roles),
+          $string,
+          0,
+          10
+        );
+        while ($user = db_fetch_object($result)) {
+          $matches[$user->name] = check_plain($user->name);
+        }
       }
     }
   }
@@ -653,7 +677,7 @@
 /**
  * Implementation of hook_form().
  */
-function support_form(&$node) {
+function support_form(&$node, $form_state) {
   $type = node_get_types('type', $node);
 
   $form['title'] = array(
@@ -664,8 +688,7 @@
     '#weight' => -5,
   );
 
-  $reference = array();
-  $form = array_merge($form, support_status_form($reference, $node, ''));
+  $form = array_merge($form, support_status_form($form_state, $node, '', TRUE));
 
   $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
 
@@ -687,7 +710,7 @@
     );
   }
 
-  $form = array_merge($form, support_subscribe_form($reference, $node, ''));
+  $form = array_merge($form, support_status_form($form_state, $node, '', TRUE));
 
   return $form;
 
@@ -1663,7 +1686,7 @@
     if (isset($node) && is_object($node) && isset($node->type) &&
       $node->type == 'support_ticket') {
       $reference = array();
-      $form = array_merge(support_status_form($form_state, $form, ''), $form);
+      $form = array_merge(support_status_form($form_state, $form, '', FALSE), $form);
       $form = array_merge($form, support_subscribe_form($reference, $form, ''));
       $form['comment_filter']['comment']['#title'] = t('Update');
       unset($form['_author']);
@@ -2032,8 +2055,9 @@
  * Generate form for adding update to ticket.  Enhances comment_form adding
  * a ticket status bar.
  */
-function support_status_form(&$form_state, $edit, $title) {
+function support_status_form(&$form_state, $edit, $title, $include_ahah_for_client) {
   global $user;
+
   $cid = 0;
   if (is_array($edit)) {
     if (is_array($edit['nid'])) {
@@ -2048,6 +2072,18 @@
   else {
     $node = $edit;
   }
+
+  if (isset($form_state['assigned_per_client'])) {
+    $node = $form_state['assigned_per_client'] + (array) $node;
+    $node = (object) $node;
+  }
+  /**
+   * If the node has a client defined, register it in the auxiliar session
+   * variable.
+   */
+  if (isset($node->client)) {
+    $_SESSION['support_client'] = $node->client;
+  }
   $autoassign = _support_autoassign(_support_current_client(), $user->uid);
   if ($autoassign && !isset($node->assigned) &&
       (!isset($node->nid) || !$node->nid)) {
@@ -2071,8 +2107,7 @@
       user_access('can administer state')) {
     $form['support'] = array(
       '#type' => 'fieldset',
-      '#prefix' => '<div class="container-inline">',
-      '#suffix' => '</div>',
+      '#attributes' => array('class' => 'container-inline'),
       '#title' => t('Ticket properties'),
     );
   }
@@ -2157,13 +2192,52 @@
       '#prefix' => '&nbsp;&nbsp;',
       '#title' => t('Client'),
       '#options' => $clients,
-      '#default_value' => is_numeric($node->client) ? $node->client : 0,
+      '#default_value' => (int) $node->client,
     );
+    /**
+     * Only including AHAH for client editing to automatically update assigned
+     * field per client if asked by the caller.
+     *
+     * Right now it's enabled only for ticket creation but not for comment
+     * inclusion.
+     *
+     * In ticket creation everything seems to be working just fine.
+     *
+     * In comment inclusion, if AHAH is enabled (even if it's not used) you can
+     * never save the new comentary as the "Save" button is never presented. As
+     * far as I could debug, it has something to do with the form being cached
+     * when AHAH is enabled and the form not being cached when AHAH is disabled.
+     *
+     * This difference happens inside drupal_get_form as result of the
+     * form_get_cache call on line 89.
+     *
+     * TODO: make automatic update of assigned field work on comment inclusion
+     * also.
+     *
+     * UPDATE: Apparently the incompatibility with client AHAH and comments only
+     * happens if the user tries to pre-visuazlize the comment before posting.
+     * If he saves it straight away everything wroks fine.
+     */
+//    if ($include_ahah_for_client) {
+      $form['support']['client']['#ahah'] = array(
+        'path' => 'support/update_ticket',
+        'wrapper' => 'support-assigned-wrapper',
+      );
+//    }
   }
+  /**
+   * <div> wrapper to the assigned form field that might have to be recreated on
+   * client dropdown change.
+   */
+  $form['support']['assigned_wrapper'] = array(
+    '#tree' => FALSE,
+    '#prefix' => '<div id="support-assigned-wrapper">',
+    '#suffix' => '</div>',
+  );
   if (!user_access('can assign tickets to self') &&
       !user_access('can assign tickets to any user') &&
       !user_access('administer support')) {
-    $form['support']['assigned'] = array(
+    $form['support']['assigned_wrapper']['assigned'] = array(
       '#type' => 'hidden',
       '#value' => $node->assigned ? $node->assigned : 0,
     );
@@ -2183,7 +2257,7 @@
       else {
         $assigned = '';
       }
-      $form['support']['assigned'] = array(
+      $form['support']['assigned_wrapper']['assigned'] = array(
         '#type' => 'textfield',
         '#prefix' => '&nbsp;&nbsp;',
         '#title' => t('Assigned'),
@@ -2193,7 +2267,7 @@
       );
     }
     else {
-      $form['support']['assigned'] = array(
+      $form['support']['assigned_wrapper']['assigned'] = array(
         '#type' => 'select',
         '#prefix' => '&nbsp;&nbsp;',
         '#title' => t('Assigned'),
@@ -3283,6 +3357,71 @@
 }
 
 /**
+ * ahah callback for client dropdown.
+ */
+function support_update_ticket_js() {
+  module_load_include('inc', 'node', 'node.pages');
+  $form_state = array(
+    'storage' => NULL,
+    'submitted' => FALSE,
+    'rebuild' => TRUE,
+  );
+  $form_build_id = $_POST['form_build_id'];
+
+  $form = form_get_cache($form_build_id, $form_state);
+
+  $args = $form['#parameters'];
+  $form_id = array_shift($args);
+
+  $form['#post'] = $_POST;
+  $form['#redirect'] = FALSE;
+  $form['#programmed'] = FALSE;
+  $form_state['post'] = $_POST;
+
+  /**
+   * Disabling the 'required' attribute of all fiels so their emptyness doesn't
+   * triggers validation errors during form rebuild for AHAH.
+   */
+  $form = _support_remove_required_attribute($form);
+
+  $assigned_per_client = $_POST;
+  drupal_process_form($form_id, $form, $form_state);
+
+  $form_state['assigned_per_client'] = $assigned_per_client;
+
+  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
+
+  $assigned = $form['support']['assigned_wrapper'];
+  // we'll unset the div to make sure it won't be repeated!
+  unset($assigned['#prefix'], $assigned['#suffix']);
+  $javascript = drupal_add_js(NULL, NULL, 'header');
+  drupal_json(array(
+    'status'   => TRUE,
+    'data'     => theme('status_messages') . drupal_render($assigned), // rebuild just the part that needs to be changed
+    'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
+  ));
+}
+
+/**
+ * Returns a copy of the form element with all #required attributes removed.
+ */
+function _support_remove_required_attribute($form) {
+  if (!is_array($form)) {
+    return $form;
+  }
+  $new_form = array();
+  foreach ($form as $key => $value) {
+    if (is_array($value)) {
+      $new_form[$key] = _support_remove_required_attribute($value);
+    }
+    elseif ($key !== '#required') {
+      $new_form[$key] = $value;
+    }
+  }
+  return $new_form;
+}
+
+/**
  * Callback access function for 'support/autocomplete/autosubscribe' menu item.
  *
  * @return <bool>
