Index: misc/autofocus.js
===================================================================
RCS file: misc/autofocus.js
diff -N misc/autofocus.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ misc/autofocus.js	4 Jan 2007 19:13:24 -0000
@@ -0,0 +1,16 @@
+// $Id$
+
+/**
+ * Focuses a field on page load
+ */
+
+// Global Killswitch
+if (Drupal.jsEnabled) {
+  $(document).ready(function() {
+    var field = $('input.form-autofocus, textarea.form-autofocus');
+    if (field[0]) {
+      field[0].focus();
+      field[0].select();
+    }
+  });
+}
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.170
diff -u -d -F^\s*function -r1.170 form.inc
--- includes/form.inc	2 Jan 2007 05:58:53 -0000	1.170
+++ includes/form.inc	4 Jan 2007 19:13:24 -0000
@@ -1340,6 +1340,10 @@ function theme_textfield($element) {
     $class[] = 'form-autocomplete';
     $extra =  '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], NULL, NULL, TRUE)) .'" disabled="disabled" />';
   }
+  if (isset($element['#autofocus']) && $element['#autofocus']) {
+    drupal_add_js('misc/autofocus.js');
+    $class[] = 'form-autofocus';
+  }
   _form_set_class($element, $class);
 
   if (isset($element['#field_prefix'])) {
@@ -1385,6 +1389,10 @@ function theme_textarea($element) {
     drupal_add_js('misc/textarea.js');
     $class[] = 'resizable';
   }
+  if (isset($element['#autofocus']) && $element['#autofocus']) {
+    drupal_add_js('misc/autofocus.js');
+    $class[] = 'form-autofocus';
+  }
 
   $cols = $element['#cols'] ? ' cols="'. $element['#cols'] .'"' : '';
   _form_set_class($element, $class);
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.104
diff -u -d -F^\s*function -r1.104 locale.inc
--- includes/locale.inc	2 Jan 2007 05:05:38 -0000	1.104
+++ includes/locale.inc	4 Jan 2007 19:13:28 -0000
@@ -346,6 +346,7 @@ function _locale_string_seek_form() {
     '#size' => 30,
     '#maxlength' => 30,
     '#description' => t('Leave blank to show all strings. The search is case sensitive.'),
+    '#autofocus' => TRUE,
   );
   $form['search']['language'] = array('#type' => 'radios',
     '#title' => t('Language'),
@@ -384,6 +385,7 @@ function _locale_string_edit($lid) {
       '#title' => $languages['name'][$translation->locale],
       '#default_value' => $translation->translation,
       '#rows' => $rows,
+      '#autofocus' => TRUE,
     );
     unset($languages['name'][$translation->locale]);
   }
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.324
diff -u -d -F^\s*function -r1.324 aggregator.module
--- modules/aggregator/aggregator.module	26 Dec 2006 10:28:12 -0000	1.324
+++ modules/aggregator/aggregator.module	4 Jan 2007 19:13:31 -0000
@@ -320,6 +320,7 @@  function aggregator_form_category($edit
     '#default_value' => $edit['title'],
     '#maxlength' => 64,
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -425,6 +426,7 @@ function aggregator_form_feed($edit = ar
     '#maxlength' => 255,
     '#description' => t('The name of the feed; typically the name of the web site you syndicate content from.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['url'] = array('#type' => 'textfield',
     '#title' => t('URL'),
Index: modules/contact/contact.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v
retrieving revision 1.73
diff -u -d -F^\s*function -r1.73 contact.module
--- modules/contact/contact.module	2 Jan 2007 05:05:38 -0000	1.73
+++ modules/contact/contact.module	4 Jan 2007 19:13:33 -0000
@@ -165,6 +165,7 @@ function contact_admin_edit($cid = NULL)
     '#default_value' => $edit['category'],
     '#description' => t("Example: 'website feedback' or 'product information'."),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['recipients'] = array('#type' => 'textarea',
     '#title' => t('Recipients'),
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.158
diff -u -d -F^\s*function -r1.158 filter.module
--- modules/filter/filter.module	16 Dec 2006 01:05:11 -0000	1.158
+++ modules/filter/filter.module	4 Jan 2007 19:13:37 -0000
@@ -411,6 +411,7 @@ function filter_admin_format_form($forma
     '#default_value' => $format->name,
     '#description' => t('Specify a unique name for this filter format.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
 
   // Add a row of checkboxes for form group.
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.373
diff -u -d -F^\s*function -r1.373 forum.module
--- modules/forum/forum.module	25 Dec 2006 22:22:42 -0000	1.373
+++ modules/forum/forum.module	4 Jan 2007 19:13:39 -0000
@@ -442,7 +442,8 @@ function forum_form_container($edit = ar
     '#default_value' => $edit['name'],
     '#maxlength' =>  64,
     '#description' => t('The container name is used to identify related forums.'),
-    '#required' => TRUE
+    '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
 
   $form['description'] = array(
@@ -500,6 +501,7 @@ function forum_form_forum($edit = array(
     '#maxlength' =>  64,
     '#description' => t('The forum name is used to identify related discussions.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
Index: modules/node/content_types.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v
retrieving revision 1.23
diff -u -d -F^\s*function -r1.23 content_types.inc
--- modules/node/content_types.inc	29 Dec 2006 08:22:15 -0000	1.23
+++ modules/node/content_types.inc	4 Jan 2007 19:13:40 -0000
@@ -79,6 +79,7 @@ function node_type_form($type = NULL) {
     '#default_value' => $type->name,
     '#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>create content</em> page. It is recommended that this name begins with a capital letter and consists only of letters, numbers, and <strong>spaces</strong>. This name must be unique to this content type.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
 
   if (!$type->locked) {
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.765
diff -u -d -F^\s*function -r1.765 node.module
--- modules/node/node.module	4 Jan 2007 09:53:58 -0000	1.765
+++ modules/node/node.module	4 Jan 2007 19:13:47 -0000
@@ -1962,9 +1962,14 @@ function node_form($node, $form_values =
   $form['changed'] = array('#type' => 'hidden', '#default_value' => $node->changed);
 
   // Get the node-specific bits.
-  $form = array_merge_recursive($form, node_invoke($node, 'form', $form_values));
-  if (!isset($form['title']['#weight'])) {
-    $form['title']['#weight'] = -5;
+  $form = array_merge_recursive($form, node_invoke($node, 'form', $form_values));#
+  if (isset($form['title'])) {
+    if (!$node->nid && !isset($form['title']['#autofocus'])) {
+      $form['title']['#autofocus'] = TRUE;
+    }
+    if (!isset($form['title']['#weight'])) {
+      $form['title']['#weight'] = -5;
+    }
   }
 
   $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.104
diff -u -d -F^\s*function -r1.104 path.module
--- modules/path/path.module	18 Dec 2006 11:16:51 -0000	1.104
+++ modules/path/path.module	4 Jan 2007 19:13:48 -0000
@@ -182,6 +182,7 @@ function path_form($edit = '') {
     '#maxlength' => 64,
     '#size' => 45,
     '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.'),
+    '#autofocus' => TRUE,
     '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
   );
   $form['dst'] = array(
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.186
diff -u -d -F^\s*function -r1.186 profile.module
--- modules/profile/profile.module	27 Dec 2006 12:55:52 -0000	1.186
+++ modules/profile/profile.module	4 Jan 2007 19:13:50 -0000
@@ -232,6 +232,7 @@ function profile_field_form($arg = NULL)
     '#autocomplete_path' => 'admin/user/profile/autocomplete',
     '#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['fields']['title'] = array('#type' => 'textfield',
     '#title' => t('Title'),
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.329
diff -u -d -F^\s*function -r1.329 taxonomy.module
--- modules/taxonomy/taxonomy.module	20 Dec 2006 10:32:16 -0000	1.329
+++ modules/taxonomy/taxonomy.module	4 Jan 2007 19:13:59 -0000
@@ -222,6 +222,7 @@ function taxonomy_form_vocabulary($edit 
     '#maxlength' => 64,
     '#description' => t('The name for this vocabulary. Example: "Topic".'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -383,7 +384,9 @@ function taxonomy_form_term($vocabulary_
     '#default_value' => $edit['name'],
     '#maxlength' => 64,
     '#description' => t('The name of this term.'),
-    '#required' => TRUE);
+    '#required' => TRUE,
+    '#autofocus' => TRUE,
+  );
 
   $form['description'] = array(
     '#type' => 'textarea',
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.737
diff -u -d -F^\s*function -r1.737 user.module
--- modules/user/user.module	2 Jan 2007 05:05:38 -0000	1.737
+++ modules/user/user.module	4 Jan 2007 19:14:06 -0000
@@ -1898,6 +1898,7 @@ function user_admin_role() {
       '#required' => TRUE,
       '#maxlength' => 64,
       '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
+      '#autofocus' => TRUE,
     );
     $form['rid'] = array(
       '#type' => 'value',
