--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ dependent.js	Wed Aug 19 04:10:35 2009 -0700
@@ -0,0 +1,182 @@
+// $Id: dependent.js,v 1.3 2009/05/05 17:30:21 merlinofchaos Exp $
+/**
+ * @file
+ *
+ * Written by dmitrig01 (Dmitri Gaskin) for CTools; this provides dependent
+ * visibility for form items in CTools' ajax forms.
+ *
+ * To your $form item definition add:
+ * - '#process' => array('themesettings_process_dependency'),
+ * - Add '#dependency' => array('id-of-form-item' => array(list, of, values, that,
+     make, this, item, show),
+ *
+ * Special considerations:
+ * - radios are harder. Because Drupal doesn't give radio groups individual ids,
+ *   use 'radio:name-of-radio'
+ *
+ * - Checkboxes don't have their own id, so you need to add one in a div
+ *   around the checkboxes via #prefix and #suffix. You actually need to add TWO
+ *   divs because it's the parent that gets hidden. Also be sure to retain the
+ *   'expand_checkboxes' in the #process array, because the themesettings _process will
+ *   override it.
+ */
+
+Drupal.Themesettings = Drupal.Themesettings || {};
+Drupal.Themesettings.dependent = {};
+
+Drupal.Themesettings.dependent.bindings = {};
+Drupal.Themesettings.dependent.activeBindings = {};
+Drupal.Themesettings.dependent.activeTriggers = [];
+
+Drupal.Themesettings.dependent.inArray = function(array, search_term) {
+  var i = array.length;
+  if (i > 0) {
+	 do {
+		if (array[i] == search_term) {
+		   return true;
+		}
+	 } while (i--);
+  }
+  return false;
+}
+
+
+Drupal.Themesettings.dependent.autoAttach = function() {
+  // Clear active bindings and triggers.
+  for (i in Drupal.Themesettings.dependent.activeTriggers) {
+    jQuery(Drupal.Themesettings.dependent.activeTriggers[i]).unbind('change');
+  }
+  Drupal.Themesettings.dependent.activeTriggers = [];
+  Drupal.Themesettings.dependent.activeBindings = {};
+  Drupal.Themesettings.dependent.bindings = {};
+
+  if (!Drupal.settings.Themesettings) {
+    return;
+  }
+
+  // Iterate through all relationships
+  for (id in Drupal.settings.Themesettings.dependent) {
+
+    // Drupal.Themesettings.dependent.activeBindings[id] is a boolean,
+    // whether the binding is active or not.  Defaults to no.
+    Drupal.Themesettings.dependent.activeBindings[id] = 0;
+    // Iterate through all possible values
+    for(bind_id in Drupal.settings.Themesettings.dependent[id].values) {
+      // This creates a backward relationship.  The bind_id is the ID
+      // of the element which needs to change in order for the id to hide or become shown.
+      // The id is the ID of the item which will be conditionally hidden or shown.
+      // Here we're setting the bindings for the bind
+      // id to be an empty array if it doesn't already have bindings to it
+      if (!Drupal.Themesettings.dependent.bindings[bind_id]) {
+        Drupal.Themesettings.dependent.bindings[bind_id] = [];
+      }
+      // Add this ID
+      Drupal.Themesettings.dependent.bindings[bind_id].push(id);
+      // Big long if statement.
+      // Drupal.settings.Themesettings.dependent[id].values[bind_id] holds the possible values
+
+      if (bind_id.substring(0, 6) == 'radio:') {
+        var trigger_id = "input[name='" + bind_id.substring(6) + "']";
+      }
+      else {
+        var trigger_id = '#' + bind_id;
+      }
+
+      Drupal.Themesettings.dependent.activeTriggers.push(trigger_id);
+
+
+      var getValue = function(item, trigger) {
+        if (item.substring(0, 6) == 'radio:') {
+          var val = jQuery(trigger + ':checked').val();
+        }
+        else {
+          switch (jQuery(trigger).attr('type')) {
+            case 'checkbox':
+              var val = jQuery(trigger).attr('checked') || 0;
+              break;
+            default:
+              var val = jQuery(trigger).val();
+          }
+        }
+        return val;
+      }
+
+      var setChangeTrigger = function(trigger_id, bind_id) {
+        // Triggered when change() is clicked.
+        var changeTrigger = function() {
+          var val = getValue(bind_id, trigger_id);
+
+          for (i in Drupal.Themesettings.dependent.bindings[bind_id]) {
+            var id = Drupal.Themesettings.dependent.bindings[bind_id][i];
+
+            // Fix numerous errors
+            if (typeof id != 'string') {
+              continue;
+            }
+
+            // This bit had to be rewritten a bit because two properties on the
+            // same set caused the counter to go up and up and up.
+            if (!Drupal.Themesettings.dependent.activeBindings[id]) {
+              Drupal.Themesettings.dependent.activeBindings[id] = {};
+            }
+
+            if (Drupal.Themesettings.dependent.inArray(Drupal.settings.Themesettings.dependent[id].values[bind_id], val)) {
+              Drupal.Themesettings.dependent.activeBindings[id][bind_id] = 'bind';
+            }
+            else {
+              delete Drupal.Themesettings.dependent.activeBindings[id][bind_id];
+            }
+
+            var len = 0;
+            for (i in Drupal.Themesettings.dependent.activeBindings[id]) {
+              len++;
+            }
+
+            var object = jQuery('#' + id + '-wrapper');
+            if (!object.size()) {
+              object = jQuery('#' + id).parent();
+            }
+
+            if (Drupal.settings.Themesettings.dependent[id].num <= len) {
+              // Show if the element if criteria is matched
+              object.show(0);
+            }
+            else {
+              // Otherwise hide
+              object.hide(0);
+            }
+          }
+        }
+
+        jQuery(trigger_id).change(function() {
+          // Trigger the internal change function
+          // the attr('id') is used because closures are more confusing
+          changeTrigger(trigger_id, bind_id);
+        });
+        // Trigger initial reaction
+        changeTrigger(trigger_id, bind_id);
+      }
+      setChangeTrigger(trigger_id, bind_id);
+    }
+  }
+}
+
+Drupal.behaviors.ThemesettingsDependent = function (context) {
+  Drupal.Themesettings.dependent.autoAttach();
+
+  // Really large sets of fields are too slow with the above method, so this
+  // is a sort of hacked one that's faster but much less flexible.
+  $("select.Themesettings-master-dependent:not(.Themesettings-processed)")
+    .addClass('Themesettings-processed')
+    .change(function() {
+      var val = $(this).val();
+      if (val == 'all') {
+        $('.Themesettings-dependent-all').show(0);
+      }
+      else {
+        $('.Themesettings-dependent-all').hide(0);
+        $('.Themesettings-dependent-' + val).show(0);
+      }
+    })
+    .trigger('change');
+}
--- themesettings.module	Tue Aug 18 17:50:14 2009 -0700
+++ themesettings.module	Wed Aug 19 04:10:35 2009 -0700
@@ -50,7 +50,7 @@ function themesettings_nodeapi(&$node, $
       global $theme_key;
       $settings = _themesettings_get_settings($theme_key);
       // Determine the node type
-      $readmore_node_type = isset($settings["ts_{$node->type}_readmore"]) ? $node->type : 'default';
+      $readmore_node_type = $settings["ts_{$node->type}_readmore_enabled"] ? $node->type : 'default';
       // Create the link
       if (isset($rss_teaser) or $teaser and $node->readmore and $settings["ts_{$readmore_node_type}_readmore_placement"] != 'links') {
         $link = _themesettings_link(
@@ -70,7 +70,7 @@ function themesettings_nodeapi(&$node, $
 
       // Optionally prepend or append the comments links
       if (module_exists('comment')){
-        $comment_node_type = isset($settings["ts_{$node->type}_comment_singular"]) ? $node->type : 'default';
+        $comment_node_type = $settings["ts_{$node->type}_comment_enabled"] ? $node->type : 'default';
         if ($op != 'rss item' and $teaser and $settings["ts_{$comment_node_type}_comment_teaser_placement"] != 'links') {
           $all = comment_num_all($node->nid);
           if ($all) {
@@ -165,8 +165,8 @@ function themesettings_link_alter(&$link
   $settings = _themesettings_get_settings($theme_key);
 
   // Determine the node type
-  $readmore_node_type = isset($settings["ts_{$node->type}_readmore"]) ? $node->type : 'default';
-  $comment_node_type  = isset($settings["ts_{$node->type}_comment_singular"]) ? $node->type : 'default';
+  $readmore_node_type = $settings["ts_{$node->type}_readmore_enabled"] ? $node->type : 'default';
+  $comment_node_type  = $settings["ts_{$node->type}_comment_enabled"] ? $node->type : 'default';
 
   if ($node->display_teaser and $node->readmore) {
     // If the Read more link will be added to the content, turn off the Readmore link
@@ -283,317 +283,534 @@ function themesettings_link_alter(&$link
  *   void
  */
 function themesettings_form_alter(&$form, $form_state, $form_id) {
+  if ($form_id == 'system_theme_settings' && $form['var']['#value'] == 'theme_settings') {
+    // Grab the default settings first
+    $defaults =& _themesettings_defaults();
+    // Grab the specific theme settings
+    $var = $form['var']['#value'];
+    $settings = _themesettings_get_settings($var);
 
-  switch ($form_id) {
-    case 'system_theme_settings':
-      // Grab the default settings first
-      $defaults =& _themesettings_defaults();
-      // Grab the specific theme settings
-      $var = $form['var']['#value'];
-      $settings = _themesettings_get_settings($var);
+    $form['buttons']['#weight'] = 1;
 
-      $form['buttons']['#weight'] = 1;
+    // Read more link settings
+    $form['readmore'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('“Read more” link settings'),
+      '#description' => t('Customize the text and placement of the “Read more” link.'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => FALSE,
+    );
 
-      // Read more link settings
-      $form['readmore'] = array(
+    // Comments link settings
+    $form['comment'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('“Comment” links settings'),
+      '#description' => t('Customize the text and placement of the “Comment” links.'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => FALSE,
+    );
+
+    // Default settings
+    $form['readmore']['default'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Default settings for any content type'),
+    );
+    $form['readmore']['default']["ts_default_readmore"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Link text'),
+      '#default_value' => $settings["ts_default_readmore"],
+      '#description'   => t('HTML is allowed.'),
+    );
+    $form['readmore']['default']["ts_default_readmore_title"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Title text (tool tip)'),
+      '#default_value' => $settings["ts_default_readmore_title"],
+      '#description'   => t('Displayed when hovering over link. Plain text only.'),
+    );
+    $form['readmore']['default']["ts_default_readmore_prefix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Prefix'),
+      '#default_value' => $settings["ts_default_readmore_prefix"],
+      '#description'   => t('Text or HTML placed before the link.'),
+    );
+    $form['readmore']['default']["ts_default_readmore_suffix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Suffix'),
+      '#default_value' => $settings["ts_default_readmore_suffix"],
+      '#description'   => t('Text or HTML placed after the link.'),
+    );
+    $form['readmore']['default']["ts_default_readmore_placement"] = array(
+      '#type'          => 'radios',
+      '#title'         => t('Link placement'),
+      '#default_value' => $settings["ts_default_readmore_placement"],
+      '#options'       => array(
+                            'links'  => t('Add to the links (default)'),
+                            'append' => t('Add a paragraph to the teaser'),
+                            'inline' => t('Add a sentence to the last paragraph of the teaser'),
+                          ),
+    );
+    $form['comment']['default'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('Default settings for any content type'),
+    );
+    $form['comment']['default']['teaser'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('Links when displaying teaser'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => FALSE,
+    );
+    $form['comment']['default']['teaser']['add'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('“Add new comment” link'),
+      '#description' => t('The link when there are no comments.'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['teaser']['add']["ts_default_comment_add"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Link text'),
+      '#default_value' => $settings["ts_default_comment_add"],
+      '#description'   => t('HTML is allowed.'),
+    );
+    $form['comment']['default']['teaser']['add']["ts_default_comment_add_title"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Title text (tool tip)'),
+      '#default_value' => $settings["ts_default_comment_add_title"],
+      '#description'   => t('Displayed when hovering over link. Plain text only.'),
+    );
+    $form['comment']['default']['teaser']['add']['extra'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('Options'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['teaser']['add']['extra']["ts_default_comment_add_prefix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Prefix'),
+      '#default_value' => $settings["ts_default_comment_add_prefix"],
+      '#description'   => t('Text or HTML placed before the link.'),
+    );
+    $form['comment']['default']['teaser']['add']['extra']["ts_default_comment_add_suffix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Suffix'),
+      '#default_value' => $settings["ts_default_comment_add_suffix"],
+      '#description'   => t('Text or HTML placed after the link.'),
+    );
+    $form['comment']['default']['teaser']['add']['extra']["ts_default_comment_add_disable"] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Don’t show this link when “Read more” is present'),
+      '#default_value' => $settings["ts_default_comment_add_disable"],
+    );
+    $form['comment']['default']['teaser']['standard'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('“Comments” link'),
+      '#description' => t('The link when there are one or more comments.'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['teaser']['standard']["ts_default_comment_singular"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Link text when there is 1 comment'),
+      '#default_value' => $settings["ts_default_comment_singular"],
+      '#description'   => t('HTML is allowed.'),
+    );
+    $form['comment']['default']['teaser']['standard']["ts_default_comment_plural"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Link text when there are multiple comments'),
+      '#default_value' => $settings["ts_default_comment_plural"],
+      '#description'   => t('HTML is allowed. @count will be replaced with the number of comments.'),
+    );
+    $form['comment']['default']['teaser']['standard']["ts_default_comment_title"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Title text (tool tip)'),
+      '#default_value' => $settings["ts_default_comment_title"],
+      '#description'   => t('Displayed when hovering over link. Plain text only.'),
+    );
+    $form['comment']['default']['teaser']['standard']['extra'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('Options'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['teaser']['standard']['extra']["ts_default_comment_prefix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Prefix'),
+      '#default_value' => $settings["ts_default_comment_prefix"],
+      '#description'   => t('Text or HTML placed before the link.'),
+    );
+    $form['comment']['default']['teaser']['standard']['extra']["ts_default_comment_suffix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Suffix'),
+      '#default_value' => $settings["ts_default_comment_suffix"],
+      '#description'   => t('Text or HTML placed after the link.'),
+    );
+    $form['comment']['default']['teaser']['new'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('“New comments” link'),
+      '#description' => t('The link when there are one or more new comments.'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['teaser']['new']["ts_default_comment_new_singular"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Link text when there is 1 new comment'),
+      '#default_value' => $settings["ts_default_comment_new_singular"],
+      '#description'   => t('HTML is allowed.'),
+    );
+    $form['comment']['default']['teaser']['new']["ts_default_comment_new_plural"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Link text when there are multiple new comments'),
+      '#default_value' => $settings["ts_default_comment_new_plural"],
+      '#description'   => t('HTML is allowed. @count will be replaced with the number of comments.'),
+    );
+    $form['comment']['default']['teaser']['new']["ts_default_comment_new_title"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Title text (tool tip)'),
+      '#default_value' => $settings["ts_default_comment_new_title"],
+      '#description'   => t('Displayed when hovering over link. Plain text only.'),
+    );
+    $form['comment']['default']['teaser']['new']['extra'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('Options'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['teaser']['new']['extra']["ts_default_comment_new_prefix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Prefix'),
+      '#default_value' => $settings["ts_default_comment_new_prefix"],
+      '#description'   => t('Text or HTML placed before the link.'),
+    );
+    $form['comment']['default']['teaser']['new']['extra']["ts_default_comment_new_suffix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Suffix'),
+      '#default_value' => $settings["ts_default_comment_new_suffix"],
+      '#description'   => t('Text or HTML placed after the link.'),
+    );
+    $form['comment']['default']['teaser']["ts_default_comment_teaser_placement"] = array(
+      '#type'          => 'radios',
+      '#title'         => t('Link placement'),
+      '#default_value' => $settings["ts_default_comment_teaser_placement"],
+      '#options'       => array(
+                            'links'   => t('Add to the links (default)'),
+                            'prepend' => t('Prepend to “Read more” link'),
+                            'append'  => t('Append to “Read more” link'),
+                          ),
+    );
+    $form['comment']['default']['node'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('Links when displaying full content'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => FALSE,
+    );
+    $form['comment']['default']['node']['add'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('“Add new comment” link'),
+      '#description' => t('The link when the full content is being displayed.'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['node']['add']["ts_default_comment_node"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Link text'),
+      '#default_value' => $settings["ts_default_comment_node"],
+      '#description'   => t('HTML is allowed.'),
+    );
+    $form['comment']['default']['node']['add']["ts_default_comment_node_title"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Title text (tool tip)'),
+      '#default_value' => $settings["ts_default_comment_node_title"],
+      '#description'   => t('Displayed when hovering over link. Plain text only.'),
+    );
+    $form['comment']['default']['node']['add']['extra'] = array(
+      '#type'        => 'fieldset',
+      '#title'       => t('Options'),
+      '#collapsible' => TRUE,
+      '#collapsed'   => TRUE,
+    );
+    $form['comment']['default']['node']['add']['extra']["ts_default_comment_node_prefix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Prefix'),
+      '#default_value' => $settings["ts_default_comment_node_prefix"],
+      '#description'   => t('Text or HTML placed before the link.'),
+    );
+    $form['comment']['default']['node']['add']['extra']["ts_default_comment_node_suffix"] = array(
+      '#type'          => 'textfield',
+      '#title'         => t('Suffix'),
+      '#default_value' => $settings["ts_default_comment_node_suffix"],
+      '#description'   => t('Text or HTML placed after the link.'),
+    );
+
+
+    // Get node-specific settings
+    foreach (node_get_types('names') AS $type => $name) {
+      // Setup a safe type name to use for CSS classes/ids
+      $safe_type = str_replace('_', '-', $type);
+      // Read more
+      $form['readmore']["ts_{$type}_readmore_enabled"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Enable custom “Read more” link settings for @name', array('@name' => $name)),
+        '#default_value' => $settings["ts_{$type}_readmore_enabled"],
+      );
+      $form['readmore']["{$type}_div_prefix"] = array(
+        '#type' => 'hidden',
+        '#id' => "{$safe_type}-readmore-options",
+        '#prefix' => "<div><div id=\"{$safe_type}-readmore-options\">",
+        '#process' => array('themesettings_dependent_process'),
+        '#dependency' => array("edit-ts-{$safe_type}-readmore-enabled" => array(1)),
+      );
+      $form['readmore'][$type] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Custom settings for %name', array('%name' => $name)),
+      );
+      $form['readmore'][$type]["ts_{$type}_readmore"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Link text'),
+        '#default_value' => $settings["ts_{$type}_readmore"],
+        '#description'   => t('HTML is allowed.'),
+      );
+      $form['readmore'][$type]["ts_{$type}_readmore_title"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Title text (tool tip)'),
+        '#default_value' => $settings["ts_{$type}_readmore_title"],
+        '#description'   => t('Displayed when hovering over link. Plain text only.'),
+      );
+      $form['readmore'][$type]["ts_{$type}_readmore_prefix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Prefix'),
+        '#default_value' => $settings["ts_{$type}_readmore_prefix"],
+        '#description'   => t('Text or HTML placed before the link.'),
+      );
+      $form['readmore'][$type]["ts_{$type}_readmore_suffix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Suffix'),
+        '#default_value' => $settings["ts_{$type}_readmore_suffix"],
+        '#description'   => t('Text or HTML placed after the link.'),
+      );
+      $form['readmore'][$type]["ts_{$type}_readmore_placement"] = array(
+        '#type'          => 'radios',
+        '#title'         => t('Link placement'),
+        '#default_value' => $settings["ts_{$type}_readmore_placement"],
+        '#options'       => array(
+                              'links'  => t('Add to the links (default)'),
+                              'append' => t('Add a paragraph to the teaser'),
+                              'inline' => t('Add a sentence to the last paragraph of the teaser'),
+                            ),
+      );
+      $form['readmore']["{$type}_div_suffix"] = array(
+        '#value' => '</div></div>',
+      );
+
+      // Comments
+      $form['comment']["ts_{$type}_comment_enabled"] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Enable custom “Comment” link settings for @name', array('@name' => $name)),
+        '#default_value' => $settings["ts_{$type}_comment_enabled"],
+      );
+      $form['comment']["{$type}_div_prefix"] = array(
+        '#type' => 'hidden',
+        '#id' => "{$safe_type}-comment-options",
+        '#prefix' => "<div><div id=\"{$safe_type}-comment-options\">",
+        '#process' => array('themesettings_dependent_process'),
+        '#dependency' => array("edit-ts-{$safe_type}-comment-enabled" => array(1)),
+      );
+      $form['comment'][$type] = array(
         '#type'        => 'fieldset',
-        '#title'       => t('“Read more” link settings'),
-        '#description' => t('Customize the text and placement of the “Read more” link.'),
+        '#title'       => t('Custom settings for %name', array('%name' => $name)),
+      );
+      $form['comment'][$type]['teaser'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('Links when displaying teaser'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => FALSE,
+      );
+      $form['comment'][$type]['teaser']['add'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('“Add new comment” link'),
+        '#description' => t('The link when there are no comments.'),
         '#collapsible' => TRUE,
         '#collapsed'   => TRUE,
       );
-
-      // Comments link settings
-      $form['comment'] = array(
+      $form['comment'][$type]['teaser']['add']["ts_{$type}_comment_add"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Link text'),
+        '#default_value' => $settings["ts_{$type}_comment_add"],
+        '#description'   => t('HTML is allowed.'),
+      );
+      $form['comment'][$type]['teaser']['add']["ts_{$type}_comment_add_title"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Title text (tool tip)'),
+        '#default_value' => $settings["ts_{$type}_comment_add_title"],
+        '#description'   => t('Displayed when hovering over link. Plain text only.'),
+      );
+      $form['comment'][$type]['teaser']['add']['extra'] = array(
         '#type'        => 'fieldset',
-        '#title'       => t('“Comment” links settings'),
-        '#description' => t('Customize the text and placement of the “Comment” links.'),
+        '#title'       => t('Options'),
         '#collapsible' => TRUE,
         '#collapsed'   => TRUE,
       );
+      $form['comment'][$type]['teaser']['add']['extra']["ts_{$type}_comment_add_prefix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Prefix'),
+        '#default_value' => $settings["ts_{$type}_comment_add_prefix"],
+        '#description'   => t('Text or HTML placed before the link.'),
+      );
+      $form['comment'][$type]['teaser']['add']['extra']["ts_{$type}_comment_add_suffix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Suffix'),
+        '#default_value' => $settings["ts_{$type}_comment_add_suffix"],
+        '#description'   => t('Text or HTML placed after the link.'),
+      );
+      $form['comment'][$type]['teaser']['add']['extra']["ts_{$type}_comment_add_disable"] = array(
+        '#type'          => 'checkbox',
+        '#title'         => t('Don’t show this link when “Read more” is present'),
+        '#default_value' => $settings["ts_{$type}_comment_add_disable"],
+      );
+      $form['comment'][$type]['teaser']['standard'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('“Comments” link'),
+        '#description' => t('The link when there are one or more comments.'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => TRUE,
+      );
+      $form['comment'][$type]['teaser']['standard']["ts_{$type}_comment_singular"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Link text when there is 1 comment'),
+        '#default_value' => $settings["ts_{$type}_comment_singular"],
+        '#description'   => t('HTML is allowed.'),
+      );
+      $form['comment'][$type]['teaser']['standard']["ts_{$type}_comment_plural"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Link text when there are multiple comments'),
+        '#default_value' => $settings["ts_{$type}_comment_plural"],
+        '#description'   => t('HTML is allowed. @count will be replaced with the number of comments.'),
+      );
+      $form['comment'][$type]['teaser']['standard']["ts_{$type}_comment_title"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Title text (tool tip)'),
+        '#default_value' => $settings["ts_{$type}_comment_title"],
+        '#description'   => t('Displayed when hovering over link. Plain text only.'),
+      );
+      $form['comment'][$type]['teaser']['standard']['extra'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('Options'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => TRUE,
+      );
+      $form['comment'][$type]['teaser']['standard']['extra']["ts_{$type}_comment_prefix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Prefix'),
+        '#default_value' => $settings["ts_{$type}_comment_prefix"],
+        '#description'   => t('Text or HTML placed before the link.'),
+      );
+      $form['comment'][$type]['teaser']['standard']['extra']["ts_{$type}_comment_suffix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Suffix'),
+        '#default_value' => $settings["ts_{$type}_comment_suffix"],
+        '#description'   => t('Text or HTML placed after the link.'),
+      );
+      $form['comment'][$type]['teaser']['new'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('“New comments” link'),
+        '#description' => t('The link when there are one or more new comments.'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => TRUE,
+      );
+      $form['comment'][$type]['teaser']['new']["ts_{$type}_comment_new_singular"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Link text when there is 1 new comment'),
+        '#default_value' => $settings["ts_{$type}_comment_new_singular"],
+        '#description'   => t('HTML is allowed.'),
+      );
+      $form['comment'][$type]['teaser']['new']["ts_{$type}_comment_new_plural"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Link text when there are multiple new comments'),
+        '#default_value' => $settings["ts_{$type}_comment_new_plural"],
+        '#description'   => t('HTML is allowed. @count will be replaced with the number of comments.'),
+      );
+      $form['comment'][$type]['teaser']['new']["ts_{$type}_comment_new_title"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Title text (tool tip)'),
+        '#default_value' => $settings["ts_{$type}_comment_new_title"],
+        '#description'   => t('Displayed when hovering over link. Plain text only.'),
+      );
+      $form['comment'][$type]['teaser']['new']['extra'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('Options'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => TRUE,
+      );
+      $form['comment'][$type]['teaser']['new']['extra']["ts_{$type}_comment_new_prefix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Prefix'),
+        '#default_value' => $settings["ts_{$type}_comment_new_prefix"],
+        '#description'   => t('Text or HTML placed before the link.'),
+      );
+      $form['comment'][$type]['teaser']['new']['extra']["ts_{$type}_comment_new_suffix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Suffix'),
+        '#default_value' => $settings["ts_{$type}_comment_new_suffix"],
+        '#description'   => t('Text or HTML placed after the link.'),
+      );
+      $form['comment'][$type]['teaser']["ts_{$type}_comment_teaser_placement"] = array(
+        '#type'          => 'radios',
+        '#title'         => t('Link placement'),
+        '#default_value' => $settings["ts_{$type}_comment_teaser_placement"],
+        '#options'       => array(
+                              'links'   => t('Add to the links (default)'),
+                              'prepend' => t('Prepend to “Read more” link'),
+                              'append'  => t('Append to “Read more” link'),
+                            ),
+      );
+      $form['comment'][$type]['node'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('Links when displaying full content'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => FALSE,
+      );
+      $form['comment'][$type]['node']['add'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('“Add new comment” link'),
+        '#description' => t('The link when the full content is being displayed.'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => TRUE,
+      );
+      $form['comment'][$type]['node']['add']["ts_{$type}_comment_node"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Link text'),
+        '#default_value' => $settings["ts_{$type}_comment_node"],
+        '#description'   => t('HTML is allowed.'),
+      );
+      $form['comment'][$type]['node']['add']["ts_{$type}_comment_node_title"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Title text (tool tip)'),
+        '#default_value' => $settings["ts_{$type}_comment_node_title"],
+        '#description'   => t('Displayed when hovering over link. Plain text only.'),
+      );
+      $form['comment'][$type]['node']['add']['extra'] = array(
+        '#type'        => 'fieldset',
+        '#title'       => t('Options'),
+        '#collapsible' => TRUE,
+        '#collapsed'   => TRUE,
+      );
+      $form['comment'][$type]['node']['add']['extra']["ts_{$type}_comment_node_prefix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Prefix'),
+        '#default_value' => $settings["ts_{$type}_comment_node_prefix"],
+        '#description'   => t('Text or HTML placed before the link.'),
+      );
+      $form['comment'][$type]['node']['add']['extra']["ts_{$type}_comment_node_suffix"] = array(
+        '#type'          => 'textfield',
+        '#title'         => t('Suffix'),
+        '#default_value' => $settings["ts_{$type}_comment_node_suffix"],
+        '#description'   => t('Text or HTML placed after the link.'),
+      );
+      $form['comment']["{$type}_div_suffix"] = array(
+        '#value' => '</div></div>',
+      );
 
-      // Get node-specific settings
-      foreach ((array('default' => 'Default') + node_get_types('names')) AS $type => $name) {
-        // Read more
-        $form['readmore'][$type] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('!name settings', array('!name' => t($name))),
-          '#collapsible' => TRUE,
-          '#collapsed'   => FALSE,
-        );
-        $form['readmore'][$type]["ts_{$type}_readmore"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Link text'),
-          '#default_value' => $settings["ts_{$type}_readmore"],
-          '#description'   => t('HTML is allowed.'),
-        );
-        $form['readmore'][$type]["ts_{$type}_readmore_title"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Title text (tool tip)'),
-          '#default_value' => $settings["ts_{$type}_readmore_title"],
-          '#description'   => t('Displayed when hovering over link. Plain text only.'),
-        );
-        $form['readmore'][$type]["ts_{$type}_readmore_prefix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Prefix'),
-          '#default_value' => $settings["ts_{$type}_readmore_prefix"],
-          '#description'   => t('Text or HTML placed before the link.'),
-        );
-        $form['readmore'][$type]["ts_{$type}_readmore_suffix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Suffix'),
-          '#default_value' => $settings["ts_{$type}_readmore_suffix"],
-          '#description'   => t('Text or HTML placed after the link.'),
-        );
-        $form['readmore'][$type]["ts_{$type}_readmore_placement"] = array(
-          '#type'          => 'radios',
-          '#title'         => t('Link placement'),
-          '#default_value' => $settings["ts_{$type}_readmore_placement"],
-          '#options'       => array(
-                                'links'  => t('Add to the links (default)'),
-                                'append' => t('Add a paragraph to the teaser'),
-                                'inline' => t('Add a sentence to the last paragraph of the teaser'),
-                              ),
-        );
-        // Comment
-        $form['comment'][$type] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('!name settings', array('!name' => t($name))),
-          '#collapsible' => TRUE,
-          '#collapsed'   => FALSE,
-        );
-        $form['comment'][$type]['teaser'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('Links when displaying teaser'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => FALSE,
-        );
-        $form['comment'][$type]['teaser']['add'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('“Add new comment” link'),
-          '#description' => t('The link when there are no comments.'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['teaser']['add']["ts_{$type}_comment_add"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Link text'),
-          '#default_value' => $settings["ts_{$type}_comment_add"],
-          '#description'   => t('HTML is allowed.'),
-        );
-        $form['comment'][$type]['teaser']['add']["ts_{$type}_comment_add_title"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Title text (tool tip)'),
-          '#default_value' => $settings["ts_{$type}_comment_add_title"],
-          '#description'   => t('Displayed when hovering over link. Plain text only.'),
-        );
-        $form['comment'][$type]['teaser']['add']['extra'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('Options'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['teaser']['add']['extra']["ts_{$type}_comment_add_prefix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Prefix'),
-          '#default_value' => $settings["ts_{$type}_comment_add_prefix"],
-          '#description'   => t('Text or HTML placed before the link.'),
-        );
-        $form['comment'][$type]['teaser']['add']['extra']["ts_{$type}_comment_add_suffix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Suffix'),
-          '#default_value' => $settings["ts_{$type}_comment_add_suffix"],
-          '#description'   => t('Text or HTML placed after the link.'),
-        );
-        $form['comment'][$type]['teaser']['add']['extra']["ts_{$type}_comment_add_disable"] = array(
-          '#type'          => 'checkbox',
-          '#title'         => t('Don’t show this link when “Read more” is present'),
-          '#default_value' => $settings["ts_{$type}_comment_add_disable"],
-        );
-        $form['comment'][$type]['teaser']['standard'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('“Comments” link'),
-          '#description' => t('The link when there are one or more comments.'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['teaser']['standard']["ts_{$type}_comment_singular"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Link text when there is 1 comment'),
-          '#default_value' => $settings["ts_{$type}_comment_singular"],
-          '#description'   => t('HTML is allowed.'),
-        );
-        $form['comment'][$type]['teaser']['standard']["ts_{$type}_comment_plural"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Link text when there are multiple comments'),
-          '#default_value' => $settings["ts_{$type}_comment_plural"],
-          '#description'   => t('HTML is allowed. @count will be replaced with the number of comments.'),
-        );
-        $form['comment'][$type]['teaser']['standard']["ts_{$type}_comment_title"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Title text (tool tip)'),
-          '#default_value' => $settings["ts_{$type}_comment_title"],
-          '#description'   => t('Displayed when hovering over link. Plain text only.'),
-        );
-        $form['comment'][$type]['teaser']['standard']['extra'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('Options'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['teaser']['standard']['extra']["ts_{$type}_comment_prefix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Prefix'),
-          '#default_value' => $settings["ts_{$type}_comment_prefix"],
-          '#description'   => t('Text or HTML placed before the link.'),
-        );
-        $form['comment'][$type]['teaser']['standard']['extra']["ts_{$type}_comment_suffix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Suffix'),
-          '#default_value' => $settings["ts_{$type}_comment_suffix"],
-          '#description'   => t('Text or HTML placed after the link.'),
-        );
-        $form['comment'][$type]['teaser']['new'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('“New comments” link'),
-          '#description' => t('The link when there are one or more new comments.'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['teaser']['new']["ts_{$type}_comment_new_singular"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Link text when there is 1 new comment'),
-          '#default_value' => $settings["ts_{$type}_comment_new_singular"],
-          '#description'   => t('HTML is allowed.'),
-        );
-        $form['comment'][$type]['teaser']['new']["ts_{$type}_comment_new_plural"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Link text when there are multiple new comments'),
-          '#default_value' => $settings["ts_{$type}_comment_new_plural"],
-          '#description'   => t('HTML is allowed. @count will be replaced with the number of comments.'),
-        );
-        $form['comment'][$type]['teaser']['new']["ts_{$type}_comment_new_title"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Title text (tool tip)'),
-          '#default_value' => $settings["ts_{$type}_comment_new_title"],
-          '#description'   => t('Displayed when hovering over link. Plain text only.'),
-        );
-        $form['comment'][$type]['teaser']['new']['extra'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('Options'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['teaser']['new']['extra']["ts_{$type}_comment_new_prefix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Prefix'),
-          '#default_value' => $settings["ts_{$type}_comment_new_prefix"],
-          '#description'   => t('Text or HTML placed before the link.'),
-        );
-        $form['comment'][$type]['teaser']['new']['extra']["ts_{$type}_comment_new_suffix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Suffix'),
-          '#default_value' => $settings["ts_{$type}_comment_new_suffix"],
-          '#description'   => t('Text or HTML placed after the link.'),
-        );
-        $form['comment'][$type]['teaser']["ts_{$type}_comment_teaser_placement"] = array(
-          '#type'          => 'radios',
-          '#title'         => t('Link placement'),
-          '#default_value' => $settings["ts_{$type}_comment_teaser_placement"],
-          '#options'       => array(
-                                'links'   => t('Add to the links (default)'),
-                                'prepend' => t('Prepend to “Read more” link'),
-                                'append'  => t('Append to “Read more” link'),
-                              ),
-        );
-        $form['comment'][$type]['node'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('Links when displaying full content'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => FALSE,
-        );
-        $form['comment'][$type]['node']['add'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('“Add new comment” link'),
-          '#description' => t('The link when the full content is being displayed.'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['node']['add']["ts_{$type}_comment_node"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Link text'),
-          '#default_value' => $settings["ts_{$type}_comment_node"],
-          '#description'   => t('HTML is allowed.'),
-        );
-        $form['comment'][$type]['node']['add']["ts_{$type}_comment_node_title"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Title text (tool tip)'),
-          '#default_value' => $settings["ts_{$type}_comment_node_title"],
-          '#description'   => t('Displayed when hovering over link. Plain text only.'),
-        );
-        $form['comment'][$type]['node']['add']['extra'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('Options'),
-          '#collapsible' => TRUE,
-          '#collapsed'   => TRUE,
-        );
-        $form['comment'][$type]['node']['add']['extra']["ts_{$type}_comment_node_prefix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Prefix'),
-          '#default_value' => $settings["ts_{$type}_comment_node_prefix"],
-          '#description'   => t('Text or HTML placed before the link.'),
-        );
-        $form['comment'][$type]['node']['add']['extra']["ts_{$type}_comment_node_suffix"] = array(
-          '#type'          => 'textfield',
-          '#title'         => t('Suffix'),
-          '#default_value' => $settings["ts_{$type}_comment_node_suffix"],
-          '#description'   => t('Text or HTML placed after the link.'),
-        );
 
-        // Special options for default settings
-        if ($type == 'default') {
-          $form['readmore']['default']['#title'] = t('Default settings for any content type');
-          $form['readmore']['default']['#collapsed'] = $settings['ts_readmore_enable_content_type'] ? TRUE : FALSE;
-          $form['readmore']['ts_readmore_enable_content_type'] = array(
-            '#type'          => 'checkbox',
-            '#title'         => t('Enable separate settings for each content type'),
-            '#default_value' => $settings['ts_readmore_enable_content_type'],
-          );
-          /* $form['readmore']['ts_reamore_content_types'] = array(
-            '#value' => '<div id="themesettings-content-types">'
-          ); */
-          $form['comment']['default']['#title'] = t('Default settings for any content type');
-          $form['comment']['default']['#collapsed'] = $settings['ts_comment_enable_content_type'] ? TRUE : FALSE;
-          $form['comment']['ts_comment_enable_content_type'] = array(
-            '#type'          => 'checkbox',
-            '#title'         => t('Enable separate settings for each content type'),
-            '#default_value' => $settings['ts_comment_enable_content_type'],
-          );
-        }
-        // Collapse if default settings are used
-        else {
-          if (!$settings['ts_readmore_enable_content_type'] or // remove the or clause if we add jquery hiding
-              $settings["ts_{$type}_readmore"]           == $defaults["ts_default_readmore"] and
-              $settings["ts_{$type}_readmore_title"]     == $defaults["ts_default_readmore_title"] and
-              $settings["ts_{$type}_readmore_prefix"]    == $defaults["ts_default_readmore_prefix"] and
-              $settings["ts_{$type}_readmore_suffix"]    == $defaults["ts_default_readmore_suffix"] and
-              $settings["ts_{$type}_readmore_placement"] == $defaults['ts_default_readmore_placement']
-             )
-          {
-            $form['readmore'][$type]['#collapsed'] = TRUE;
-          }
-          if (!$settings['ts_comment_enable_content_type'])
-          {
-            $form['comment'][$type]['#collapsed'] = TRUE;
-          }
-        }
-      }
-      /* $form['readmore']['ts_reamore_content_types_end'] = array(
-        '#value' => '</div><!-- /#themesettings-content-types -->'
-      ); */
-
-
-      break;
+    }
   }
 }
 
@@ -626,13 +843,11 @@ function themesettings_node_type($op, $i
  */
 function &_themesettings_defaults_basic() {
   $defaults = array(
-    'ts_readmore_enable_content_type'     => 0,
     'ts_default_readmore'                 => t('Read more'),
     'ts_default_readmore_title'           => t('Read the rest of this posting.'),
     'ts_default_readmore_prefix'          => '',
     'ts_default_readmore_suffix'          => '',
     'ts_default_readmore_placement'       => 'links',
-    'ts_comment_enable_content_type'      => 0,
     'ts_default_comment_singular'         => t('1 comment'),
     'ts_default_comment_plural'           => t('@count comments'),
     'ts_default_comment_title'            => t('Jump to the first comment of this posting.'),
@@ -711,28 +926,12 @@ function &_themesettings_defaults() {
  * @return
  *   An array of settings.
  */
-function _themesettings_get_settings($var) {
-  static $theme_settings = FALSE;
-  global $theme_key;
-
-  // Return the current theme's settings if we already know them
-  if ($var == $theme_key and $theme_settings) {
-    return $theme_settings;
-  }
-
+function _themesettings_get_settings() {
   // Get the default-content-type settings
-  $settings =& _themesettings_defaults_basic();
+  $settings =& _themesettings_defaults();
 
   // Get the theme-specific settings
   $settings = array_merge($settings, variable_get('theme_settings', array()));
-  if ($var != 'theme_settings') {
-    $settings = array_merge($settings, variable_get(str_replace('/', '_', 'theme_'. $var .'_settings'), array()));
-  }
-
-  // Save the current theme's settings
-  if ($var == $theme_key) {
-    $theme_settings = $settings;
-  }
 
   return $settings;
 }
@@ -784,3 +983,25 @@ function _themesettings_link($prefix, $s
            )
          . $suffix;
 }
+
+/**
+ * Process callback to add dependency to form items.
+ */
+function themesettings_dependent_process($element, $edit, &$form_state, &$form) {
+  if (isset($element['#dependency'])) {
+    if (!isset($element['#dependency_count'])) {
+      $element['#dependency_count'] = 1;
+    }
+    if (!empty($form_state['ajax'])) {
+      $form_state['js settings']['Themesettings']['dependent'][$element['#id']] = array('num' => $element['#dependency_count'], 'values' => $element['#dependency']);
+    }
+    else {
+      $path = drupal_get_path('module', 'themesettings');
+      drupal_add_js($path .'/dependent.js', 'module', 'header');
+      $options['Themesettings']['dependent'][$element['#id']] = array('num' => $element['#dependency_count'], 'values' => $element['#dependency']);
+      drupal_add_js($options, 'setting');
+    }
+  }
+
+  return $element;
+}
