--- common.inc	2007-07-26 15:16:45.000000000 -0400
+++ common.inc.weighted	2007-09-16 20:37:08.000000000 -0400
@@ -1419,7 +1419,7 @@ function drupal_add_link($attributes) {
  * @return
  *   An array of CSS files.
  */
-function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
+function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE, $weight = 0 ) {
   static $css = array();
 
   // Create an array of CSS files for each media type first, since each type needs to be served
@@ -1427,9 +1427,9 @@ function drupal_add_css($path = NULL, $t
   if (isset($path)) {
     // This check is necessary to ensure proper cascading of styles and is faster than an asort().
     if (!isset($css[$media])) {
-      $css[$media] = array('module' => array(), 'theme' => array());
+      $css[$media] = array('first' => array(), 'module' => array(), 'theme' => array(), 'last' => array());
     }
-    $css[$media][$type][$path] = $preprocess;
+    $css[$media][$type][$weight][$path] = $preprocess;
   }
 
   return $css;
@@ -1458,21 +1458,26 @@ function drupal_get_css($css = NULL) {
   foreach ($css as $media => $types) {
     // If CSS preprocessing is off, we still need to output the styles.
     // Additionally, go through any remaining styles if CSS preprocessing is on and output the non-cached ones.
-    foreach ($types as $type => $files) {
-      foreach ($types[$type] as $file => $preprocess) {
-        if (!$preprocess || !($is_writable && $preprocess_css)) {
-          // If a CSS file is not to be preprocessed and it's a module CSS file, it needs to *always* appear at the *top*,
-          // regardless of whether preprocessing is on or off.
-          if (!$preprocess && $type == 'module') {
-            $no_module_preprocess .= '<style type="text/css" media="'. $media .'">@import "'. base_path() . $file .'";</style>' ."\n";
-          }
-          // If a CSS file is not to be preprocessed and it's a theme CSS file, it needs to *always* appear at the *bottom*,
-          // regardless of whether preprocessing is on or off.
-          else if (!$preprocess && $type == 'theme') {
-            $no_theme_preprocess .= '<style type="text/css" media="'. $media .'">@import "'. base_path() . $file .'";</style>' ."\n";
-          }
-          else {
-            $output .= '<style type="text/css" media="'. $media .'">@import "'. base_path() . $file .'";</style>' ."\n";
+    foreach ($types as $type => $weights) {
+      foreach ($weights as $weight => $files ) {
+        foreach ($files as $file => $preprocess) {
+          if (!$preprocess || !($is_writable && $preprocess_css)) {
+            // If a CSS file is not to be preprocessed and it's a module CSS file, it needs to *always* appear at the *top*,
+            // regardless of whether preprocessing is on or off.
+            if (!$preprocess && $type == 'module') {
+              $no_module_preprocess .= '<style type="text/css" media="'. $media .'">@import "'. base_path() . $file .'";</style>' ."\n";
+            }
+            // If a CSS file is not to be preprocessed and it's a theme CSS file, it needs to *always* appear at the *bottom*,
+            // regardless of whether preprocessing is on or off.
+            else if (!$preprocess && $type == 'theme') {
+              $no_theme_preprocess .= '<style type="text/css" media="'. $media .'">@import "'. base_path() . $file .'";</style>' ."\n";
+            }
+            else if (!$preprocess && $type == 'theme') {
+              $no_last_preprocess .= '<style type="text/css" media="'. $media .'">@import "'. base_path() . $file .'";</style>' ."\n";
+            }
+            else {
+              $output .= '<style type="text/css" media="'. $media .'">@import "'. base_path() . $file .'";</style>' ."\n";
+            }
           }
         }
       }
@@ -1485,7 +1490,7 @@ function drupal_get_css($css = NULL) {
     }
   }
 
-  return $no_module_preprocess . $output . $no_theme_preprocess;
+  return $no_module_preprocess . $output . $no_theme_preprocess . $no_last_preprocess ;
 }
 
 /**
