diff -upN old/jquery_ui.install new/jquery_ui.install
--- old/jquery_ui.install	2008-06-15 07:15:11.000000000 +0200
+++ new/jquery_ui.install	2008-07-06 09:46:46.000000000 +0200
@@ -7,6 +7,13 @@
  */
 
 /**
+ * Implementation of hook_install().
+ */
+function jquery_ui_install() {
+  // Make sure the module is the last one to be called.
+  db_query("UPDATE {system} SET weight = 8 WHERE name = 'jquery_ui'");
+}
+/**
  * Implementation of hook_requirements().
  */
 function jquery_ui_requirements($phase) {
@@ -37,8 +44,11 @@ function jquery_ui_requirements($phase) 
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implementation of hook_update_N().
  */
-function jquery_ui_uninstall() {
-  variable_del('jquery_ui_compression_type');
-}
+function jquery_ui_update_6100() {
+  // Make sure the module is the last one to be called.
+  db_query("UPDATE {system} SET weight = 8 WHERE name = 'jquery_ui'");
+  
+  return array();
+}
\ No newline at end of file
diff -upN old/jquery_ui.module new/jquery_ui.module
--- old/jquery_ui.module	2008-06-22 22:09:58.000000000 +0200
+++ new/jquery_ui.module	2008-07-06 08:41:37.000000000 +0200
@@ -13,8 +13,61 @@
 /**
  * Path to jQuery UI library.
  */
-define('JQUERY_UI_PATH', drupal_get_path('module', 'jquery_ui') . '/jquery.ui');
+ define('JQUERY_UI_PATH', drupal_get_path('module', 'jquery_ui') .'/jquery.ui');
  
+/*******************************************************************************
+ * Drupal hooks.
+ ******************************************************************************/
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function jquery_ui_form_system_theme_settings_alter(&$form, &$form_state) {
+  // Determine which Drupal theme's settings page we're looking at.
+  $key = $form['var']['#value'];
+  $key = ($key == 'theme_settings') ? '' : preg_replace('/(^theme_|_settings$)/', '', $key);
+  
+  $themes   = jquery_ui_get_themes();
+  $settings = jquery_ui_get_settings($key);
+  
+  $form['jquery_ui'] = array(
+    '#type'          => 'fieldset',
+    '#title'         => t('jQuery UI'),
+    '#collapsible'   => TRUE,
+    '#collapsed'     => TRUE,
+    '#weight'        => -25,
+    '#tree'          => TRUE,
+  );
+  $form['jquery_ui']['theme'] = array(
+    '#type'          => 'select',
+    '#title'         => t('jQuery UI theme'),
+    '#description'   => t('The theme used by jQuery UI for its widgets.'),
+    '#options'       => $themes,
+    '#default_value' => $settings['theme'],
+  );
+
+}
+
+/**
+ * Implementation of hook_init().
+ */
+function jquery_ui_init() {
+  global $theme_key;
+  
+  $jquery_ui_path = JQUERY_UI_PATH .'/ui';
+  $result         = jquery_ui_add();
+  if (is_array($result) && !empty($result)) {
+    // The JavaScript files have been added; add the CSS files too.
+    $settings = jquery_ui_get_settings($theme_key);
+    $theme    = $settings['theme'];
+    drupal_add_css(JQUERY_UI_PATH ."/themes/{$theme}/{$theme}.css");
+  }
+}
+
+/*******************************************************************************
+ * Public functions.
+ ******************************************************************************/
+
 /**
  * Add the specified jQuery UI library files to this page.
  *
@@ -25,50 +78,91 @@ define('JQUERY_UI_PATH', drupal_get_path
  *   An array of what additional files (other than UI core) should be loaded
  *   on the page, or a string with a single file name.
  */
-function jquery_ui_add($files = array()) {
+function jquery_ui_add($files = NULL) {
   static $loaded_files, $ui_core, $effects_core;
-  $jquery_ui_path = JQUERY_UI_PATH . '/ui';
-  $compression = variable_get('jquery_update_compression_type', 'mini');
-
-  // Convert file to an array if it's not one already, to compensate for
-  // lazy developers. ;)
-  if (!is_array($files)) {
-    $files = array($files);
-  }
-
-  // If core hasn't been added yet, add it.
-  if (!isset($ui_core)) {
-    $ui_core = TRUE;
-    jquery_ui_add(array('ui.core'));
+  
+  if ($files) {
+    $jquery_ui_path = JQUERY_UI_PATH .'/ui';
+    $compression    = variable_get('jquery_update_compression_type', 'mini');
+    
+    // Convert file to an array if it's not one already, to compensate for
+    // lazy developers. ;)
+    if (!is_array($files)) {
+      $files = array($files);
+    }
+    
+    // If core hasn't been added yet, add it.
+    if (!isset($ui_core)) {
+      $ui_core = TRUE;
+      jquery_ui_add(array('ui.core'));
+    }
+    
+    // Loop through list of files to include and add them to the page.
+    foreach ($files as $file) {
+      // Any effects files require the effects core file.
+      if (!isset($effects_core) && strpos($file, 'effects.') === 0) {
+        $effects_core = TRUE;
+        jquery_ui_add(array('effects.core'));
+      }
+      
+      // Load other files.
+      if (!isset($loaded_files[$file])) {
+        switch ($compression) {
+          case 'none':
+            $file_path = "$file.js";
+            break;
+          case 'pack':
+            $file_path = "packed/$file.packed.js";
+            break;
+          case 'mini':
+          default:
+            $file_path = "minified/$file.min.js";
+            break;
+        }
+        $js_path = "{$jquery_ui_path}/{$file_path}";
+        drupal_add_js($js_path);
+        $loaded_files[$file] = $js_path; // or TRUE...
+      }
+    }
   }
+  
+  return $loaded_files;
+}
 
-  // Loop through list of files to include and add them to the page.
-  foreach ($files as $file) {
-    // Any effects files require the effects core file.
-    if (!isset($effects_core) && strpos($file, 'effects.') === 0) {
-      $effects_core = TRUE;
-      jquery_ui_add(array('effects.core'));
-    }
+/**
+ * Retrieve the jQuery UI settings for the theme.
+ */
+function jquery_ui_get_settings($key) {
+  $default_settings = array(
+    'jquery_ui' => array(
+      'theme' => 'flora',
+    )
+  );
+  $settings = array_merge($default_settings, theme_get_settings($key));
   
-    // Load other files.
-    if (!isset($loaded_files[$file])) {
-      switch ($compression) {
-        case 'none':
-          $file_path = "$file.js";
-          break;
-        case 'pack':
-          $file_path = "packed/$file.packed.js";
-          break;
-        case 'mini':
-        default:
-          $file_path = "minified/$file.min.js";
-          break;
+  return $settings['jquery_ui'];
+}
+
+/**
+ * Retrieve list of themes that can be selected.
+ */
+function jquery_ui_get_themes() {
+  $themes_path = JQUERY_UI_PATH .'/themes';
+  $themes      = array();
+
+  // Find all files in the themes folder, without recursing. Loop through and
+  // check for directories with dirname.css files within them.
+  $files = file_scan_directory($themes_path, '.*', array('.', '..', 'CVS'), 0, FALSE, 'basename');
+  foreach ($files as $file => $info) {
+    if (is_dir($info->filename)) {
+      $css_path = "{$info->filename}/{$file}.css";
+      if (file_exists($css_path)) {
+        $themes[$file] = $file;
       }
-      $js_path = $jquery_ui_path . '/' . $file_path;
-      drupal_add_js($js_path);
-      $loaded_files[$file] = $js_path; // or TRUE...
     }
   }
+
+  return $themes;
 }
 
 /**
@@ -76,10 +170,11 @@ function jquery_ui_add($files = array())
  */
 function jquery_ui_get_version() {
   $version = 0;
-
-  if (file_exists(JQUERY_UI_PATH . '/version.txt')) {
-    $version = file_get_contents(JQUERY_UI_PATH . '/version.txt');
+  $file    = JQUERY_UI_PATH .'/version.txt';
+  
+  if (file_exists($file)) {
+    $version = file_get_contents($file);
   }
-
+  
   return $version;
 }
