Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.537.2.8
diff -u -F^f -r1.537.2.8 common.inc
--- includes/common.inc	26 Aug 2006 14:19:09 -0000	1.537.2.8
+++ includes/common.inc	23 Sep 2006 13:57:09 -0000
@@ -116,7 +116,7 @@ function drupal_set_html_head($data = NU
 function drupal_get_html_head() {
   $output = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
   $output .= theme('stylesheet_import', base_path() .'misc/drupal.css');
-  return $output . drupal_set_html_head();
+  return $output . drupal_get_js() . drupal_set_html_head();
 }
 
 /**
@@ -1216,24 +1216,145 @@ function drupal_add_link($attributes) {
 }
 
 /**
- * Add a JavaScript file to the output.
+ * Add a JavaScript file, setting or inline code to the page.
  *
- * The first time this function is invoked per page request,
- * it adds "misc/drupal.js" to the output. Other scripts
- * depends on the 'killswitch' inside it.
- */
-function drupal_add_js($file, $nocache = FALSE) {
-  static $sent = array();
-
-  $postfix = $nocache ? '?'. time() : '';
-  if (!isset($sent['misc/drupal.js'])) {
-    drupal_set_html_head('<script type="text/javascript" src="'. base_path() .'misc/drupal.js'. $postfix .'"></script>');
-    $sent['misc/drupal.js'] = true;
-  }
-  if (!isset($sent[$file])) {
-    drupal_set_html_head('<script type="text/javascript" src="'. check_url(base_path() . $file) . $postfix .'"></script>');
-    $sent[$file] = true;
+ * The behavior of this function depends on the parameters it is called with.
+ * Generally, it handles the addition of JavaScript to the page, either as
+ * reference to an existing file or as inline code. The following actions can be
+ * performed using this function:
+ *
+ * - Add a file ('core', 'module' and 'theme'):
+ *   Adds a reference to a JavaScript file to the page. JavaScript files
+ *   are placed in a certain order, from 'core' first, to 'module' and finally
+ *   'theme' so that files, that are added later, can override previously added
+ *   files with ease.
+ *
+ * - Add inline JavaScript code ('inline'):
+ *   Executes a piece of JavaScript code on the current page by placing the code
+ *   directly in the page. This can, for example, be useful to tell the user that
+ *   a new message arrived, by opening a pop up, alert box etc.
+ *
+ * - Add settings ('setting'):
+ *   Adds a setting to Drupal's global storage of JavaScript settings. Per-page
+ *   settings are required by some modules to function properly. The settings
+ *   will be accessible at Drupal.settings.
+ *
+ * @param $data
+ *   (optional) If given, the value depends on the $type parameter:
+ *   - 'core', 'module' or 'theme': Path to the file relative to base_path().
+ *   - 'inline': The JavaScript code that should be placed in the given scope.
+ *   - 'setting': An array with configuration options as associative array. The
+ *       array is directly placed in Drupal.settings. You might want to wrap your
+ *       actual configuration settings in another variable to prevent the pollution
+ *       of the Drupal.settings namespace.
+ * @param $type
+ *   (optional) The type of JavaScript that should be added to the page. Allowed
+ *   values are 'core', 'module', 'theme', 'inline' and 'setting'. You
+ *   can, however, specify any value. It is treated as a reference to a JavaScript
+ *   file. Defaults to 'module'.
+ * @param $scope
+ *   (optional) The location in which you want to place the script. Possible
+ *   values are 'header' and 'footer' by default. If your theme implements
+ *   different locations, however, you can also use these.
+ * @param $defer
+ *   (optional) If set to TRUE, the defer attribute is set on the <script> tag.
+ *   Defaults to FALSE. This parameter is not used with $type == 'setting'.
+ * @param $cache
+ *   (optional) If set to FALSE, the JavaScript file is loaded anew on every page
+ *   call, that means, it is not cached. Defaults to TRUE. Used only when $type
+ *   references a JavaScript file.
+ * @return
+ *   If the first parameter is NULL, the JavaScript array that has been built so
+ *   far for $scope is returned.
+ */
+function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE) {
+  static $settings_include;
+  
+  if (!is_null($data)) {
+    _drupal_add_js('misc/jquery.js', 'core', 'header', FALSE, $cache);
+    _drupal_add_js('misc/drupal.js', 'core', 'header', FALSE, $cache);
+
+    if (!$settings_include) {
+     _drupal_add_js(array('basePath' => base_path()), 'setting', 'header', false, true);
+     $settings_include = true; 
+    }
+  }
+  
+  return _drupal_add_js($data, $type, $scope, $defer, $cache);
+}
+
+/**
+ * Helper function for drupal_add_js().
+ */
+function _drupal_add_js($data, $type, $scope, $defer, $cache) {
+  static $javascript = array();
+
+  if (!isset($javascript[$scope])) {
+    $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
+  }
+
+  if (!isset($javascript[$scope][$type])) {
+    $javascript[$scope][$type] = array();
+  }
+
+  if (!is_null($data)) {
+    switch ($type) {
+      case 'setting':
+        $javascript[$scope][$type][] = $data;
+        break;
+      case 'inline':
+        $javascript[$scope][$type][] = array('code' => $data, 'defer' => $defer);
+        break;
+      default:
+        $javascript[$scope][$type][$data] = array('cache' => $cache, 'defer' => $defer);
+    }
   }
+
+  return $javascript[$scope];
+}
+
+/**
+ * Returns a themed presentation of all JavaScript code for the current page.
+ * References to JavaScript files are placed in a certain order: first, all
+ * 'core' files, then all 'module' and finally all 'theme' JavaScript files
+ * are added to the page. Then, all settings are output, followed by 'inline'
+ * JavaScript code.
+ *
+ * @parameter $scope
+ *   (optional) The scope for which the JavaScript rules should be returned.
+ *   Defaults to 'header'.
+ * @parameter $javascript
+ *   (optional) An array with all JavaScript code. Defaults to the default
+ *   JavaScript array for the given scope.
+ * @return
+ *   All JavaScript code segments and includes for the scope as HTML tags.
+ */
+function drupal_get_js($scope = 'header', $javascript = NULL) {
+  $output = '';
+  if (is_null($javascript)) {
+    $javascript = drupal_add_js(NULL, NULL, $scope);
+  }
+
+  foreach ($javascript as $type => $data) {
+    if (!$data) continue;
+
+    switch ($type) {
+      case 'setting':
+        $output .= '<script type="text/javascript">Drupal.extend({ settings: '. drupal_to_js(call_user_func_array('array_merge_recursive', $data)) ." });</script>\n";
+        break;
+      case 'inline':
+        foreach ($data as $info) {
+          $output .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .'>'. $info['code'] ."</script>\n";
+        }
+        break;
+      default:
+        foreach ($data as $path => $info) {
+          $output .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .' src="'. check_url(base_path() . $path) . ($info['cache'] ? '' : '?'. time()) ."\"></script>\n";
+        }
+    }
+  }
+
+  return $output;
 }
 
 /**
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.292.2.7
diff -u -F^f -r1.292.2.7 theme.inc
--- includes/theme.inc	5 Sep 2006 10:22:24 -0000	1.292.2.7
+++ includes/theme.inc	23 Sep 2006 13:57:09 -0000
@@ -919,7 +919,7 @@ function theme_feed_icon($url) {
  */
 function theme_closure($main = 0) {
   $footer = module_invoke_all('footer', $main);
-  return implode("\n", $footer);
+  return implode("\n", $footer) . drupal_get_js('footer');
 }
 
 /**
Index: misc/autocomplete.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v
retrieving revision 1.11
diff -u -F^f -r1.11 autocomplete.js
--- misc/autocomplete.js	17 Apr 2006 20:48:25 -0000	1.11
+++ misc/autocomplete.js	23 Sep 2006 13:57:09 -0000
@@ -1,76 +1,51 @@
-// $Id: autocomplete.js,v 1.11 2006/04/17 20:48:25 dries Exp $
-
-// Global Killswitch
-if (isJsEnabled()) {
-  addLoadEvent(autocompleteAutoAttach);
-}
+// $Id: autocomplete.js,v 1.13 2006/08/31 23:31:24 unconed Exp $
 
 /**
  * Attaches the autocomplete behaviour to all required fields
  */
-function autocompleteAutoAttach() {
+Drupal.autocompleteAutoAttach = function () {
   var acdb = [];
-  var inputs = document.getElementsByTagName('input');
-  for (i = 0; input = inputs[i]; i++) {
-    if (input && hasClass(input, 'autocomplete')) {
-      uri = input.value;
-      if (!acdb[uri]) {
-        acdb[uri] = new ACDB(uri);
-      }
-      input = $(input.id.substr(0, input.id.length - 13));
-      input.setAttribute('autocomplete', 'OFF');
-      addSubmitEvent(input.form, autocompleteSubmit);
-      new jsAC(input, acdb[uri]);
+  $('input.autocomplete').each(function () {
+    var uri = this.value;
+    if (!acdb[uri]) {
+      acdb[uri] = new Drupal.ACDB(uri);
     }
-  }
+    var input = $('#' + this.id.substr(0, this.id.length - 13))
+      .attr('autocomplete', 'OFF')[0];
+    $(input.form).submit(Drupal.autocompleteSubmit);
+    new Drupal.jsAC(input, acdb[uri]);
+  });
 }
 
 /**
  * Prevents the form from submitting if the suggestions popup is open
+ * and closes the suggestions popup when doing so.
  */
-function autocompleteSubmit() {
-  var popup = document.getElementById('autocomplete');
-  if (popup) {
-    popup.owner.hidePopup();
-    return false;
-  }
-  return true;
+Drupal.autocompleteSubmit = function () {
+  return $('#autocomplete').each(function () {
+    this.owner.hidePopup();
+  }).size() == 0;
 }
 
-
 /**
  * An AutoComplete object
  */
-function jsAC(input, db) {
+Drupal.jsAC = function (input, db) {
   var ac = this;
   this.input = input;
   this.db = db;
-  this.input.onkeydown = function (event) { return ac.onkeydown(this, event); };
-  this.input.onkeyup = function (event) { ac.onkeyup(this, event) };
-  this.input.onblur = function () { ac.hidePopup(); ac.db.cancel(); };
-  this.popup = document.createElement('div');
-  this.popup.id = 'autocomplete';
-  this.popup.owner = this;
-};
 
-/**
- * Hides the autocomplete suggestions
- */
-jsAC.prototype.hidePopup = function (keycode) {
-  if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) {
-    this.input.value = this.selected.autocompleteValue;
-  }
-  if (this.popup.parentNode && this.popup.parentNode.tagName) {
-    removeNode(this.popup);
-  }
-  this.selected = false;
-}
+  $(this.input)
+    .keydown(function (event) { return ac.onkeydown(this, event); })
+    .keyup(function (event) { ac.onkeyup(this, event) })
+    .blur(function () { ac.hidePopup(); ac.db.cancel(); });
 
+};
 
 /**
  * Handler for the "keydown" event
  */
-jsAC.prototype.onkeydown = function (input, e) {
+Drupal.jsAC.prototype.onkeydown = function (input, e) {
   if (!e) {
     e = window.event;
   }
@@ -89,7 +64,7 @@ function jsAC(input, db) {
 /**
  * Handler for the "keyup" event
  */
-jsAC.prototype.onkeyup = function (input, e) {
+Drupal.jsAC.prototype.onkeyup = function (input, e) {
   if (!e) {
     e = window.event;
   }
@@ -126,21 +101,21 @@ function jsAC(input, db) {
 /**
  * Puts the currently highlighted suggestion into the autocomplete field
  */
-jsAC.prototype.select = function (node) {
+Drupal.jsAC.prototype.select = function (node) {
   this.input.value = node.autocompleteValue;
 }
 
 /**
  * Highlights the next suggestion
  */
-jsAC.prototype.selectDown = function () {
+Drupal.jsAC.prototype.selectDown = function () {
   if (this.selected && this.selected.nextSibling) {
     this.highlight(this.selected.nextSibling);
   }
   else {
-    var lis = this.popup.getElementsByTagName('li');
-    if (lis.length > 0) {
-      this.highlight(lis[0]);
+    var lis = $('li', this.popup);
+    if (lis.size() > 0) {
+      this.highlight(lis.get(0));
     }
   }
 }
@@ -148,7 +123,7 @@ function jsAC(input, db) {
 /**
  * Highlights the previous suggestion
  */
-jsAC.prototype.selectUp = function () {
+Drupal.jsAC.prototype.selectUp = function () {
   if (this.selected && this.selected.previousSibling) {
     this.highlight(this.selected.previousSibling);
   }
@@ -157,30 +132,61 @@ function jsAC(input, db) {
 /**
  * Highlights a suggestion
  */
-jsAC.prototype.highlight = function (node) {
-  removeClass(this.selected, 'selected');
-  addClass(node, 'selected');
+Drupal.jsAC.prototype.highlight = function (node) {
+  if (this.selected) {
+    $(this.selected).removeClass('selected');
+  }
+  $(node).addClass('selected');
   this.selected = node;
 }
 
 /**
  * Unhighlights a suggestion
  */
-jsAC.prototype.unhighlight = function (node) {
-  removeClass(node, 'selected');
+Drupal.jsAC.prototype.unhighlight = function (node) {
+  $(node).removeClass('selected');
+  this.selected = false;
+}
+
+/**
+ * Hides the autocomplete suggestions
+ */
+Drupal.jsAC.prototype.hidePopup = function (keycode) {
+  // Select item if the right key or mousebutton was pressed
+  if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) {
+    this.input.value = this.selected.autocompleteValue;
+  }
+  // Hide popup
+  var popup = this.popup;
+  if (popup) {
+    this.popup = null;
+    $(popup).fadeOut('fast', function() { $(popup).remove(); });
+  }
   this.selected = false;
 }
 
 /**
  * Positions the suggestions popup and starts a search
  */
-jsAC.prototype.populatePopup = function () {
-  var ac = this;
-  var pos = absolutePosition(this.input);
+Drupal.jsAC.prototype.populatePopup = function () {
+  // Show popup
+  if (this.popup) {
+    $(this.popup).remove();
+  }
+  var pos = Drupal.absolutePosition(this.input);
   this.selected = false;
-  this.popup.style.top   = (pos.y + this.input.offsetHeight) +'px';
-  this.popup.style.left  = pos.x +'px';
-  this.popup.style.width = (this.input.offsetWidth - 4) +'px';
+  this.popup = document.createElement('div');
+  this.popup.id = 'autocomplete';
+  this.popup.owner = this;
+  $(this.popup).css({
+    top: (pos.y + this.input.offsetHeight) +'px',
+    left: pos.x +'px',
+    width: (this.input.offsetWidth - 4) +'px',
+    display: 'none'
+  });
+  $('body').append(this.popup);
+
+  // Do search
   this.db.owner = this;
   this.db.search(this.input.value);
 }
@@ -188,41 +194,48 @@ function jsAC(input, db) {
 /**
  * Fills the suggestion popup with any matches received
  */
-jsAC.prototype.found = function (matches) {
-  while (this.popup.hasChildNodes()) {
-    this.popup.removeChild(this.popup.childNodes[0]);
-  }
-  if (!this.popup.parentNode || !this.popup.parentNode.tagName) {
-    document.getElementsByTagName('body')[0].appendChild(this.popup);
-  }
+Drupal.jsAC.prototype.found = function (matches) {
+  // Prepare matches
   var ul = document.createElement('ul');
   var ac = this;
-
   for (key in matches) {
     var li = document.createElement('li');
-    var div = document.createElement('div');
-    div.innerHTML = matches[key];
-    li.appendChild(div);
+    $(li)
+      .html('<div>'+ matches[key] +'</div>')
+      .mousedown(function () { ac.select(this); })
+      .mouseover(function () { ac.highlight(this); })
+      .mouseout(function () { ac.unhighlight(this); });
     li.autocompleteValue = key;
-    li.onmousedown = function() { ac.select(this); };
-    li.onmouseover = function() { ac.highlight(this); };
-    li.onmouseout  = function() { ac.unhighlight(this); };
-    ul.appendChild(li);
+    $(ul).append(li);
   }
 
+  // Show popup with matches, if any
   if (ul.childNodes.length > 0) {
-    this.popup.appendChild(ul);
+    $(this.popup).empty().append(ul).show();
   }
   else {
+    $(this.popup).css({visibility: 'hidden'});
     this.hidePopup();
   }
-  removeClass(this.input, 'throbbing');
+}
+
+Drupal.jsAC.prototype.setStatus = function (status) {
+  switch (status) {
+    case 'begin':
+      $(this.input).addClass('throbbing');
+      break;
+    case 'cancel':
+    case 'error':
+    case 'found':
+      $(this.input).removeClass('throbbing');
+      break;
+  }
 }
 
 /**
  * An AutoComplete DataBase object
  */
-function ACDB(uri) {
+Drupal.ACDB = function (uri) {
   this.uri = uri;
   this.delay = 300;
   this.cache = {};
@@ -231,46 +244,55 @@ function ACDB(uri) {
 /**
  * Performs a cached and delayed search
  */
-ACDB.prototype.search = function(searchString) {
+Drupal.ACDB.prototype.search = function (searchString) {
+  var db = this;
   this.searchString = searchString;
+
+  // See if this key has been searched for before
   if (this.cache[searchString]) {
     return this.owner.found(this.cache[searchString]);
   }
+
+  // Initiate delayed search
   if (this.timer) {
     clearTimeout(this.timer);
   }
-  var db = this;
   this.timer = setTimeout(function() {
-    addClass(db.owner.input, 'throbbing');
-    db.transport = HTTPGet(db.uri +'/'+ encodeURIComponent(searchString), db.receive, db);
-  }, this.delay);
-}
+    db.owner.setStatus('begin');
 
-/**
- * HTTP callback function. Passes suggestions to the autocomplete object
- */
-ACDB.prototype.receive = function(string, xmlhttp, acdb) {
-  // Note: Safari returns 'undefined' status if the request returns no data.
-  if (xmlhttp.status != 200 && typeof xmlhttp.status != 'undefined') {
-    removeClass(acdb.owner.input, 'throbbing');
-    return alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ acdb.uri);
-  }
-  // Parse back result
-  var matches = parseJson(string);
-  if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {
-    acdb.cache[acdb.searchString] = matches;
-    acdb.owner.found(matches);
-  }
+    // Ajax GET request for autocompletion
+    $.ajax({
+      type: "GET",
+      url: db.uri +'/'+ Drupal.encodeURIComponent(searchString),
+      success: function (xmlhttp) {
+        // Parse back result
+        var matches = Drupal.parseJson(xmlhttp.responseText);
+        if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {
+          db.cache[searchString] = matches;
+          // Verify if these are still the matches the user wants to see
+          if (db.searchString == searchString) {
+            db.owner.found(matches);
+          }
+          db.owner.setStatus('found');
+        }
+      },
+      error: function (xmlhttp) {
+        alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ db.uri);
+      }
+    });
+  }, this.delay);
 }
 
 /**
  * Cancels the current autocomplete request
  */
-ACDB.prototype.cancel = function() {
-  if (this.owner) removeClass(this.owner.input, 'throbbing');
+Drupal.ACDB.prototype.cancel = function() {
+  if (this.owner) this.owner.setStatus('cancel');
   if (this.timer) clearTimeout(this.timer);
-  if (this.transport) {
-    this.transport.onreadystatechange = function() {};
-    this.transport.abort();
-  }
+  this.searchString = '';
+}
+
+// Global Killswitch
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.autocompleteAutoAttach);
 }
Index: misc/collapse.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/collapse.js,v
retrieving revision 1.6
diff -u -F^f -r1.6 collapse.js
--- misc/collapse.js	14 Apr 2006 13:48:56 -0000	1.6
+++ misc/collapse.js	23 Sep 2006 13:57:09 -0000
@@ -1,70 +1,100 @@
-// $Id: collapse.js,v 1.6 2006/04/14 13:48:56 killes Exp $
+// $Id: collapse.js,v 1.7 2006/08/31 23:31:24 unconed Exp $
 
-if (isJsEnabled()) {
-  addLoadEvent(collapseAutoAttach);
-}
-
-function collapseAutoAttach() {
-  var fieldsets = document.getElementsByTagName('fieldset');
-  var legend, fieldset;
-  for (var i = 0; fieldset = fieldsets[i]; i++) {
-    if (!hasClass(fieldset, 'collapsible')) {
-      continue;
-    }
-    legend = fieldset.getElementsByTagName('legend');
-    if (legend.length == 0) {
-      continue;
-    }
-    legend = legend[0];
+Drupal.collapseAutoAttach = function () {
+  $('fieldset.collapsible legend').each(function () {
+    // Turn the legend into clickable link
     var a = document.createElement('a');
     a.href = '#';
-    a.onclick = function() {
-      toggleClass(this.parentNode.parentNode, 'collapsed');
-      if (!hasClass(this.parentNode.parentNode, 'collapsed')) {
-        collapseScrollIntoView(this.parentNode.parentNode);
-        if (typeof textAreaAutoAttach != 'undefined') {
-          // Add the grippie to a textarea in a collapsed fieldset.
-          textAreaAutoAttach(null, this.parentNode.parentNode);
+    $(a)
+      .click(function() {
+        var fieldset = this.parentNode.parentNode;
+
+        // Prevent double animations
+        if (fieldset.animating) {
+          return false;
+        }
+        fieldset.animating = true;
+
+        if ($(fieldset).is('.collapsed')) {
+          // Open fieldset with animation
+          $(fieldset.contentWrapper).hide();
+          $(fieldset).removeClass('collapsed');
+          $(fieldset.contentWrapper).slideDown(300,
+            {
+              // Make sure we open to height auto
+              complete: function() {
+                $(fieldset.contentWrapper).css('height', 'auto');
+                Drupal.collapseScrollIntoView(fieldset);
+                fieldset.animating = false;
+              },
+              // Scroll the fieldset into view
+              step: function() {
+                Drupal.collapseScrollIntoView(fieldset);
+              }
+            }
+          );
+          if (typeof Drupal.textareaAttach != 'undefined') {
+            // Initialize resizable textareas that are now revealed
+            Drupal.textareaAttach(null, fieldset);
+          }
+        }
+        else {
+          // Collapse fieldset with animation (reverse of opening)
+          $(fieldset.contentWrapper)
+            .slideUp('medium', function () { $(fieldset).addClass('collapsed'); fieldset.animating = false; } )
+            .show();
         }
-      }
-      this.blur();
-      return false;
-    };
-    a.innerHTML = legend.innerHTML;
-    while (legend.hasChildNodes()) {
-      removeNode(legend.childNodes[0]);
+        this.blur();
+        return false;
+      })
+      .html(this.innerHTML);
+    $(this)
+      .empty()
+      .append(a);
+
+    // Wrap fieldsets contents (except for the legend) into wrapper divs for animating.
+    // div1 is used to avoid margin problems inside fieldsets,
+    // div2 is the one that is actually animated.
+    var div1 = document.createElement('div');
+    var div2 = document.createElement('div');
+    this.parentNode.contentWrapper = div2;
+    $(this).after(div1);
+    $(div1).append(div2);
+    var el = div1.nextSibling;
+    while (el != null) {
+      var next = el.nextSibling;
+      $(el).remove();
+      $(div2).append(el);
+      el = next;
     }
-    legend.appendChild(a);
-    collapseEnsureErrorsVisible(fieldset);
-  }
-}
+    // Avoid jumping around due to margins collapsing into fieldset border
+    $(div1).css('overflow', 'hidden');
 
-function collapseEnsureErrorsVisible(fieldset) {
-  if (!hasClass(fieldset, 'collapsed')) {
-    return;
-  }
-  var inputs = [];
-  inputs = inputs.concat(fieldset.getElementsByTagName('input'));
-  inputs = inputs.concat(fieldset.getElementsByTagName('textarea'));
-  inputs = inputs.concat(fieldset.getElementsByTagName('select'));
-  for (var j = 0; j<3; j++) {
-    for (var i = 0; i < inputs[j].length; i++) {
-      if (hasClass(inputs[j][i], 'error')) {
-        return removeClass(fieldset, 'collapsed');
-      }
+    // Expand if there are errors inside
+    if ($('input.error, textarea.error, select.error', this.parentNode).size() > 0) {
+      $(this.parentNode).removeClass('collapsed');
     }
-  }
+  });
 }
 
-function collapseScrollIntoView(node) {
+/**
+ * Scroll a given fieldset into view as much as possible.
+ */
+Drupal.collapseScrollIntoView = function (node) {
   var h = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
   var offset = self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
-  var pos = absolutePosition(node);
-  if (pos.y + node.scrollHeight > h + offset) {
-    if (node.scrollHeight > h) {
+  var pos = Drupal.absolutePosition(node);
+  var fudge = 55;
+  if (pos.y + node.offsetHeight + fudge > h + offset) {
+    if (node.offsetHeight > h) {
       window.scrollTo(0, pos.y);
     } else {
-      window.scrollTo(0, pos.y + node.scrollHeight - h);
+      window.scrollTo(0, pos.y + node.offsetHeight - h + fudge);
     }
   }
 }
+
+// Global Killswitch
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.collapseAutoAttach);
+}
Index: misc/drupal.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/drupal.js,v
retrieving revision 1.22.2.2
diff -u -F^f -r1.22.2.2 drupal.js
--- misc/drupal.js	19 Aug 2006 19:55:20 -0000	1.22.2.2
+++ misc/drupal.js	23 Sep 2006 13:57:10 -0000
@@ -1,127 +1,44 @@
 // $Id: drupal.js,v 1.22.2.2 2006/08/19 19:55:20 killes Exp $
 
-/**
- * Only enable Javascript functionality if all required features are supported.
- */
-function isJsEnabled() {
-  if (typeof document.jsEnabled == 'undefined') {
-    // Note: ! casts to boolean implicitly.
-    document.jsEnabled = !(
-     !document.getElementsByTagName ||
-     !document.createElement        ||
-     !document.createTextNode       ||
-     !document.documentElement      ||
-     !document.getElementById);
-  }
-  return document.jsEnabled;
-}
-
-// Global Killswitch on the <html> element
-if (isJsEnabled()) {
-  document.documentElement.className = 'js';
-}
+var Drupal = Drupal || {};
 
 /**
- * Make IE's XMLHTTP object accessible through XMLHttpRequest()
+ * Set the variable that indicates if JavaScript behaviors should be applied
  */
-if (typeof XMLHttpRequest == 'undefined') {
-  XMLHttpRequest = function () {
-    var msxmls = ['MSXML3', 'MSXML2', 'Microsoft']
-    for (var i=0; i < msxmls.length; i++) {
-      try {
-        return new ActiveXObject(msxmls[i]+'.XMLHTTP')
-      }
-      catch (e) { }
-    }
-    throw new Error("No XML component installed!");
-  }
-}
+Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;
 
 /**
- * Creates an HTTP GET request and sends the response to the callback function.
- *
- * Note that dynamic arguments in the URI should be escaped with encodeURIComponent().
+ * Extends the current object with the parameter. Works recursively.
  */
-function HTTPGet(uri, callbackFunction, callbackParameter) {
-  var xmlHttp = new XMLHttpRequest();
-  var bAsync = true;
-  if (!callbackFunction) {
-    bAsync = false;
-  }
-
-  xmlHttp.open('GET', uri, bAsync);
-  xmlHttp.send(null);
-
-  if (bAsync) {
-    xmlHttp.onreadystatechange = function() {
-      if (xmlHttp.readyState == 4) {
-        callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
-      }
+Drupal.extend = function(obj) {
+  for (var i in obj) {
+    if (this[i]) {
+      Drupal.extend.apply(this[i], [obj[i]]);
     }
-    return xmlHttp;
-  }
-  else {
-    return xmlHttp.responseText;
-  }
-}
-
-/**
- * Creates an HTTP POST request and sends the response to the callback function
- *
- * Note: passing null or undefined for 'object' makes the request fail in Opera 8.
- *       Pass an empty string instead.
- */
-function HTTPPost(uri, callbackFunction, callbackParameter, object) {
-  var xmlHttp = new XMLHttpRequest();
-  var bAsync = true;
-  if (!callbackFunction) {
-    bAsync = false;
-  }
-  xmlHttp.open('POST', uri, bAsync);
-
-  var toSend = '';
-  if (typeof object == 'object') {
-    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-    for (var i in object) {
-      toSend += (toSend ? '&' : '') + i + '=' + encodeURIComponent(object[i]);
+    else {
+      this[i] = obj[i];
     }
   }
-  else {
-    toSend = object;
-  }
-  xmlHttp.send(toSend);
-
-  if (bAsync) {
-    xmlHttp.onreadystatechange = function() {
-      if (xmlHttp.readyState == 4) {
-        callbackFunction(xmlHttp.responseText, xmlHttp, callbackParameter);
-      }
-    }
-    return xmlHttp;
-  }
-  else {
-    return xmlHttp.responseText;
-  }
-}
+},
 
 /**
  * Redirects a button's form submission to a hidden iframe and displays the result
  * in a given wrapper. The iframe should contain a call to
  * window.parent.iframeHandler() after submission.
  */
-function redirectFormButton(uri, button, handler) {
-  // (Re)create an iframe to target.
-  createIframe();
-
+Drupal.redirectFormButton = function (uri, button, handler) {
   // Trap the button
   button.onmouseover = button.onfocus = function() {
     button.onclick = function() {
+      // Create target iframe
+      Drupal.createIframe();
+
       // Prepare variables for use in anonymous function.
       var button = this;
       var action = button.form.action;
       var target = button.form.target;
 
-      // Redirect form submission
+      // Redirect form submission to iframe
       this.form.action = uri;
       this.form.target = 'redirect-target';
 
@@ -129,7 +46,7 @@ function redirectFormButton(uri, button,
 
       // Set iframe handler for later
       window.iframeHandler = function () {
-        var iframe = $('redirect-target');
+        var iframe = $('#redirect-target').get(0);
         // Restore form submission
         button.form.action = action;
         button.form.target = target;
@@ -148,16 +65,15 @@ function redirectFormButton(uri, button,
           response = null;
         }
 
-        $('redirect-target').onload = null;
-        $('redirect-target').src = 'about:blank';
-
-        response = parseJson(response);
+        response = Drupal.parseJson(response);
         // Check response code
         if (response.status == 0) {
           handler.onerror(response.data);
           return;
         }
         handler.oncomplete(response.data);
+
+        return true;
       }
 
       return true;
@@ -166,43 +82,12 @@ function redirectFormButton(uri, button,
   button.onmouseout = button.onblur = function() {
     button.onclick = null;
   }
-}
-
-/**
- * Adds a function to the window onload event
- */
-function addLoadEvent(func) {
-  var oldOnload = window.onload;
-  if (typeof window.onload != 'function') {
-    window.onload = func;
-  }
-  else {
-    window.onload = function() {
-      oldOnload();
-      func();
-    }
-  }
-}
-
-/**
- * Adds a function to a given form's submit event
- */
-function addSubmitEvent(form, func) {
-  var oldSubmit = form.onsubmit;
-  if (typeof oldSubmit != 'function') {
-    form.onsubmit = func;
-  }
-  else {
-    form.onsubmit = function() {
-      return oldSubmit() && func();
-    }
-  }
-}
+},
 
 /**
  * Retrieves the absolute position of an element on the screen
  */
-function absolutePosition(el) {
+Drupal.absolutePosition = function (el) {
   var sLeft = 0, sTop = 0;
   var isDiv = /^div$/i.test(el.tagName);
   if (isDiv && el.scrollLeft) {
@@ -213,152 +98,109 @@ function absolutePosition(el) {
   }
   var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop };
   if (el.offsetParent) {
-    var tmp = absolutePosition(el.offsetParent);
+    var tmp = Drupal.absolutePosition(el.offsetParent);
     r.x += tmp.x;
     r.y += tmp.y;
   }
   return r;
-};
-
-function dimensions(el) {
-  return { width: el.offsetWidth, height: el.offsetHeight };
-}
-
-/**
- * Returns true if an element has a specified class name
- */
-function hasClass(node, className) {
-  if (node.className == className) {
-    return true;
-  }
-  var reg = new RegExp('(^| )'+ className +'($| )')
-  if (reg.test(node.className)) {
-    return true;
-  }
-  return false;
-}
-
-/**
- * Adds a class name to an element
- */
-function addClass(node, className) {
-  if (hasClass(node, className)) {
-    return false;
-  }
-  node.className += ' '+ className;
-  return true;
-}
-
-/**
- * Removes a class name from an element
- */
-function removeClass(node, className) {
-  if (!hasClass(node, className)) {
-    return false;
-  }
-  // Replaces words surrounded with whitespace or at a string border with a space. Prevents multiple class names from being glued together.
-  node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
-  return true;
-}
+},
 
 /**
- * Toggles a class name on or off for an element
+ * Return the dimensions of an element on the screen
  */
-function toggleClass(node, className) {
-  if (!removeClass(node, className) && !addClass(node, className)) {
-    return false;
-  }
-  return true;
-}
-
-/**
- * Emulate PHP's ereg_replace function in javascript
- */
-function eregReplace(search, replace, subject) {
-  return subject.replace(new RegExp(search,'g'), replace);
-}
-
-/**
- * Removes an element from the page
- */
-function removeNode(node) {
-  if (typeof node == 'string') {
-    node = $(node);
-  }
-  if (node && node.parentNode) {
-    return node.parentNode.removeChild(node);
-  }
-  else {
-    return false;
-  }
-}
+Drupal.dimensions = function (el) {
+  return { width: el.offsetWidth, height: el.offsetHeight };
+},
 
 /**
- * Prevents an event from propagating.
+ *  Returns the position of the mouse cursor based on the event object passed
  */
-function stopEvent(event) {
-  if (event.preventDefault) {
-    event.preventDefault();
-    event.stopPropagation();
-  }
-  else {
-    event.returnValue = false;
-    event.cancelBubble = true;
-  }
-}
+Drupal.mousePosition = function(e) {
+  return { x: e.clientX + document.documentElement.scrollLeft, y: e.clientY + document.documentElement.scrollTop };
+},
 
 /**
  * Parse a JSON response.
  *
  * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
  */
-function parseJson(data) {
-  if (data.substring(0,1) != '{') {
+Drupal.parseJson = function (data) {
+  if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
     return { status: 0, data: data.length ? data : 'Unspecified error' };
   }
   return eval('(' + data + ');');
-}
+},
 
 /**
  * Create an invisible iframe for form submissions.
  */
-function createIframe() {
-  // Delete any previous iframe
-  deleteIframe();
+Drupal.createIframe = function () {
+  if ($('#redirect-holder').size()) {
+    return;
+  }
   // Note: some browsers require the literal name/id attributes on the tag,
   // some want them set through JS. We do both.
   window.iframeHandler = function () {};
   var div = document.createElement('div');
   div.id = 'redirect-holder';
-  div.innerHTML = '<iframe name="redirect-target" id="redirect-target" class="redirect" onload="window.iframeHandler();"></iframe>';
+  $(div).html('<iframe name="redirect-target" id="redirect-target" class="redirect" onload="window.iframeHandler();"></iframe>');
   var iframe = div.firstChild;
-  with (iframe) {
-    name = 'redirect-target';
-    setAttribute('name', 'redirect-target');
-    id = 'redirect-target';
-  }
-  with (iframe.style) {
-    position = 'absolute';
-    height = '1px';
-    width = '1px';
-    visibility = 'hidden';
-  }
-  document.body.appendChild(div);
-}
+  $(iframe)
+    .attr({
+      name: 'redirect-target',
+      id: 'redirect-target'
+    })
+    .css({
+      position: 'absolute',
+      height: '1px',
+      width: '1px',
+      visibility: 'hidden'
+    });
+  $('body').append(div);
+},
+
+/**
+ * Delete the invisible iframe
+ */
+Drupal.deleteIframe = function () {
+  $('#redirect-holder').remove();
+},
 
 /**
- * Delete the invisible iframe for form submissions.
+ * Freeze the current body height (as minimum height). Used to prevent
+ * unnecessary upwards scrolling when doing DOM manipulations.
  */
-function deleteIframe() {
-  var holder = $('redirect-holder');
-  if (holder != null) {
-    removeNode(holder);
-  }
+Drupal.freezeHeight = function () {
+  Drupal.unfreezeHeight();
+  var div = document.createElement('div');
+  $(div).css({
+    position: 'absolute',
+    top: '0px',
+    left: '0px',
+    width: '1px',
+    height: $('body').css('height')
+  }).attr('id', 'freeze-height');
+  $('body').append(div);
+},
+
+/**
+ * Unfreeze the body height
+ */
+Drupal.unfreezeHeight = function () {
+  $('#freeze-height').remove();
 }
 
 /**
- * Wrapper around document.getElementById().
+ * Wrapper to address the mod_rewrite url encoding bug
+ * (equivalent of drupal_urlencode() in PHP).
  */
-function $(id) {
-  return document.getElementById(id);
+Drupal.encodeURIComponent = function (item, uri) {
+  uri = uri || location.href;
+  item = encodeURIComponent(item).replace('%2F', '/');
+  return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523');
+}
+
+// Global Killswitch on the <html> element
+if (Drupal.jsEnabled) {
+  document.documentElement.className = 'js';
 }
Index: misc/jquery.js
===================================================================
RCS file: misc/jquery.js
diff -N misc/jquery.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ misc/jquery.js	23 Sep 2006 13:57:10 -0000
@@ -0,0 +1,2 @@
+// $Id: jquery.js,v 1.2 2006/09/08 23:16:14 drumm Exp $
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('1Q.11=1Q.11;q 6(a,c){l(a&&a.I==1e&&6.C.1X)v 6(16).1X(a);a=a||6.1c||16;l(a.3k)v $(6.21(a,[]));l(c&&c.3k)v $(c).27(a);l(1Q==7)v 17 6(a,c);u m=/^[^<]*(<.+>)[^>]*$/.2W(a);l(m)a=6.37([m[1]]);7.1t(a.I==2r||a.D&&!a.1R&&a[0]!=11&&a[0].1R?6.21(a,[]):6.27(a,c));u C=1b[1b.D-1];l(C&&C.I==1e)7.R(C)}l(45 $!="11")6.3J$=$;u $=6;6.C=6.5C={3k:"$7V: 7p $",4P:q(){v 7.D},1t:q(24){l(24&&24.I==2r){7.D=0;[].1i.15(7,24);v 7}H v 24==11?6.2d(7,q(a){v a}):7[24]},R:q(C,1y){v 6.R(7,C,1y)},5F:q(12){u 2a=-1;7.R(q(i){l(7==12)2a=i});v 2a},1F:q(1J,19,B){v 1J.I!=1M||19!=11?7.R(q(){l(19==11)E(u G 1o 1J)6.1F(B?7.1d:7,G,1J[G]);H 6.1F(B?7.1d:7,1J,19)}):6[B||"1F"](7[0],1J)},1g:q(1J,19){v 7.1F(1J,19,"1U")},42:q(e){e=e||7;u t="";E(u j=0;j<e.D;j++){u r=e[j].2c;E(u i=0;i<r.D;i++)l(r[i].1R!=8)t+=r[i].1R!=1?r[i].7h:6.C.42([r[i]])}v t},5I:q(){u a=6.37(1b);v 7.R(q(){u b=a[0].3q(V);7.1u.2y(b,7);2t(b.1H)b=b.1H;b.3L(7)})},4S:q(){v 7.2x(1b,V,1,q(a){7.3L(a)})},4U:q(){v 7.2x(1b,V,-1,q(a){7.2y(a,7.1H)})},4V:q(){v 7.2x(1b,18,1,q(a){7.1u.2y(a,7)})},4X:q(){v 7.2x(1b,18,-1,q(a){7.1u.2y(a,7.5J)})},5K:q(){v 7.1t(7.2P.5L())},27:q(t){v 7.2i(6.2d(7,q(a){v 6.27(t,a)}),1b)},3O:q(3M){v 7.2i(6.2d(7,q(a){v a.3q(3M!=11?3M:V)}),1b)},1k:q(t){v 7.2i(t.I==2r&&6.2d(7,q(a){E(u i=0;i<t.D;i++)l(6.1k(t[i],[a]).r.D)v a})||t.I==5M&&(t?7.1t():[])||t.I==1e&&6.2F(7,t)||6.1k(t,7).r,1b)},2k:q(t){v 7.2i(t.I==1M?6.1k(t,7,18).r:6.2F(7,q(a){v a!=t}),1b)},1W:q(t){v 7.2i(6.21(7,t.I==1M?6.27(t):t.I==2r?t:[t]),1b)},3v:q(2n){v 2n?6.1k(2n,7).r.D>0:7.D>0},2x:q(1y,1j,2E,C){u 3O=7.4P()>1;u a=6.37(1y);v 7.R(q(){u 12=7;l(1j&&7.3X=="5P"&&a[0].3X!="5Q"){u 22=7.4y("22");l(!22.D){12=16.4q("22");7.3L(12)}H 12=22[0]}E(u i=(2E<0?a.D-1:0);i!=(2E<0?2E:a.D);i+=2E){C.15(12,[3O?a[i].3q(V):a[i]])}})},2i:q(a,1y){u C=1y&&1y[1y.D-1];l(!C||C.I!=1e){l(!7.2P)7.2P=[];7.2P.1i(7.1t());7.1t(a)}H{u 25=7.1t();7.1t(a);l(C.I==1e)v 7.R(C);7.1t(25)}v 7}};6.1T=6.C.1T=q(12,G){l(!G){G=12;12=7}E(u i 1o G)12[i]=G[i];v 12};6.1T({5e:q(){6.5S=V;6.R(6.2f.4e,q(i,n){6.C[i]=q(a){u L=6.2d(7,n);l(a&&a.I==1M)L=6.1k(a,L).r;v 7.2i(L,1b)}});6.R(6.2f.2q,q(i,n){6.C[i]=q(){u a=1b;v 7.R(q(){E(u j=0;j<a.D;j++)$(a[j])[n](7)})}});6.R(6.2f.R,q(i,n){6.C[i]=q(){v 7.R(n,1b)}});6.R(6.2f.1k,q(i,n){6.C[n]=q(24,C){v 7.1k(":"+n+"("+24+")",C)}});6.R(6.2f.1F,q(i,n){n=n||i;6.C[i]=q(h){v h==11?7.D?7[0][n]:U:7.1F(n,h)}});6.R(6.2f.1g,q(i,n){6.C[n]=q(h){v h==11?(7.D?6.1g(7[0],n):U):7.1g(n,h)}})},R:q(12,C,1y){l(12.D==11)E(u i 1o 12)C.15(12[i],1y||[i,12[i]]);H E(u i=0;i<12.D;i++)C.15(12[i],1y||[i,12[i]]);v 12},1h:{1W:q(o,c){l(6.1h.3p(o,c))v;o.1h+=(o.1h?" ":"")+c},2g:q(o,c){o.1h=!c?"":o.1h.1r(17 36("(^|\\\\s*\\\\b[^-])"+c+"($|\\\\b(?=[^-]))","g"),"")},3p:q(e,a){l(e.1h!=11)e=e.1h;v 17 36("(^|\\\\s)"+a+"(\\\\s|$)").1Y(e)}},3x:q(e,o,f){E(u i 1o o){e.1d["25"+i]=e.1d[i];e.1d[i]=o[i]}f.15(e,[]);E(u i 1o o)e.1d[i]=e.1d["25"+i]},1g:q(e,p){l(p=="1w"||p=="28"){u 25={},3m,39,d=["5W","60","5X","5D"];E(u i 1o d){25["5H"+d[i]]=0;25["5O"+d[i]+"64"]=0}6.3x(e,25,q(){l(6.1g(e,"1m")!="1Z"){3m=e.65;39=e.66}H{e=$(e.3q(V)).1g({3B:"1V",4Y:"67",1m:"2L"}).4T("68")[0];3m=e.69;39=e.6c;e.1u.3j(e)}});v p=="1w"?3m:39}H l(p=="1v"&&6.1n.23)v 3C(6.1U(e,"1k").1r(/[^0-9.]/,""))||1;v 6.1U(e,p)},1U:q(J,G,4j){u L;l(!4j&&J.1d[G]){L=J.1d[G]}H l(J.2D){u 5q=G.1r(/\\-(\\w)/g,q(m,c){v c.3o()});L=J.2D[G]||J.2D[5q]}H l(16.3s&&16.3s.47){G=G.1r(/([A-Z])/g,"-$1").4Q();u 1f=16.3s.47(J,U);l(1f)L=1f.5k(G);H l(G==\'1m\')L=\'1Z\';H 6.3x(J,{1m:\'2L\'},q(){L=16.3s.47(7,U).5k(G)})}v L},37:q(a){u r=[];E(u i=0;i<a.D;i++){l(a[i].I==1M){u 1j="";l(!a[i].1a("<43")||!a[i].1a("<22")){1j="43";a[i]="<1j>"+a[i]+"</1j>"}H l(!a[i].1a("<3i")){1j="3i";a[i]="<1j>"+a[i]+"</1j>"}H l(!a[i].1a("<3y")||!a[i].1a("<6g")){1j="3y";a[i]="<1j><22><3i>"+a[i]+"</3i></22></1j>"}u 1A=16.4q("1A");1A.2v=a[i];l(1j){1A=1A.1H;l(1j!="43")1A=1A.1H;l(1j=="3y")1A=1A.1H}E(u j=0;j<1A.2c.D;j++)r.1i(1A.2c[j])}H l(a[i].3k||a[i].D&&!a[i].1R)E(u k=0;k<a[i].D;k++)r.1i(a[i][k]);H l(a[i]!==U)r.1i(a[i].1R?a[i]:16.6j(a[i].6k()))}v r},2n:{"":"m[2]== \'*\'||a.3X.3o()==m[2].3o()","#":"a.33(\'2X\')&&a.33(\'2X\')==m[2]",":":{52:"i<m[3]-0",53:"i>m[3]-0",4s:"m[3]-0==i",51:"m[3]-0==i",2b:"i==0",1K:"i==r.D-1",4G:"i%2==0",4H:"i%2","4s-3b":"6.1q(a,m[3]).1f","2b-3b":"6.1q(a,0).1f","1K-3b":"6.1q(a,0).1K","6l-3b":"6.1q(a).D==1",57:"a.2c.D",5d:"!a.2c.D",54:"(a.6n||a.2v).1a(m[3])>=0",6o:"a.B!=\'1V\'&&6.1g(a,\'1m\')!=\'1Z\'&&6.1g(a,\'3B\')!=\'1V\'",1V:"a.B==\'1V\'||6.1g(a,\'1m\')==\'1Z\'||6.1g(a,\'3B\')==\'1V\'",6p:"!a.2A",2A:"a.2A",59:"a.59",4u:"a.4u"},".":"6.1h.3p(a,m[2])","@":{"=":"z==m[4]","!=":"z!=m[4]","^=":"!z.1a(m[4])","$=":"z.2H(z.D - m[4].D,m[4].D)==m[4]","*=":"z.1a(m[4])>=0","":"z"},"[":"6.27(m[2],a).D"},3d:["\\\\.\\\\.|/\\\\.\\\\.","a.1u",">|/","6.1q(a.1H)","\\\\+","6.1q(a).3a","~",q(a){u r=[];u s=6.1q(a);l(s.n>0)E(u i=s.n;i<s.D;i++)r.1i(s[i]);v r}],27:q(t,1c){l(1c&&1c.1R==11)1c=U;1c=1c||6.1c||16;l(t.I!=1M)v[t];l(!t.1a("//")){1c=1c.4v;t=t.2H(2,t.D)}H l(!t.1a("/")){1c=1c.4v;t=t.2H(1,t.D);l(t.1a("/")>=1)t=t.2H(t.1a("/"),t.D)}u L=[1c];u 1L=[];u 1K=U;2t(t.D>0&&1K!=t){u r=[];1K=t;t=6.38(t).1r(/^\\/\\//i,"");u 2S=18;E(u i=0;i<6.3d.D;i+=2){l(2S)4F;u 2m=17 36("^("+6.3d[i]+")");u m=2m.2W(t);l(m){r=L=6.2d(L,6.3d[i+1]);t=6.38(t.1r(2m,""));2S=V}}l(!2S){l(!t.1a(",")||!t.1a("|")){l(L[0]==1c)L.3z();1L=6.21(1L,L);r=L=[1c];t=" "+t.2H(1,t.D)}H{u 3u=/^([#.]?)([a-4A-9\\\\*3J-]*)/i;u m=3u.2W(t);l(m[1]=="#"){u 3N=16.4c(m[2]);r=L=3N?[3N]:[];t=t.1r(3u,"")}H{l(!m[2]||m[1]==".")m[2]="*";E(u i=0;i<L.D;i++)r=6.21(r,m[2]=="*"?6.3w(L[i]):L[i].4y(m[2]))}}}l(t){u 1B=6.1k(t,r);L=r=1B.r;t=6.38(1B.t)}}l(L&&L[0]==1c)L.3z();1L=6.21(1L,L);v 1L},3w:q(o,r){r=r||[];u s=o.2c;E(u i=0;i<s.D;i++)l(s[i].1R==1){r.1i(s[i]);6.3w(s[i],r)}v r},1F:q(J,1s,19){u 29={"E":"6w","76":"1h","4Z":"6x",2v:"2v",1h:"1h",19:"19",2A:"2A"};l(29[1s]){l(19!=11)J[29[1s]]=19;v J[29[1s]]}H l(J.33){l(19!=11)J.6z(1s,19);v J.33(1s,2)}H{1s=1s.1r(/-([a-z])/6A,q(z,b){v b.3o()});l(19!=11)J[1s]=19;v J[1s]}},4R:[["\\\\[ *(@)S *([!*$^=]*) *Q\\\\]",1],["(\\\\[)Q\\\\]",0],["(:)S\\\\(Q\\\\)",0],["([:.#]*)S",0]],1k:q(t,r,2k){u g=2k!==18?6.2F:q(a,f){v 6.2F(a,f,V)};2t(t&&/^[a-z[({<*:.#]/i.1Y(t)){u p=6.4R;E(u i=0;i<p.D;i++){u 2m=17 36("^"+p[i][0].1r(\'S\',"([a-z*3J-][a-4A-6E-]*)").1r(\'Q\'," *\'?\\"?([^\'\\"]*?)\'?\\"? *"),"i");u m=2m.2W(t);l(m){l(p[i][1])m=["",m[1],m[3],m[2],m[4]];t=t.1r(2m,"");6G}}l(m[1]==":"&&m[2]=="2k")r=6.1k(m[3],r,18).r;H{u f=6.2n[m[1]];l(f.I!=1M)f=6.2n[m[1]][m[2]];30("f = q(a,i){"+(m[1]=="@"?"z=6.1F(a,m[3]);":"")+"v "+f+"}");r=g(r,f)}}v{r:r,t:t}},38:q(t){v t.1r(/^\\s+|\\s+$/g,"")},2M:q(J){u 3E=[];u 1f=J.1u;2t(1f&&1f!=16){3E.1i(1f);1f=1f.1u}v 3E},1q:q(J,2a,2k){u Y=[];u 26=J.1u.2c;E(u i=0;i<26.D;i++){l(2k===V&&26[i]==J)4F;l(26[i].1R==1)Y.1i(26[i]);l(26[i]==J)Y.n=Y.D-1}v 6.1T(Y,{1K:Y.n==Y.D-1,1f:2a=="4G"&&Y.n%2==0||2a=="4H"&&Y.n%2||Y[2a]==J,3R:Y[Y.n-1],3a:Y[Y.n+1]})},21:q(2b,2T){u 1z=[];E(u k=0;k<2b.D;k++)1z[k]=2b[k];E(u i=0;i<2T.D;i++){u 3G=V;E(u j=0;j<2b.D;j++)l(2T[i]==2b[j])3G=18;l(3G)1z.1i(2T[i])}v 1z},2F:q(Y,C,3I){l(C.I==1M)C=17 1e("a","i","v "+C);u 1z=[];E(u i=0;i<Y.D;i++)l(!3I&&C(Y[i],i)||3I&&!C(Y[i],i))1z.1i(Y[i]);v 1z},2d:q(Y,C){l(C.I==1M)C=17 1e("a","v "+C);u 1z=[];E(u i=0;i<Y.D;i++){u 1B=C(Y[i],i);l(1B!==U&&1B!=11){l(1B.I!=2r)1B=[1B];1z=6.21(1z,1B)}}v 1z},N:{1W:q(P,B,20){l(6.1n.23&&P.3A!=11)P=1Q;l(!20.2j)20.2j=7.2j++;l(!P.1C)P.1C={};u 2G=P.1C[B];l(!2G){2G=P.1C[B]={};l(P["2B"+B])2G[0]=P["2B"+B]}2G[20.2j]=20;P["2B"+B]=7.4M;l(!7.2C[B])7.2C[B]=[];7.2C[B].1i(P)},2j:1,2C:{},2g:q(P,B,20){l(P.1C)l(B&&P.1C[B])l(20)4J P.1C[B][20.2j];H E(u i 1o P.1C[B])4J P.1C[B][i];H E(u j 1o P.1C)7.2g(P,j)},1I:q(B,K,P){K=K||[];l(!P){u g=7.2C[B];l(g)E(u i=0;i<g.D;i++)7.1I(B,K,g[i])}H l(P["2B"+B]){K.6R(7.29({B:B,6T:P}));P["2B"+B].15(P,K)}},4M:q(N){l(45 6=="11")v;N=N||6.N.29(1Q.N);l(!N)v;u 2R=V;u c=7.1C[N.B];E(u j 1o c){l(c[j].15(7,[N])===18){N.3Z();N.4N();2R=18}}v 2R},29:q(N){l(N){N.3Z=q(){7.2R=18};N.4N=q(){7.6V=V}}v N}}});17 q(){u b=5n.5p.4Q();6.1n={35:/6W/.1Y(b),3r:/3r/.1Y(b),23:/23/.1Y(b)&&!/3r/.1Y(b),3t:/3t/.1Y(b)&&!/6X/.1Y(b)};6.6Z=!6.1n.23||16.70=="71"};6.2f={2q:{72:"4S",4T:"4U",2y:"4V",74:"4X"},1g:"28,1w,77,78,4Y,4Z,31,79,7a".4a(","),1k:["51","52","53","54"],1F:{1B:"19",5f:"2v",2X:U,7b:U,1s:U,7c:U,3c:U,7d:U},4e:{57:"a.1u",7e:6.2M,2M:6.2M,3a:"6.1q(a).3a",3R:"6.1q(a).3R",26:6.1q,7g:"6.1q(a.1H)"},R:{7i:q(1J){7.7k(1J)},1x:q(){7.1d.1m=7.2l?7.2l:"";l(6.1g(7,"1m")=="1Z")7.1d.1m="2L"},1l:q(){7.2l=7.2l||6.1g(7,"1m");l(7.2l=="1Z")7.2l="2L";7.1d.1m="1Z"},40:q(){$(7)[$(7).3v(":1V")?"1x":"1l"].15($(7),1b)},7l:q(c){6.1h.1W(7,c)},7m:q(c){6.1h.2g(7,c)},7n:q(c){6.1h[6.1h.3p(7,c)?"2g":"1W"](7,c)},2g:q(a){l(!a||6.1k(a,[7]).r)7.1u.3j(7)},5d:q(){2t(7.1H)7.3j(7.1H)},2U:q(B,C){l(C.I==1M)C=17 1e("e",(!C.1a(".")?"$(7)":"v ")+C);6.N.1W(7,B,C)},5s:q(B,C){6.N.2g(7,B,C)},1I:q(B,K){6.N.1I(B,K,7)}}};6.5e();6.C.1T({5h:6.C.40,40:q(a,b){v a&&b&&a.I==1e&&b.I==1e?7.5l(q(e){7.1K=7.1K==a?b:a;e.3Z();v 7.1K.15(7,[e])||18}):7.5h.15(7,1b)},7q:q(f,g){q 44(e){u p=(e.B=="3l"?e.7r:e.7s)||e.7t;2t(p&&p!=7)p=p.1u;l(p==7)v 18;v(e.B=="3l"?f:g).15(7,[e])}v 7.3l(44).5o(44)},1X:q(f){l(6.3f)f.15(16);H{6.2w.1i(f)}v 7}});6.1T({3f:18,2w:[],1X:q(){l(!6.3f){6.3f=V;l(6.2w){E(u i=0;i<6.2w.D;i++)6.2w[i].15(16);6.2w=U}}}});17 q(){u e=("7w,7x,2J,7y,7z,7A,5l,7B,"+"7C,7D,7E,3l,5o,7F,7H,7I,"+"7K,7L,7N,7O,2h").4a(",");E(u i=0;i<e.D;i++)17 q(){u o=e[i];6.C[o]=q(f){v f?7.2U(o,f):7.1I(o)};6.C["7Q"+o]=q(f){v 7.5s(o,f)};6.C["7S"+o]=q(f){v 7.R(q(){u 5v=0;6.N.1W(7,o,q(e){l(5v++)v;v f.15(7,[e])})})}};l(6.1n.3t||6.1n.3r){16.7T("5w",6.1X,18)}H l(6.1n.23){16.5x("<5y"+"5z 2X=4d 5A=V "+"3c=//:><\\/2e>");u 2e=16.4c("4d");2e.2p=q(){l(7.2Q!="1D")v;7.1u.3j(7);6.1X()};2e=U}H l(6.1n.35){6.3U=3A(q(){l(16.2Q=="5E"||16.2Q=="1D"){4L(6.3U);6.3U=U;6.1X()}},10)}6.N.1W(1Q,"2J",6.1X)};6.C.1T({56:6.C.1x,1x:q(W,F){v W?7.1N({1w:"1x",28:"1x",1v:"1x"},W,F):7.56()},5t:6.C.1l,1l:q(W,F){v W?7.1N({1w:"1l",28:"1l",1v:"1l"},W,F):7.5t()},5R:q(W,F){v 7.1N({1w:"1x"},W,F)},5T:q(W,F){v 7.1N({1w:"1l"},W,F)},5U:q(W,F){v 7.R(q(){u 4g=$(7).3v(":1V")?"1x":"1l";$(7).1N({1w:4g},W,F)})},5Y:q(W,F){v 7.1N({1v:"1x"},W,F)},61:q(W,F){v 7.1N({1v:"1l"},W,F)},62:q(W,2q,F){v 7.1N({1v:2q},W,F)},1N:q(G,W,F){v 7.1p(q(){7.2z=G;E(u p 1o G){u e=17 6.2K(7,6.W(W,F),p);l(G[p].I==4o)e.2Y(e.1f(),G[p]);H e[G[p]](G)}})},1p:q(B,C){l(!C){C=B;B="2K"}v 7.R(q(){l(!7.1p)7.1p={};l(!7.1p[B])7.1p[B]=[];7.1p[B].1i(C);l(7.1p[B].D==1)C.15(7)})}});6.1T({50:q(e,p){l(e.4k)v;l(p=="1w"&&e.4h!=2V(6.1U(e,p)))v;l(p=="28"&&e.5r!=2V(6.1U(e,p)))v;u a=e.1d[p];u o=6.1U(e,p,1);l(p=="1w"&&e.4h!=o||p=="28"&&e.5r!=o)v;e.1d[p]=e.2D?"":"4i";u n=6.1U(e,p,1);l(o!=n&&n!="4i"){e.1d[p]=a;e.4k=V}},W:q(s,o){o=o||{};l(o.I==1e)o={1D:o};u 4p={6d:6e,6f:4m};o.2I=(s&&s.I==4o?s:4p[s])||5b;o.3e=o.1D;o.1D=q(){6.4r(7,"2K");l(o.3e&&o.3e.I==1e)o.3e.15(7)};v o},1p:{},4r:q(J,B){B=B||"2K";l(J.1p&&J.1p[B]){J.1p[B].3z();u f=J.1p[B][0];l(f)f.15(J)}},2K:q(J,2s,G){u z=7;z.o={2I:2s.2I||5b,1D:2s.1D,2o:2s.2o};z.T=J;u y=z.T.1d;z.a=q(){l(2s.2o)2s.2o.15(J,[z.1E]);l(G=="1v"){l(6.1n.3t&&z.1E==1)z.1E=0.6s;l(1Q.5m)y.1k="6t(1v="+z.1E*6u+")";H y.1v=z.1E}H l(2V(z.1E))y[G]=2V(z.1E)+"4W";y.1m="2L"};z.4z=q(){v 3C(6.1g(z.T,G))};z.1f=q(){u r=3C(6.1U(z.T,G));v r&&r>-6C?r:z.4z()};z.2Y=q(3H,2q){z.3P=(17 4I()).4K();z.1E=3H;z.a();z.3K=3A(q(){z.2o(3H,2q)},13)};z.1x=q(p){l(!z.T.1O)z.T.1O={};z.T.1O[G]=7.1f();z.2Y(0,z.T.1O[G]);l(G!="1v")y[G]="6J"};z.1l=q(){l(!z.T.1O)z.T.1O={};z.T.1O[G]=7.1f();z.o.1l=V;z.2Y(z.T.1O[G],0)};l(6.1n.23&&!z.T.2D.6M)y.6O="1";l(!z.T.6P)z.T.4O=6.1g(z.T,"31");y.31="1V";z.2o=q(3V,3T){u t=(17 4I()).4K();l(t>z.o.2I+z.3P){4L(z.3K);z.3K=U;z.1E=3T;z.a();z.T.2z[G]=V;u 1L=V;E(u i 1o z.T.2z)l(z.T.2z[i]!==V)1L=18;l(1L){y.31=z.T.4O;l(z.o.1l)y.1m=\'1Z\';l(z.o.1l){E(u p 1o z.T.2z){y[p]=z.T.1O[p]+(p=="1v"?"":"4W");l(p==\'1w\'||p==\'28\')6.50(z.T,p)}}}l(1L&&z.o.1D&&z.o.1D.I==1e)z.o.1D.15(z.T)}H{u p=(t-7.3P)/z.o.2I;z.1E=((-5a.7f(p*5a.7j)/2)+0.5)*(3T-3V)+3V;z.a()}}}});6.C.7o=q(O,1G,F){7.2J(O,1G,F,1)};6.C.2J=q(O,1G,F,1P){l(O.I==1e)v 7.2U("2J",O);F=F||q(){};u B="49";l(1G){l(1G.I==1e){F=1G;1G=U}H{1G=6.2N(1G);B="4b"}}u 3g=7;6.3n(B,O,1G,q(3h,14){l(14=="2u"||!1P&&14=="58"){3g.5f(3h.2O).R(F,[3h.2O,14]);$("2e",3g).R(q(){l(7.3c)$.4E(7.3c);H 30.4l(1Q,7.42||7.7u||7.2v||"")})}H F.15(3g,[3h.2O,14])},1P);v 7};l(6.1n.23&&45 32=="11")32=q(){v 17 5m(5n.5p.1a("7J 5")>=0?"7P.5u":"7R.5u")};17 q(){u e="4n,5j,5i,5g,5c".4a(\',\');E(u i=0;i<e.D;i++)17 q(){u o=e[i];6.C[o]=q(f){v 7.2U(o,f)}}};6.1T({1t:q(O,K,F,B,1P){l(K.I==1e){B=F;F=K;K=U}l(K)O+="?"+6.2N(K);6.3n("49",O,U,q(r,14){l(F)F(6.3W(r,B),14)},1P)},5N:q(O,K,F,B){6.1t(O,K,F,B,1)},4E:q(O,K,F){6.1t(O,K,F,"2e")},5Z:q(O,K,F,B){6.3n("4b",O,6.2N(K),q(r,14){l(F)F(6.3W(r,B),14)})},1S:0,6a:q(1S){6.1S=1S},2Z:{},3n:q(B,O,K,L,1P){l(!O){L=B.1D;u 2u=B.2u;u 2h=B.2h;K=B.K;O=B.O;B=B.B}l(!6.41++)6.N.1I("4n");u 48=18;u M=17 32();M.6h(B||"49",O,V);l(K)M.34("6m-6q","6r/x-6v-6y-6B");l(1P)M.34("6D-3D-6F",6.2Z[O]||"6H, 6I 6L 6N 3F:3F:3F 6Q");M.34("X-6S-6U","32");l(M.6Y)M.34("73","75");u 2p=q(3Q){l(M&&(M.2Q==4||3Q=="1S")){48=V;u 14=6.4f(M)&&3Q!="1S"?1P&&6.4t(M,O)?"58":"2u":"2h";l(14!="2h"){u 3S=M.3Y("4x-3D");l(1P&&3S)6.2Z[O]=3S;l(2u)2u(M,14);6.N.1I("5c")}H{l(2h)2h(M,14);6.N.1I("5g")}6.N.1I("5i");l(!--6.41)6.N.1I("5j");l(L)L(M,14);M.2p=q(){};M=U}};M.2p=2p;l(6.1S>0)7G(q(){l(M){M.7M();l(!48)2p("1S");M=U}},6.1S);M.5G(K)},41:0,4f:q(r){4w{v!r.14&&5V.63=="6b:"||(r.14>=4m&&r.14<6i)||r.14==4B||6.1n.35&&r.14==11}55(e){}v 18},4t:q(M,O){4w{u 4C=M.3Y("4x-3D");v M.14==4B||4C==6.2Z[O]||6.1n.35&&M.14==11}55(e){}v 18},3W:q(r,B){u 46=r.3Y("7v-B");u K=!B&&46&&46.1a("M")>=0;K=B=="M"||K?r.5B:r.2O;l(B=="2e")30.4l(1Q,K);l(B=="6K")30("K = "+K);v K},2N:q(a){u s=[];l(a.I==2r){E(u i=0;i<a.D;i++)s.1i(a[i].1s+"="+4D(a[i].19))}H{E(u j 1o a)s.1i(j+"="+4D(a[j]))}v s.7U("&")}});',62,492,'||||||jQuery|this||||||||||||||if|||||function||||var|return||||||type|fn|length|for|callback|prop|else|constructor|elem|data|ret|xml|event|url|element||each||el|null|true|speed||elems|||undefined|obj||status|apply|document|new|false|value|indexOf|arguments|context|style|Function|cur|css|className|push|table|filter|hide|display|browser|in|queue|sibling|replace|name|get|parentNode|opacity|height|show|args|result|div|val|events|complete|now|attr|params|firstChild|trigger|key|last|done|String|animate|orig|ifModified|window|nodeType|timeout|extend|curCSS|hidden|add|ready|test|none|handler|merge|tbody|msie|num|old|siblings|find|width|fix|pos|first|childNodes|map|script|macros|remove|error|pushStack|guid|not|oldblock|re|expr|step|onreadystatechange|to|Array|options|while|success|innerHTML|readyList|domManip|insertBefore|curAnim|disabled|on|global|currentStyle|dir|grep|handlers|substr|duration|load|fx|block|parents|param|responseText|stack|readyState|returnValue|foundToken|second|bind|parseInt|exec|id|custom|lastModified|eval|overflow|XMLHttpRequest|getAttribute|setRequestHeader|safari|RegExp|clean|trim|oWidth|next|child|src|token|oldComplete|isReady|self|res|tr|removeChild|jquery|mouseover|oHeight|ajax|toUpperCase|has|cloneNode|opera|defaultView|mozilla|re2|is|getAll|swap|td|shift|setInterval|visibility|parseFloat|Modified|matched|00|noCollision|from|inv|_|timer|appendChild|deep|oid|clone|startTime|istimeout|prev|modRes|lastNum|safariTimer|firstNum|httpData|nodeName|getResponseHeader|preventDefault|toggle|active|text|thead|handleHover|typeof|ct|getComputedStyle|requestDone|GET|split|POST|getElementById|__ie_init|axis|httpSuccess|state|scrollHeight|auto|force|notAuto|call|200|ajaxStart|Number|ss|createElement|dequeue|nth|httpNotModified|selected|documentElement|try|Last|getElementsByTagName|max|z0|304|xmlRes|encodeURIComponent|getScript|continue|even|odd|Date|delete|getTime|clearInterval|handle|stopPropagation|oldOverflow|size|toLowerCase|parse|append|prependTo|prepend|before|px|after|position|float|setAuto|eq|lt|gt|contains|catch|_show|parent|notmodified|checked|Math|400|ajaxSuccess|empty|init|html|ajaxError|_toggle|ajaxComplete|ajaxStop|getPropertyValue|click|ActiveXObject|navigator|mouseout|userAgent|newProp|scrollWidth|unbind|_hide|XMLHTTP|count|DOMContentLoaded|write|scr|ipt|defer|responseXML|prototype|Left|loaded|index|send|padding|wrap|nextSibling|end|pop|Boolean|getIfModified|border|TABLE|THEAD|slideDown|initDone|slideUp|slideToggle|location|Top|Right|fadeIn|post|Bottom|fadeOut|fadeTo|protocol|Width|offsetHeight|offsetWidth|absolute|body|clientHeight|ajaxTimeout|file|clientWidth|slow|600|fast|th|open|300|createTextNode|toString|only|Content|innerText|visible|enabled|Type|application|9999|alpha|100|www|htmlFor|cssFloat|form|setAttribute|ig|urlencoded|10000|If|9_|Since|break|Thu|01|1px|json|Jan|hasLayout|1970|zoom|oldOverlay|GMT|unshift|Requested|target|With|cancelBubble|webkit|compatible|overrideMimeType|boxModel|compatMode|CSS1Compat|appendTo|Connection|insertAfter|close|class|top|left|color|background|title|href|rel|ancestors|cos|children|nodeValue|removeAttr|PI|removeAttribute|addClass|removeClass|toggleClass|loadIfModified|249|hover|fromElement|toElement|relatedTarget|textContent|content|blur|focus|resize|scroll|unload|dblclick|mousedown|mouseup|mousemove|change|setTimeout|reset|select|MSIE|submit|keydown|abort|keypress|keyup|Microsoft|un|Msxml2|one|addEventListener|join|Rev'.split('|'),0,{}))
Index: misc/progress.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/progress.js,v
retrieving revision 1.10
diff -u -F^f -r1.10 progress.js
--- misc/progress.js	28 Mar 2006 09:29:23 -0000	1.10
+++ misc/progress.js	23 Sep 2006 13:57:10 -0000
@@ -1,49 +1,39 @@
-// $Id: progress.js,v 1.10 2006/03/28 09:29:23 killes Exp $
+// $Id: progress.js,v 1.11 2006/08/31 23:31:25 unconed Exp $
 
 /**
  * A progressbar object. Initialized with the given id. Must be inserted into
  * the DOM afterwards through progressBar.element.
  *
  * method is the function which will perform the HTTP request to get the
- * progress bar state. Either HTTPGet or HTTPPost.
+ * progress bar state. Either "GET" or "POST".
  *
  * e.g. pb = new progressBar('myProgressBar');
  *      some_element.appendChild(pb.element);
  */
-function progressBar(id, updateCallback, method, errorCallback) {
+Drupal.progressBar = function (id, updateCallback, method, errorCallback) {
   var pb = this;
   this.id = id;
-  this.method = method ? method : HTTPGet;
+  this.method = method || "GET";
   this.updateCallback = updateCallback;
   this.errorCallback = errorCallback;
 
   this.element = document.createElement('div');
   this.element.id = id;
   this.element.className = 'progress';
-  this.element.innerHTML = '<div class="percentage"></div>'+
-                           '<div class="message">&nbsp;</div>'+
-                           '<div class="bar"><div class="filled"></div></div>';
+  $(this.element).html('<div class="percentage"></div>'+
+                       '<div class="message">&nbsp;</div>'+
+                       '<div class="bar"><div class="filled"></div></div>');
 }
 
 /**
  * Set the percentage and status message for the progressbar.
  */
-progressBar.prototype.setProgress = function (percentage, message) {
-  var divs = this.element.getElementsByTagName('div');
-  var div;
-  for (var i = 0; div = divs[i]; ++i) {
-    if (percentage >= 0) {
-      if (hasClass(divs[i], 'filled')) {
-        divs[i].style.width = percentage + '%';
-      }
-      if (hasClass(divs[i], 'percentage')) {
-        divs[i].innerHTML = percentage + '%';
-      }
-    }
-    if (hasClass(divs[i], 'message')) {
-      divs[i].innerHTML = message;
-    }
+Drupal.progressBar.prototype.setProgress = function (percentage, message) {
+  if (percentage >= 0 && percentage <= 100) {
+    $('div.filled', this.element).css('width', percentage +'%');
+    $('div.percentage', this.element).html(percentage +'%');
   }
+  $('div.message', this.element).html(message);
   if (this.updateCallback) {
     this.updateCallback(percentage, message, this);
   }
@@ -52,7 +42,7 @@ function progressBar(id, updateCallback,
 /**
  * Start monitoring progress via Ajax.
  */
-progressBar.prototype.startMonitoring = function (uri, delay) {
+Drupal.progressBar.prototype.startMonitoring = function (uri, delay) {
   this.delay = delay;
   this.uri = uri;
   this.sendPing();
@@ -61,7 +51,7 @@ function progressBar(id, updateCallback,
 /**
  * Stop monitoring progress via Ajax.
  */
-progressBar.prototype.stopMonitoring = function () {
+Drupal.progressBar.prototype.stopMonitoring = function () {
   clearTimeout(this.timer);
   // This allows monitoring to be stopped from within the callback
   this.uri = null;
@@ -70,47 +60,44 @@ function progressBar(id, updateCallback,
 /**
  * Request progress data from server.
  */
-progressBar.prototype.sendPing = function () {
+Drupal.progressBar.prototype.sendPing = function () {
   if (this.timer) {
     clearTimeout(this.timer);
   }
   if (this.uri) {
-    this.method(this.uri, this.receivePing, this, '');
-  }
-}
-
-/**
- * HTTP callback function. Passes data back to the progressbar and sets a new
- * timer for the next ping.
- */
-progressBar.prototype.receivePing = function (string, xmlhttp, pb) {
-  if (xmlhttp.status != 200) {
-    return pb.displayError('An HTTP error '+ xmlhttp.status +' occured.\n'+ pb.uri);
-  }
-  // Parse response
-  var progress = parseJson(string);
-  // Display errors
-  if (progress.status == 0) {
-    pb.displayError(progress.data);
-    return;
+    var pb = this;
+    $.ajax({
+      type: this.method,
+      url: this.uri,
+      success: function (xmlhttp) {
+        // Parse response
+        var progress = Drupal.parseJson(xmlhttp.responseText);
+        // Display errors
+        if (progress.status == 0) {
+          pb.displayError(progress.data);
+          return;
+        }
+        // Update display
+        pb.setProgress(progress.percentage, progress.message);
+        // Schedule next timer
+        pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
+      },
+      error: function (xmlhttp) {
+        pb.displayError('An HTTP error '+ xmlhttp.status +' occured.\n'+ pb.uri);
+      }
+    });
   }
-
-  // Update display
-  pb.setProgress(progress.percentage, progress.message);
-  // Schedule next timer
-  pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
 }
 
 /**
  * Display errors on the page.
  */
-progressBar.prototype.displayError = function (string) {
+Drupal.progressBar.prototype.displayError = function (string) {
   var error = document.createElement('div');
   error.className = 'error';
   error.innerHTML = string;
 
-  this.element.style.display = 'none';
-  this.element.parentNode.insertBefore(error, this.element);
+  $(this.element).before(error).hide();
 
   if (this.errorCallback) {
     this.errorCallback(this);
Index: misc/textarea.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/textarea.js,v
retrieving revision 1.9
diff -u -F^f -r1.9 textarea.js
--- misc/textarea.js	14 Apr 2006 13:48:56 -0000	1.9
+++ misc/textarea.js	23 Sep 2006 13:57:10 -0000
@@ -1,122 +1,34 @@
-// $Id: textarea.js,v 1.9 2006/04/14 13:48:56 killes Exp $
+// $Id: textarea.js,v 1.11 2006/09/07 08:05:31 dries Exp $
 
-if (isJsEnabled()) {
-  addLoadEvent(textAreaAutoAttach);
-}
-
-function textAreaAutoAttach(event, parent) {
-  if (typeof parent == 'undefined') {
-    // Attach to all visible textareas.
-    textareas = document.getElementsByTagName('textarea');
-  }
-  else {
-    // Attach to all visible textareas inside parent.
-    textareas = parent.getElementsByTagName('textarea');
-  }
-  var textarea;
-  for (var i = 0; textarea = textareas[i]; ++i) {
-    if (hasClass(textarea, 'resizable') && !hasClass(textarea.nextSibling, 'grippie')) {
-      if (typeof dimensions(textarea).width != 'undefined' && dimensions(textarea).width != 0) {
-        new textArea(textarea);
-      }
+Drupal.textareaAttach = function() {
+  $('textarea.resizable:not(.processed)').each(function() {
+    var textarea = $(this).addClass('processed'), staticOffset = null;
+
+    $(this).wrap('<div class="resizable-textarea"></div>')
+      .parent().append($('<div class="grippie"></div>').mousedown(startDrag));
+
+    var grippie = $('div.grippie', $(this).parent())[0];
+    grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';
+
+    function startDrag(e) {
+      staticOffset = textarea.height() - Drupal.mousePosition(e).y;
+      textarea.css('opacity', 0.25);
+      $(document).mousemove(performDrag).mouseup(endDrag);
+      return false;
     }
-  }
-}
-
-function textArea(element) {
-  var ta = this;
-  this.element = element;
-  this.parent = this.element.parentNode;
-  this.dimensions = dimensions(element);
-
-  // Prepare wrapper
-  this.wrapper = document.createElement('div');
-  this.wrapper.className = 'resizable-textarea';
-  this.parent.insertBefore(this.wrapper, this.element);
-
-  // Add grippie and measure it
-  this.grippie = document.createElement('div');
-  this.grippie.className = 'grippie';
-  this.wrapper.appendChild(this.grippie);
-  this.grippie.dimensions = dimensions(this.grippie);
-  this.grippie.onmousedown = function (e) { ta.beginDrag(e); };
-
-  // Set wrapper and textarea dimensions
-  this.wrapper.style.height = this.dimensions.height + this.grippie.dimensions.height + 1 +'px';
-  this.element.style.marginBottom = '0px';
-  this.element.style.width = '100%';
-  this.element.style.height = this.dimensions.height +'px';
-
-  // Wrap textarea
-  removeNode(this.element);
-  this.wrapper.insertBefore(this.element, this.grippie);
-
-  // Measure difference between desired and actual textarea dimensions to account for padding/borders
-  this.widthOffset = dimensions(this.wrapper).width - this.dimensions.width;
-
-  // Make the grippie line up in various browsers
-  if (window.opera) {
-    // Opera
-    this.grippie.style.marginRight = '4px';
-  }
-  if (document.all && !window.opera) {
-    // IE
-    this.grippie.style.width = '100%';
-    this.grippie.style.paddingLeft = '2px';
-  }
-  // Mozilla
-  this.element.style.MozBoxSizing = 'border-box';
-
-  this.heightOffset = absolutePosition(this.grippie).y - absolutePosition(this.element).y - this.dimensions.height;
-}
-
-textArea.prototype.beginDrag = function (event) {
-  if (document.isDragging) {
-    return;
-  }
-  document.isDragging = true;
-
-  event = event || window.event;
-  // Capture mouse
-  var cp = this;
-  this.oldMoveHandler = document.onmousemove;
-  document.onmousemove = function(e) { cp.handleDrag(e); };
-  this.oldUpHandler = document.onmouseup;
-  document.onmouseup = function(e) { cp.endDrag(e); };
-
-  // Store drag offset from grippie top
-  var pos = absolutePosition(this.grippie);
-  this.dragOffset = event.clientY - pos.y;
 
-  // Make transparent
-  this.element.style.opacity = 0.5;
-
-  // Process
-  this.handleDrag(event);
-}
-
-textArea.prototype.handleDrag = function (event) {
-  event = event || window.event;
-  // Get coordinates relative to text area
-  var pos = absolutePosition(this.element);
-  var y = event.clientY - pos.y;
-
-  // Set new height
-  var height = Math.max(32, y - this.dragOffset - this.heightOffset);
-  this.wrapper.style.height = height + this.grippie.dimensions.height + 1 + 'px';
-  this.element.style.height = height + 'px';
+    function performDrag(e) {
+      textarea.height(Math.max(32, staticOffset + Drupal.mousePosition(e).y) + 'px');
+      return false;
+    }
 
-  // Avoid text selection
-  stopEvent(event);
+    function endDrag(e) {
+      $(document).unmousemove(performDrag).unmouseup(endDrag);
+      textarea.css('opacity', 1);
+    }
+  });
 }
 
-textArea.prototype.endDrag = function (event) {
-  // Uncapture mouse
-  document.onmousemove = this.oldMoveHandler;
-  document.onmouseup = this.oldUpHandler;
-
-  // Restore opacity
-  this.element.style.opacity = 1.0;
-  document.isDragging = false;
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.textareaAttach);
 }
-
Index: misc/update.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/update.js,v
retrieving revision 1.8
diff -u -F^f -r1.8 update.js
--- misc/update.js	28 Mar 2006 09:29:23 -0000	1.8
+++ misc/update.js	23 Sep 2006 13:57:10 -0000
@@ -1,12 +1,11 @@
-// $Id: update.js,v 1.8 2006/03/28 09:29:23 killes Exp $
+// $Id: update.js,v 1.9 2006/08/31 23:31:25 unconed Exp $
 
-if (isJsEnabled()) {
-  addLoadEvent(function() {
-    if ($('edit-has_js')) {
-      $('edit-has_js').value = 1;
-    }
+if (Drupal.jsEnabled) {
+  $(document).ready(function() {
+    $('#edit-has_js').each(function() { this.value = 1; });
+    $('#progress').each(function () {
+      var holder = this;
 
-    if ($('progress')) {
       // Success: redirect to the summary.
       var updateCallback = function (progress, status, pb) {
         if (progress == 100) {
@@ -19,15 +18,15 @@
       var errorCallback = function (pb) {
         var div = document.createElement('p');
         div.className = 'error';
-        div.innerHTML = 'An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>';
-        $('progress').insertBefore(div, $('progress').firstChild);
-        $('wait').style.display = 'none';
+        $(div).html('An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>');
+        $(holder).prepend(div);
+        $('#wait').hide();
       }
 
-      var progress = new progressBar('updateprogress', updateCallback, HTTPPost, errorCallback);
+      var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
       progress.setProgress(-1, 'Starting updates');
-      $('progress').appendChild(progress.element);
+      $(holder).append(progress.element);
       progress.startMonitoring('update.php?op=do_update', 0);
-    }
+    });
   });
 }
Index: misc/upload.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/upload.js,v
retrieving revision 1.8.2.1
diff -u -F^f -r1.8.2.1 upload.js
--- misc/upload.js	5 May 2006 11:57:19 -0000	1.8.2.1
+++ misc/upload.js	23 Sep 2006 13:57:10 -0000
@@ -1,75 +1,116 @@
-// $Id: upload.js,v 1.8.2.1 2006/05/05 11:57:19 killes Exp $
-
-// Global killswitch
-if (isJsEnabled()) {
-  addLoadEvent(uploadAutoAttach);
-}
+// $Id: upload.js,v 1.11 2006/08/31 23:31:25 unconed Exp $
 
 /**
  * Attaches the upload behaviour to the upload form.
  */
-function uploadAutoAttach() {
-  var inputs = document.getElementsByTagName('input');
-  for (i = 0; input = inputs[i]; i++) {
-    if (input && hasClass(input, 'upload')) {
-      var uri = input.value;
-      // Extract the button ID based on a substring of the input name: edit[foo][bar] -> foo-bar
-      var button = input.name.substr(5, input.name.length - 6).replace('][', '-');
-      var wrapper = button + '-wrapper';
-      var hide = button + '-hide';
-      var upload = new jsUpload(uri, button, wrapper, hide);
-    }
-  }
+Drupal.uploadAutoAttach = function() {
+  $('input.upload').each(function () {
+    var uri = this.value;
+    // Extract the base name from the id (edit-attach-url -> attach).
+    var base = this.id.substring(5, this.id.length - 4);
+    var button = base + '-button';
+    var wrapper = base + '-wrapper';
+    var hide = base + '-hide';
+    var upload = new Drupal.jsUpload(uri, button, wrapper, hide);
+  });
 }
 
 /**
  * JS upload object.
  */
-function jsUpload(uri, button, wrapper, hide) {
-  this.button = button;
-  this.wrapper = wrapper;
-  this.hide = hide;
-  redirectFormButton(uri, $(button), this);
+Drupal.jsUpload = function(uri, button, wrapper, hide) {
+  // Note: these elements are replaced after an upload, so we re-select them
+  // everytime they are needed.
+  this.button = '#'+ button;
+  this.wrapper = '#'+ wrapper;
+  this.hide = '#'+ hide;
+  Drupal.redirectFormButton(uri, $(this.button).get(0), this);
 }
 
 /**
  * Handler for the form redirection submission.
  */
-jsUpload.prototype.onsubmit = function () {
-  var hide = $(this.hide);
+Drupal.jsUpload.prototype.onsubmit = function () {
   // Insert progressbar and stretch to take the same space.
-  this.progress = new progressBar('uploadprogress');
+  this.progress = new Drupal.progressBar('uploadprogress');
   this.progress.setProgress(-1, 'Uploading file');
-  this.progress.element.style.width = '28em';
-  this.progress.element.style.height = hide.offsetHeight +'px';
-  hide.parentNode.insertBefore(this.progress.element, hide);
-  // Hide file form (cannot use display: none, this mysteriously aborts form
-  // submission in Konqueror)
-  hide.style.position = 'absolute';
-  hide.style.left = '-2000px';
+
+  var hide = this.hide;
+  var el = this.progress.element;
+  var offset = $(hide).get(0).offsetHeight;
+  $(el).css({
+    width: '28em',
+    height: offset +'px',
+    paddingTop: '10px',
+    display: 'none'
+  });
+  $(hide).css('position', 'absolute');
+
+  $(hide).after(el);
+  $(el).fadeIn('slow');
+  $(hide).fadeOut('slow');
 }
 
 /**
  * Handler for the form redirection completion.
  */
-jsUpload.prototype.oncomplete = function (data) {
-  // Remove progressbar
-  removeNode(this.progress.element);
-  this.progress = null;
-  // Replace form and re-attach behaviour
-  $(this.wrapper).innerHTML = data;
-  uploadAutoAttach();
+Drupal.jsUpload.prototype.oncomplete = function (data) {
+  // Remove old form
+  Drupal.freezeHeight(); // Avoid unnecessary scrolling
+  $(this.wrapper).html('');
+
+  // Place HTML into temporary div
+  var div = document.createElement('div');
+  $(div).html(data);
+
+  // If uploading the first attachment fade in everything
+  if ($('tr', div).size() == 2) {
+    // Replace form and re-attach behaviour
+    $(div).hide();
+    $(this.wrapper).append(div);
+    $(div).fadeIn('slow');
+    Drupal.uploadAutoAttach();
+  }
+  // Else fade in only the last table row
+  else {
+    // Hide form and last table row
+    $('table tr:last-of-type td', div).hide();
+
+    // Note: workaround because jQuery's #id selector does not work outside of 'document'
+    // Should be: $(this.hide, div).hide();
+    var hide = this.hide;
+    $('div', div).each(function() {
+      if (('#'+ this.id) == hide) {
+        this.style.display = 'none';
+      }
+    });
+
+    // Replace form, fade in items and re-attach behaviour
+    $(this.wrapper).append(div);
+    $('table tr:last-of-type td', div).fadeIn('slow');
+    $(this.hide, div).fadeIn('slow');
+    Drupal.uploadAutoAttach();
+  }
+  Drupal.unfreezeHeight();
 }
 
 /**
  * Handler for the form redirection error.
  */
-jsUpload.prototype.onerror = function (error) {
+Drupal.jsUpload.prototype.onerror = function (error) {
   alert('An error occurred:\n\n'+ error);
   // Remove progressbar
-  removeNode(this.progress.element);
+  $(this.progress.element).remove();
   this.progress = null;
   // Undo hide
-  $(this.hide).style.position = 'static';
-  $(this.hide).style.left = '0px';
+  $(this.hide).css({
+    position: 'static',
+    left: '0px'
+  });
+}
+
+
+// Global killswitch
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.uploadAutoAttach);
 }
