--- worldclock.module.orig	2008-12-05 09:42:00.000000000 -0800
+++ worldclock.module	2008-12-08 11:46:27.000000000 -0800
@@ -23,152 +23,73 @@ define("INDEX_ENTH",   8);
 define("INDEX_EDOW",   9);
 define("INDEX_ETIME", 10);
 
-  // Note: wc_location array
-  //
-  //    Name      Country or area name
-  //    GMT Diff    GMT time difference -12 to +12 (can be decimal numbers)
-  //    DST Y/N     0=No DST, 1=Has DST
-  //    DST Start   Describes when the DST starts
-  //        Mon   1 to 12 (0 is used for no DST countries)
-  //        Nth   1=1st, 2=2nd, 3=3rd, 9=Last
-  //        DOW   Day of the week (0=Sun, 1=Mon, 2=Tue... 6=Sat)
-  //        Time  0=0:00AM, 1=1:00AM, 2=2:00AM.....
-  //    DST End     Describes when the DST ends
-  //        Mon   1 to 12 (0 is used for no DST countries)
-  //        Nth   1=1st, 2=2nd, 3=3rd, 9=Last
-  //        DOW   Day of the week (0=Sun, 1=Mon, 2=Tue... 6=Sat)
-  //        Time  0=0:00AM, 1=1:00AM, 2=2:00AM.....
-  //
-  $GLOBALS['wc_location'] = array(
-    //     Name                 GMT  DST ----- Start ------  ------ End -------
-    //                          Diff Y/N  Mon Nth DOW Time    Mon Nth DOW Time
-    array( t('-Not Selected-'),   0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Afghanistan'),    4.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Argentina'),       -3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Australia ET'),    10,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
-    array( t('Australia CT'),   9.5,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
-    array( t('Australia WT'),     8,  1,  10,  9,  0,   2,     3,  9,  0,   3 ),
-    array( t('Austria'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Bangladesh'),       6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Belgium'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Bhutan'),           6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Bolivia'),         -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Brazil'),          -3,  1,  10,  3,  0,   0,     2,  3,  0,   0 ),
-    array( t('Bulgaria'),         2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Cambodia'),         7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Cameroon'),         1,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada AB'),       -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada BC'),       -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada MB'),       -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NB'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NF'),     -3.5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NT'),       -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NS'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NU(M)'),    -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NU(C)'),    -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada NU(E)'),    -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada ON(E)'),    -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada ON(W)'),    -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada PE'),       -4,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada QC'),       -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Canada QC(E)'),    -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada SK'),       -7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada SK(L)'),    -6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Canada YK'),       -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Chile'),           -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('China'),            8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Colombia'),        -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Costa Rica'),      -6,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Croatia'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Czech Republic'),   1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Denmark'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Ecuador'),         -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Egypt'),            2,  1,   4,  9,  5,   0,     9,  9,  4,   0 ),
-    array( t('Ethiopia'),         3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Fiji'),            12,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Finland'),          2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('France'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Germany'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Ghana'),            0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Greece'),           2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Hungary'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Iceland'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('India'),          5.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Iran'),           3.5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Israel'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Italy'),            1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Japan'),            9,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Jordan'),           2,  1,   3,  9,  4,   0,    10,  9,  5,   1 ),
-    array( t('Kenya'),            3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Korea'),            9,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Laos'),             7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Libya'),            2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Madagascar'),       3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Malaysia'),         8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Mauritius'),        4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Monaco'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Mongolia'),         8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Morocco'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Myanmar'),        6.3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Nepal'),         5.45,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Netherland'),       1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('New Caledonia'),   11,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('New Zealand'),     12,  1,   9,  9,  0,   2,     4,  1,  0,   3 ),
-    array( t('Nigeria'),          1,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Norway'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Oman'),             4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Pakistan'),         5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Panama'),          -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Peru'),            -5,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Philippines'),      8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Porland'),          1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Portugal'),         0,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Romania'),          2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Rwanda'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Russia Moscow'),    3,  1,   3,  9,  0,   2,    10,  9,  0,   3 ),
-    array( t('Saudi Arabia'),     3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Senegal'),          0,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Seychells'),        4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Singapore'),        8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('South Africa'),     2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Spain'),            1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Sudan'),            3,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Sweden'),           1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Switherland'),      1,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('Taiwan'),           8,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Thailand'),         7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Tonga'),           13,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Turkey'),           2,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('UK'),               0,  1,   3,  9,  0,   1,    10,  9,  0,   1 ),
-    array( t('USA Alaska'),      -9,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA Hawaii'),     -10,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('USA PT'),          -8,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA MT'),          -7,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA CT'),          -6,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('USA ET'),          -5,  1,   3,  2,  0,   2,    11,  1,  0,   2 ),
-    array( t('Venezuela'),       -4,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Vietnam'),          7,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-    array( t('Zambia'),           2,  0,   0,  0,  0,   0,     0,  0,  0,   0 ),
-  );
 
 /**
  * Construct an array for location pulldown menu
  */
 function _worldclock_get_location_options() {
-  // add this array to $GLOBALS so that other functions can access it
-  global $wc_location;
+  
+  $loc_list = db_query("SELECT wid, name FROM {wc_location}");
   $loc_array = array();
+  
+  while ($loc = db_fetch_object($loc_list)) {
+    $loc_array[$loc->wid] = $loc->name;
+  }
+  return $loc_array;
+}
 
-  $numitems = count($wc_location);
-  for ($i = 0 ; $i < $numitems ; $i++) {
-    $loc = $wc_location[$i];
-    $loc_name = $loc[INDEX_NAME];
-    $loc_array[] = $loc_name;
+/**
+ * Construct the full array of locations
+ */
+function worldclock_get_location_list($uid = NULL) {
+  
+  $loc_array = array();
+  $loc_list = db_query("SELECT * FROM {wc_location}");
+
+  while ($loc = db_fetch_object($loc_list)) {
+    $loc_array[$loc->wid] = array(
+      $loc->name,
+      $loc->gmt,
+      $loc->dst,
+      $loc->s_mon,
+      $loc->s_nth,
+      $loc->s_dow,
+      $loc->s_time,
+      $loc->e_mon,
+      $loc->e_nth,
+      $loc->e_dow,
+      $loc->e_time,
+    );
   }
   return $loc_array;
 }
 
 /**
+ * Construct a list of the location ids for a specific user
+ */
+function worldclock_get_user_locations($uid) {
+  $loc_array = array();
+  $loc_list = db_query("SELECT wid FROM {wc_user} WHERE uid = '%d'", $uid);
+  
+  while ($loc = db_fetch_object($loc_list)) {
+    $loc_array[] = $loc->wid;
+  }
+
+  return array_reverse($loc_array);
+}
+function worldclock_save_user_locations($post) {
+  global $user;
+
+  db_query("DELETE FROM {wc_user} WHERE uid = %d", $user->uid);
+
+  foreach ($post as $name => $value) {
+    if (strstr($name, 'worldclock_location_') && $value != '1') {
+      db_query("INSERT INTO {wc_user} VALUES (%d, %d)", $value, $user->uid);
+    }
+  }
+}
+
+/**
  * Construct location information text string
  */
 function _worldclock_get_location_info($loc) {
@@ -220,65 +141,161 @@ function worldclock_help($path, $arg) {
   return $output;
 }
 
+function worldclock_perm() {
+    return array('access administration pages', 'personalize worldclock');
+}
+
 /**
  * Implementation of hook_block
  */
 function worldclock_block($op='list', $delta=0) {
-  global $wc_location;
+  
   if ($op == 'list') {
     $block[0]['info'] = t('World Clock');
     return $block;
   }
   else if ($op == 'view') {
     $block['subject'] = t('World Clock');
-            
-    // get option
-    $maxnum    = variable_get('worldclock_maxnum', 4);
-    $footnote  = variable_get('worldclock_footnote', '');
-    $showzebra = variable_get('worldclock_showzebra', 0);
-    $showdst   = variable_get('worldclock_showdst', 0);
-    $dststr    = variable_get('worldclock_dststr', '*');
-    $timestr   = variable_get('worldclock_format', 'm/d h:i A');
-    if ($timestr == 'custom') {
-      $timestr = variable_get('worldclock_timestr', 'm/d h:i A');
+    $block['content'] = worldclock_contents();
+    //show a link to the worldclock page where users can personalize their list of locations
+    if (user_access('personalize worldclock')) {
+      $block['content'] .= l('Personalize the worldclock list', 'worldclock');
     }
+    return $block;
+  } // end of $op == 'view'
+}
+
+/**
+ * Returns page output
+ */
+function worldclock_page() {
+  
+  $output = worldclock_contents('page');
+  if (user_access('personalize worldclock')) {
+    $output .= drupal_get_form('worldclock_personalize_form');
+  }
+
+  return $output;
+}
+
+/**
+ * Block / Page contents 
+ */
+function worldclock_contents($format = 'block') {
+  global $user;
+  if ($format== 'page') {
+    $op = isset($_POST['op']) ? $_POST['op'] : ''; 
+    if ($op == t('Save') && $user->uid) {
+      // If the user pressed the Save button, and is logged in, save their preferences
+      worldclock_save_user_locations($_POST);
+      drupal_set_message(t('Your Locations has been saved.'));
+    }
+  }
+
+  $wc_location = worldclock_get_location_list();
+
+  // get option
+  $maxnum    = variable_get('worldclock_maxnum', 4);
+  $footnote  = variable_get('worldclock_footnote', '');
+  $showzebra = variable_get('worldclock_showzebra', 0);
+  $showdst   = variable_get('worldclock_showdst', 0);
+  $dststr    = variable_get('worldclock_dststr', '*');
+  $timestr   = variable_get('worldclock_format', 'm/d h:i A');
+  if ($timestr == 'custom') {
+    $timestr = variable_get('worldclock_timestr', 'm/d h:i A');
+  }
     
-    // output block content
-    $output = theme('clocks_list', $wc_location, $maxnum, $showzebra, $timestr, $footnote);
-    
-    // output javascript
-    $output .= '<script language="javascript">';
-    $output .= 'var locations = new Array();';
-    $output .= 'var maxnum  = '. $maxnum .';';
-    $output .= 'var time_str = "'. $timestr .'";';
-    $output .= 'var show_dst = '. $showdst .';';
-    $output .= 'var dst_str  = "'. $dststr .'";';
+  // output content
+
+  $locations = worldclock_get_user_locations($user->uid);
+  $output = theme('clocks_list', $wc_location, $maxnum, $showzebra, $timestr, $footnote, $locations);
     
-    $days_short = array(t('Sun'), t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'));
-    $days_long  = array(t('Sunday'), t('Monday'), t('Tueday'), t('Wedday'), t('Thuday'), t('Friday'), t('Satday'));
-    $months_short = array(t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), t('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec'));
-    $months_long  = array(t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December'));
+  // output javascript
+  $output .= '<script type="text/javascript" language="javascript">';
+  $output .= 'var locations = new Array();';
+  $output .= 'var maxnum  = '. $maxnum .';';
+  $output .= 'var time_str = "'. $timestr .'";';
+  $output .= 'var show_dst = '. $showdst .';';
+  $output .= 'var dst_str  = "'. $dststr .'";';
+
+  $days_short = array(t('Sun'), t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'));
+  $days_long  = array(t('Sunday'), t('Monday'), t('Tueday'), t('Wedday'), t('Thuday'), t('Friday'), t('Satday'));
+  $months_short = array(t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), t('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec'));
+  $months_long  = array(t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December'));
     
-    $output .= 'var sdow = '. drupal_to_js($days_short) .';';
-    $output .= 'var ldow = '. drupal_to_js($days_long) .';';
-    $output .= 'var smon = '. drupal_to_js($months_short) .';';
-    $output .= 'var lmon = '. drupal_to_js($months_long) .';';
+  $output .= 'var sdow = '. drupal_to_js($days_short) .';';
+  $output .= 'var ldow = '. drupal_to_js($days_long) .';';
+  $output .= 'var smon = '. drupal_to_js($months_short) .';';
+  $output .= 'var lmon = '. drupal_to_js($months_long) .';';
 
-    for ($j = 1 ; $j <= $maxnum ; $j++) {
+  for ($j = 1 ; $j <= $maxnum ; $j++) {
+    if ($locations) {
+      $loc_no = $locations[$j-1];
+    } 
+    else {
       $loc_no = variable_get('worldclock_location_'. $j, 0);
-      // get the location record
-      if ($loc_no > 0) {
-        $output .= "locations[$j] = ". drupal_to_js(array_merge(array($loc_no), $wc_location[$loc_no])) .';';
-      }
     }
-    $output .= 'setTimeout("DisplayClock(maxnum, time_str, show_dst, dst_str, locations)", 100);';
-    $output .= '</script>';
+    // get the location record
+    if ($loc_no > 0) {
+      $output .= "locations[$j] = ". drupal_to_js(array_merge(array($loc_no), $wc_location[$loc_no])) .';';
+    }
+  }
 
-    $block['content'] = $output;
-    return $block;
-  } // end of $op == 'view'
+  $output .= 'setTimeout("DisplayClock(maxnum, time_str, show_dst, dst_str, locations)", 100);';
+  $output .= '</script>';
+
+  return $output;
+}
+
+function worldclock_personalize_form() {
+  global $user;
+  $wc_location = worldclock_get_location_list();
+  $locations   = worldclock_get_user_locations($user->uid);
+  $maxnum      = variable_get('worldclock_maxnum', 4);
+
+
+  $form['personal'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Personalize the worlclock list'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $form['personal']['location'] = worldclock_locaton_list_form($wc_location, $maxnum, $locations);
+  $form['personal']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+  return $form; 
+}
+
+function worldclock_locaton_list_form($wc_location, $maxnum, $locations = NULL) {
+  for ($j = 1 ; $j <= $maxnum ; $j++) {
+    // show some information
+    if ($locations) {
+      $loc_no = $locations[$j-1];
+    } 
+    else {
+      $loc_no = variable_get('worldclock_location_'. $j, 0);
+    }
+    $loc_info = '';
+    if ($loc_no) {
+      $loc = $wc_location[$loc_no];
+      $loc_info = _worldclock_get_location_info($loc);
+    }
+    // create a pull-down menu
+    $form['worldclock_location_'. $j] = array(
+      '#type' => 'select',
+      '#title' => t('Location ') . $j,
+      '#default_value' => $loc_no,
+      '#options' => _worldclock_get_location_options(),
+      '#description' => $loc_info,
+    );
+  }
+  return $form;
 }
 
+
 /**
  * Implementation of hook_theme
  */
@@ -286,16 +303,16 @@ function worldclock_block($op='list', $d
 function worldclock_theme() {
   return array(
     'clocks_list' => array(
-      'arguments' => array('wc_location' => NULL, 'maxnum' => NULL, 'showzebra' => NULL, 'timestr' => NULL, 'footnote' => NULL),
+      'arguments' => array('wc_location' => NULL, 'maxnum' => NULL, 'showzebra' => NULL, 'timestr' => NULL, 'footnote' => NULL, 'locations' => NULL)
     ),
   );
 }
 
 /**
- * Theming function for block
+ * Theming function for output
  */
 
-function theme_clocks_list($wc_location, $maxnum, $showzebra, $timestr, $footnote) {
+function theme_clocks_list($wc_location, $maxnum, $showzebra, $timestr, $footnote, $locations) {
   $output = '';
   // output table HTML
   $tr_class = '';
@@ -305,7 +322,12 @@ function theme_clocks_list($wc_location,
       if ($j % 2) $tr_class = 'odd';
       else $tr_class = 'even';
     }
-    $loc_no = variable_get('worldclock_location_'. $j, 0);
+    if ($locations) {
+      $loc_no = $locations[$j-1];
+    } 
+    else {
+      $loc_no = variable_get('worldclock_location_'. $j, 0);
+    }
     if ($loc_no > 0) {
       // get location name
       $loc = $wc_location[$loc_no];
@@ -328,7 +350,7 @@ function theme_clocks_list($wc_location,
  * Module settings (admin page)
  */
 function worldclock_admin() {
-  global $wc_location;
+  $wc_location = _worldclock_get_all_locations();
 
   $maxnum  = variable_get('worldclock_maxnum', 4);
   $format  = variable_get('worldclock_format', 'm/d h:i A');
@@ -336,7 +358,7 @@ function worldclock_admin() {
 
   $form['location'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Location settings'),
+    '#title' => t('Default Location settings'),
     '#collapsible' => FALSE,
     '#collapsed' => FALSE,
   );
@@ -355,23 +377,7 @@ function worldclock_admin() {
     '#value' => t('You may leave the location unselected if you do not need to display the time.'),
   );
 
-  for ($j = 1 ; $j <= $maxnum ; $j++) {
-    // show some information
-    $loc_no = variable_get('worldclock_location_'. $j, 0);
-    $loc_info = '';
-    if ($loc_no) {
-      $loc = $wc_location[$loc_no];
-      $loc_info = _worldclock_get_location_info($loc);
-    }
-    // create a pull-down menu
-    $form['location']['worldclock_location_'. $j] = array(
-      '#type' => 'select',
-      '#title' => t('Location ') . $j,
-      '#default_value' => variable_get('worldclock_location_'. $j, 0),
-      '#options' => _worldclock_get_location_options(),
-      '#description' => $loc_info,
-    );
-  }
+  $form['location']['location'] = worldclock_locaton_list_form($wc_location, $maxnum);
 
   $format_desc = t('Specify the custom time string format. You can use the following format characters.');
   $format_desc .= '<ul>';
@@ -524,6 +530,13 @@ function worldclock_menu() {
     'access arguments' => array('access administration pages'),
     'type' => MENU_NORMAL_ITEM,
   );
+
+  $items['worldclock'] = array(
+    'title' => 'World Clock',
+    'page callback' => 'worldclock_page',
+    'access arguments' => array('access content'),
+  );
+
   return $items;
 }
 
@@ -531,5 +544,5 @@ function worldclock_menu() {
  * Implementation of hook_init
  */
 function worldclock_init() {
-  drupal_add_js(drupal_get_path('module', 'worldclock') . '/worldclock.js');
+  drupal_add_js(drupal_get_path('module', 'worldclock') .'/worldclock.js');
 }
