--- autotimezone.module.orig	2006-05-09 15:35:15.000000000 -0700
+++ autotimezone.module	2006-05-09 16:01:08.000000000 -0700
@@ -29,19 +29,23 @@
   }
   else {
     if (!function_exists('throttle_status') || !throttle_status()) { 
-      $javascript = '<script type="text/javascript">';
-      $javascript .= "\nvar now = new Date();";
-      $javascript .= "\nvar offset = now.getTimezoneOffset();";
-      $javascript .= "\nvar path = \"" . url('autotimezone/') . '";';
-      $javascript .= "\n" . 'document.write(\'<link  rel="stylesheet" type="text/css" href="\' + path + offset + \'"/>\');';
-      $javascript .= "\n</script>\n";
       global $user;
       //If only_update_new is enabled then make sure the user->timezone matches default.
-      if (!variable_get('autotimezone_only_update_new', 0) or $user->timezone == variable_get('date_default_timezone', 0)) {
-        $max = 100 / variable_get('autotimezone_update_percent', 25);
-        if ($max == 1 or rand(1, $max) == 1) {
-          drupal_set_html_head($javascript);
+      if (!($user->uid == 0 and !(variable_get('autotimezone_session',0))) and (!variable_get('autotimezone_only_update_new', 0) or $user->timezone == variable_get('date_default_timezone', 0))) {
+        if ($user->uid == 0) {
+          if (!$_SESSION['timezone']) {
+            $_SESSION['timezone'] = variable_get('date_default_timezone',0);
+          }
+          $sessvar = $_SESSION['timezone'] / 60;
+        } else {
+          $sessvar = $user->timezone / 60;
         }
+        $javascript = '<script type="text/javascript">';
+        $javascript .= "\nvar now = new Date();";
+        $javascript .= "\nvar offset = now.getTimezoneOffset();";
+        $javascript .= "\n" . 'if (!(offset == ' . $sessvar . ')) {document.write(\'<link  rel="stylesheet" type="text/css" href="' .url('autotimezone/') . '\' + offset + \'"/>\')};';
+        $javascript .= "\n</script>\n";
+        drupal_set_html_head($javascript);
       }
     }
   }
@@ -72,12 +76,6 @@
     '#default_value' => variable_get('autotimezone_only_update_new', 0),
     '#options' => $options,
     '#description' => t('If Enabled, then a users timezone will only be updated if it matches the default timezone. This is useful for updating accounts only once after being created and then leaving them be. The default timezone for this site is currently set to <b>%timezone</b>.', array('%timezone' => variable_get('date_default_timezone', 0) / 3600)));
-  $form['performance']['autotimezone_update_percent'] = array(
-    '#type' => 'select',
-    '#title' => t('Percentage of page hits that should check users timezone'),
-    '#default_value' => variable_get('autotimezone_update_percent', 25),
-    '#options' => array(100 => '100%', 50 => '50%', 25 => '25%', 10 => '10%', 5 => '5%', 2 => '2%'),
-    '#description' => t('This only effects extra hits on the server, not page loading time. If set too low new user accounts will not get updated.'));
 
   $form['developers'] = array(
     '#type' => 'fieldset',
@@ -108,4 +106,4 @@
   else { //If the user is anonymous.
     $_SESSION['timezone'] = $offset;
   } 
-}
\ No newline at end of file
+}
