split m/;/, ($self->config->flags || '')
   ]);
 
-  $::request->layout->focus('#config_name');
   $self->render('custom_variable_config/form', %params);
 }
 
 
 sub show_login_form {
   my ($self, %params) = @_;
 
-  $::request->layout->focus('#auth_login');
   $self->render('login_screen/user_login', %params);
 }
 
 
   $params{CUSTOM_VARIABLES} = CVar->get_custom_variables(module => 'Projects', trans_id => $self->project->id);
   CVar->render_inputs(variables => $params{CUSTOM_VARIABLES}) if @{ $params{CUSTOM_VARIABLES} };
 
-  $::request->{layout}->focus('#projectnumber');
-
   $self->render('project/form', %params);
 }
 
 
 
   $form->{title}      = $locale->text('Add Price Factor');
   $form->{callback} ||= build_std_url('action=add_price_factor');
-  $::request->{layout}->focus('#description');
 
   $form->header();
   print $form->parse_html_template('am/edit_price_factor');
 
   $form->{title}      = $locale->text('Edit Price Factor');
   $form->{callback} ||= build_std_url('action=add_price_factor');
-  $::request->{layout}->focus('#description');
 
   AM->get_price_factor(\%myconfig, $form);
 
 
   $form->{title}      = $locale->text('Add Warehouse');
   $form->{callback} ||= build_std_url('action=add_warehouse');
-  $::request->{layout}->focus('#description');
 
   $form->header();
   print $form->parse_html_template('am/edit_warehouse');
 
   $form->{title}      = $locale->text('Edit Warehouse');
   $form->{callback} ||= build_std_url('action=list_warehouses');
-  $::request->{layout}->focus('#description');
 
   $form->header();
   print $form->parse_html_template('am/edit_warehouse');
 
 
     $options{"CAN_EDIT"} = $form->{"edit"};
 
-    if ($form->{edit}) {
-      $::request->{layout}->focus("#edit_content");
-
-    } else {
+    if (!$form->{edit}) {
       $options{"content"}                 = "\n\n" if (!$options{"content"});
       $options{"SHOW_SECOND_EDIT_BUTTON"} = $options{"lines"} > 25;
     }
 
   $form->all_vc(\%myconfig, "vendor", "AP");
 
   $form->{title}    = $locale->text('AP Transactions');
-  $::request->{layout}->focus('#vendor');
   $form->{jsscript} = 1;
 
   $form->get_lists("projects"     => { "key" => "ALL_PROJECTS", "all" => 1 },
 
     $taxcharts{$item->{id}} = $item;
   }
 
-  $::request->{layout}->focus("#customer");
-
   my $follow_up_vc         =  $form->{customer};
   $follow_up_vc            =~ s/--.*?//;
   my $follow_up_trans_info =  "$form->{invnumber} ($follow_up_vc)";
 
 
   $form->{jsscript} = 1;
   $form->{title}    = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
-  $::request->{layout}->focus('#name');
 
   $form->header();
   print $form->parse_html_template('ct/search');
   my @columns = (
     'id',        'name',      "$form->{db}number",   'contact',   'phone',
     'fax',       'email',     'taxnumber',           'street',    'zipcode' , 'city',
-    'business',  'invnumber', 'ordnumber',           'quonumber', 'salesman', 'country' 
+    'business',  'invnumber', 'ordnumber',           'quonumber', 'salesman', 'country'
   );
 
   my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
   $form->{taxzone_id}     = 0                                                               if !$form->{id};
   $form->{jsscript}       = 1;
   $form->{SHIPTO_ALL}     = [ +{ shipto_id => '0', shiptoname => $::locale->text('All') }, @{ $form->{SHIPTO} } ];
-  $::request->{layout}->focus("#greeting");
 
   $form->{title} = $form->{title_save}
                 || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : '');
 
 
   $form->{title}    = $locale->text('Start Dunning Process');
   $form->{jsscript} = 1;
-  $::request->{layout}->focus('#customer');
   $form->header();
 
   print $form->parse_html_template("dunning/add");
 
   $form->{jsscript} = 1;
   $form->{title}    = $locale->text('Dunnings');
-  $::request->{layout}->focus('#customer');
 
   $form->header();
 
 
 
   $form->{defaults} = AM->get_defaults();
 
-  $::request->{layout}->focus("#partnumber");
-
   $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'IC', 'trans_id' => $form->{id});
 
   CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1)
 
   my $attachment_filename = $form->generate_attachment_filename();
   my $subject             = $form->{subject} || $form->generate_email_subject();
 
-  $::request->{layout}->focus($form->{"email"} ? "#subject" : "#email");
   $form->header;
 
   my (@dont_hide_key_list, %dont_hide_key, @hidden_keys);
 
   $TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
   $TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
 
-  $::request->{layout}->focus('#vendor');
-
   my $follow_up_vc         =  $form->{vendor};
   $follow_up_vc            =~ s/--\d*\s*$//;
   $TMPL_VAR{vendor_name} = $follow_up_vc;
 
   $TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
   $TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
 
-  $::request->{layout}->focus('#customer');
-
   my $follow_up_vc         =  $form->{customer};
   $follow_up_vc            =~ s/--\d*\s*$//;
   $TMPL_VAR{customer_name} = $follow_up_vc;
 
    <table border="0">
     <tr>
      <td align="right">[% 'Description' | $T8 %]</td>
-     <td><input id="description" name="description" value="[% HTML.escape(description) %]"></td>
+     <td><input id="description" name="description" value="[% HTML.escape(description) %]" class="initial_focus"></td>
     </tr>
 
     <tr>
    [% IF id %][% IF orphaned %]<input type="submit" name="action" value="[% 'Delete' | $T8 %]">[% END %][% END %]
   </p>
  </form>
-
 
    </p>
 
    [% IF CAN_EDIT %]
-    <p><textarea name="content" id="edit_content" cols="100" rows="25">[% HTML.escape(content) %]</textarea></p>
+    <p><textarea name="content" id="edit_content" cols="100" rows="25"[% IF edit %] class="initial_focus"[% END %]>[% HTML.escape(content) %]</textarea></p>
 
     <p>
      <input type="hidden" name="save_nextsub" value="save_template">
   [% END %] <!-- SHOW_CONTENT -->
 
  </form>
-
 
    <tr>
     <td align="right">[% 'Description' | $T8 %]</td>
     <td>
-     <input id='description' name="description" size="60" value="[% HTML.escape(description) %]">
+     <input id='description' name="description" size="60" value="[% HTML.escape(description) %]" class="initial_focus">
      <input type="hidden" name="orig_description" value="[% HTML.escape(description) %]">
     </td>
    </tr>
  [% END %]
 
  [% END %]
-
 
                  name          = 'vendor',
                  default       = oldvendor,
                  style         = 'width: 250px',
+                 class         = 'initial_focus',
                  DATA          = ALL_VC,
                  id_sub        = 'vc_keys',
                  label_key     = 'name',
 
                 <th align="right" nowrap>[% 'Customer' | $T8 %]</th>
                 <td colspan=3>
 [%- IF selectcustomer %]
-    <select id='customer' name="customer" onchange="document.getElementById('update_button').click();">[% selectcustomer %]</select>
+    <select id='customer' name="customer" onchange="document.getElementById('update_button').click();" class="initial_focus">[% selectcustomer %]</select>
 [%- ELSE %]
-    <input id='customer' name=customer value="[% customer | html %]" size=35>
+    <input id='customer' name=customer value="[% customer | html %]" size=35 class="initial_focus">
 [%- END %]
                 <input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('customer')"></td>
                 [% L.hidden_tag('selectcustomer', selectcustomer) %]
 
      <tr>
       <th align="right" nowrap>[% 'Greeting' | $T8 %]</th>
       <td>
-       <input id="greeting" name="greeting" size="30" value="[% HTML.escape(greeting) %]"> 
+       <input id="greeting" name="greeting" size="30" value="[% HTML.escape(greeting) %]" class="initial_focus"> 
        [%- INCLUDE generic/multibox.html
              name       = 'selected_company_greeting',
              DATA       = MB_COMPANY_GREETINGS,
 
 
    <tr>
     <th align="right" nowrap>[% IF IS_CUSTOMER %][% 'Customer Name' | $T8 %][%- ELSE %][% 'Vendor Name' | $T8 %][%- END %]</th>
-    <td><input id="name" name="name" size="35"></td>
+    <td><input id="name" name="name" size="35" class="initial_focus"></td>
    </tr>
 
    <tr>
 
   <input type="submit" class="submit" name="action" value="[% 'Continue' | $T8 %]">
  </form>
-
 
 
    <tr>
     <td align="right">[% 'Variable Name' | $T8 %]<sup><span class="small-text">(1)</span></sup></td>
-    <td>[%- L.input_tag("config.name", SELF.config.name) %]</td>
+    <td>[%- L.input_tag("config.name", SELF.config.name, class='initial_focus') %]</td>
    </tr>
 
    <tr>
 
     <th align="right">[% 'Customer' | $T8 %]</th>
     <td colspan="3">
      [% IF SHOW_CUSTOMER_SELECTION %]
-      <select name="customer">
+      <select name="customer" class="initial_focus">
        <option></option>
        [% FOREACH row = all_customer %]<option>[% HTML.escape(row.name) %]--[% HTML.escape(row.id) %]</option>[% END %]
       </select>
       [% ELSE %]
-      <input name="customer" size="35">
+      <input name="customer" size="35" class="initial_focus">
      [% END %]
     </td>
    </tr>
   <input class="submit" type="submit" name="action" value="[% 'Continue' | $T8 %]">
 
  </form>
-
-
 
        <th align="right">[% 'Customer' | $T8 %]</th>
        <td colspan="3">
         [% IF SHOW_CUSTOMER_DDBOX %]
-         <select id='customer' name="customer_id">
+         <select id='customer' name="customer_id" class="initial_focus">
           <option value=""></option>
           [% FOREACH row = ALL_CUSTOMERS %]<option value="[% HTML.escape(row.id) %]">[% HTML.escape(row.name) %]</option>
           [% END %]
          </select>
          [% ELSE %]
-         <input id='customer' name="customer" size="35">
+         <input id='customer' name="customer" size="35" class="initial_focus">
         [% END %]
        </td>
       </tr>
   <input class="submit" type="submit" name="action" value="[% 'Continue' | $T8 %]">
 
  </form>
-
 
 [%- USE T8 %]
-[%- USE HTML %]
+[%- USE HTML %][%- USE L -%]
 <form name="Form" method="post" action="[% script %]">
 
 <table width="100%">
         <tr>
           <th align="right" nowrap>[% 'To' | $T8 %]</th>
 
-          <td><input id="email" name="email" size="30" value="[% HTML.escape(email) %]"></td>
+          <td>[% L.input_tag('email', email, size=30, class=(email ? '' : 'initial_focus')) %]</td>
         </tr>
         <tr>
           <th align="right" nowrap>[% 'Cc' | $T8 %]</th>
         <tr>
           <th align="right" nowrap>[% 'Subject' | $T8 %]</th>
 
-          <td><input id="subject" name="subject" size="30" value="[% HTML.escape(subject) %]"></td>
+          <td>[% L.input_tag('subject', subject, size=30, class=(email ? 'initial_focus' : '')) %]</td>
         </tr>
         <tr>
           <th align="right" nowrap>[% 'Attachment name' | $T8 %]</th>
 <br>
 <input name="action" class="submit" type="submit" value="[% 'Continue' | $T8 %]">
 </form>
-
 
             <table>
              <tr>
               <th align="right">[% 'Part Number' | $T8 %]</th>
-              <td><input id='partnumber' name="partnumber" value="[% HTML.escape(partnumber) %]" size="40"></td>
+              <td><input id='partnumber' name="partnumber" value="[% HTML.escape(partnumber) %]" size="40" class="initial_focus"></td>
              </tr>
              <tr>
               <th align="right">[% 'Part Description' | $T8 %]</th>
 
                  id            = 'vendor',
                  name          = 'vendor',
                  style         = 'width: 250px',
+                 class         = 'initial_focus',
                  DATA          = ALL_VENDORS,
                  id_sub        = 'vc_keys',
                  label_key     = 'name',
 
                  id            = 'customer',
                  name          = 'customer',
                  style         = 'width: 250px',
+                 class         = 'initial_focus',
                  DATA          = ALL_CUSTOMERS,
                  id_sub        = 'vc_keys',
                  label_key     = 'name',
 
           <table>
            <tr>
             <th align="right">[% 'Login Name' | $T8 %]</th>
-            <td>[% L.input_tag('{AUTH}login', '', id='auth_login', style=style) %]</td>
+            <td>[% L.input_tag('{AUTH}login', '', id='auth_login', style=style, class='initial_focus') %]</td>
            </tr>
            <tr>
             <th align="right">[% 'Password' | $T8 %]</th>
 
     <table>
      <tr>
       <th align="right">[% 'Number' | $T8 %]</th>
-      <td>[% L.input_tag("project.projectnumber", SELF.project.projectnumber, size=60) %]</td>
+      <td>[% L.input_tag("project.projectnumber", SELF.project.projectnumber, size=60, class='initial_focus') %]</td>
      </tr>
 
      <tr>