--- jgrowl.install	2008-12-13 11:10:45.000000000 +1300
+++ jgrowl.install	2008-12-14 15:32:28.000000000 +1300
@@ -2,18 +2,18 @@
 // $Id: jgrowl.install,v 1.3 2008/12/12 22:10:45 stevemckenzie Exp $
 
 /**
- * 
+ *
  *  @file
  *  Module install file.
- * 
+ *
  */
 
 /**
- *  Implementation of hook_install().
+ * Implementation of hook_install().
  */
 function jgrowl_install() {
   // Always keep jgrowl last so we can grab all the messages.
-  $weight = db_result(db_query("SELECT weight FROM {system} ORDER BY weight DESC LIMIT 1"));
+  $weight = db_result(db_query_range("SELECT weight FROM {system} ORDER BY weight DESC", $count=1));
   db_query("UPDATE {system} SET weight = %d WHERE name = 'jgrowl'", $weight + 100);
 }
 
--- jgrowl.module	2008-12-14 13:47:52.000000000 +1300
+++ jgrowl.module	2008-12-14 15:28:23.000000000 +1300
@@ -2,15 +2,15 @@
 // $Id: jgrowl.module,v 1.7 2008/12/14 00:47:52 stevemckenzie Exp $
 
 /**
- * 
+ *
  *  @file
  *  jGrowl is a jQuery plugin that raises unobtrusive messages within the browser, similar to the way that OS X's Growl Framework works.
- * 
+ *
  *  - Override status messages to be displayed on jGrowl.
  *  - An API to use with Drupal
  *  - A settings page for easy configuration of all options available in jgrowl.
- *  - A hook_jgrowl_variable_alter(&$variables) to alter / add variables on the settings form and on runtime. 
- * 
+ *  - A hook_jgrowl_variable_alter(&$variables) to alter / add variables on the settings form and on runtime.
+ *
  */
 
 define('JGROWL_SYSTEM_MESSAGES', variable_get('jgrowl_system_messages', TRUE));
@@ -18,20 +18,20 @@ define('JGROWL_STICKY_ERRORS', variable_
 define('JGROWL_STICKY_STATUSES', variable_get('jgrowl_sticky_statuses', FALSE));
 
 /**
- *  Implementation of hook_perm().
+ * Implementation of hook_perm().
  */
 function jgrowl_perm() {
   return array('access jgrowl', 'administer jgrowl');
 }
 
 /**
- *  Implementation of hook_menu().
+ * Implementation of hook_menu().
  */
 function jgrowl_menu() {
   $items = array();
 
   $items['admin/settings/jgrowl'] = array(
-  'title' => t('jGrowl'),
+  'title' => 'jGrowl',
   'page callback' => 'drupal_get_form',
   'page arguments' => array('jgrowl_settings_form'),
   'access callback' => 'user_access',
@@ -42,7 +42,7 @@ function jgrowl_menu() {
 }
 
 /**
- *  Implementation of hook_theme().
+ * Implementation of hook_theme().
  */
 function jgrowl_theme() {
   return array(
@@ -53,24 +53,24 @@ function jgrowl_theme() {
 }
 
 /**
- *  Implementation of hook_footer().
+ * Implementation of hook_footer().
  */
 function jgrowl_footer($main = 0) {
   jgrowl_system_messages();
 }
 
 /**
- *  Includes all that is needed.
- * 
- *  @return void - uses drupal_dd_js () / drupal_add_css().
+ * Includes all that is needed.
+ *
+ * @return void - uses drupal_dd_js () / drupal_add_css().
  */
 function jgrowl_include() {
   static $include;
-  
+
   if (!$include) {
     // Handle the various ways jgrowl comes packaged.
     // There are 3 types:
-    //  1) full (dev version, full source) 
+    //  1) full (dev version, full source)
     //  2) compressed
     //  3) minimized
     $file = 'jquery.jgrowl';
@@ -79,8 +79,8 @@ function jgrowl_include() {
     if ($type != 'full') {
       $file .= '_'. $type;
     }
-    drupal_add_js($path. '/jgrowl/'. $file .'.js', 'module', 'footer');
-    
+    drupal_add_js($path .'/jgrowl/'. $file .'.js', 'module', 'footer');
+
     // TODO: make theme-able.
     drupal_add_css($path .'/jgrowl/jquery.jgrowl.css');
     drupal_add_css($path .'/jgrowl.css');
@@ -91,33 +91,33 @@ function jgrowl_include() {
 
 /**
  *  Themable jQuery jGrowl snippet.
- * 
+ *
  *  @param $message
  *  The message string that is being displayed in jGrowl.
- * 
+ *
  *  @param $options
  *  Extra jGrowl options to pass to the JS layer.
- * 
+ *
  *  @return string - JavaScript snippet of a jGrowl instance.
  */
 function theme_jgrowl_message($message, $options = array()) {
   $variables = array_merge(jgrowl_variables(), $options);
   $defaults = jgrowl_default_variables();
-  
+
   // No need to add items that are already using their default values.
   foreach ($defaults as $name => $default) {
     if ($name && $variables[$name] === $default) {
       unset($variables[$name]);
     }
   }
-  
+
   return '$.jGrowl("'. str_replace("\n", "<br />", addslashes($message)) .'", '. jgrowl_to_js($variables) .'); ';
 }
 
 /**
- *  Module settings form.
- *  
- *  This form is also setup to provide a configurable settings area for other settings that modules implement via the hook_jgrowl_variable_alter().
+ * Module settings form.
+ *
+ * This form is also setup to provide a configurable settings area for other settings that modules implement via the hook_jgrowl_variable_alter().
  */
 function jgrowl_settings_form() {
   $form['jgrowl_file_type'] = array(
@@ -134,23 +134,23 @@ function jgrowl_settings_form() {
   '#type' => 'checkbox',
   '#default_value' => JGROWL_SYSTEM_MESSAGES,
   );
-  
+
   $form['jgrowl_sticky_errors'] = array(
   '#title' => t('Sticky error messages'),
   '#description' => t('Automatically sticky error messages even if sticky is not enabled below.'),
   '#type' => 'checkbox',
   '#default_value' => JGROWL_STICKY_ERRORS,
   );
-  
+
   $form['jgrowl_sticky_statuses'] = array(
   '#title' => t('Sticky status messages'),
   '#description' => t('Automatically sticky status messages even if sticky is not enabled below.'),
   '#type' => 'checkbox',
   '#default_value' => JGROWL_STICKY_STATUSES,
   );
-  
+
   $form['variables'] = array('#title' => t('Configuration'), '#type' => 'fieldset', '#collapsible' => TRUE, '#description' => t('For more information on the variables available and what they do, visit the !site.', array('!site' => l(t('plugin\'s site'), 'http://stanlemon.net/projects/jgrowl.html'))));
-  
+
   foreach (jgrowl_variables('settings') as $variable => $value) {
     // Leave room for more custom fields.
     // TODO: make the settings $op of the hook able to control this?
@@ -160,13 +160,13 @@ function jgrowl_settings_form() {
         $options = array('top-left' => t('Top left'), 'top-right' => t('Top right'), 'bottom-left' => t('Bottom left'), 'bottom-right' => t('Bottom right'), 'center' => t('Center'));
         $options = array('#options' => $options);
         break;
-      
+
       default:
         $type = 'textfield';
         $options = array();
-        break; 
+        break;
     }
-    
+
     $form['variables']['jgrowl__'. $variable] = array_merge(array(
       '#title' => $variable,
       '#type' => $type,
@@ -178,14 +178,14 @@ function jgrowl_settings_form() {
 }
 
 /**
- *  Handle altering the system messages and displaying them in jgrowl.
- * 
- *  @return void - uses drupal_add_js() to change Drupal's core messages to jGrowl.
+ * Handle altering the system messages and displaying them in jgrowl.
+ *
+ * @return void - uses drupal_add_js() to change Drupal's core messages to jGrowl.
  */
 function jgrowl_system_messages() {
   if (JGROWL_SYSTEM_MESSAGES && !empty($_SESSION['messages'])) {
     jgrowl_include();
-    
+
     // Remove messages from the session and display them with growl.
     $js = '';
     foreach ($_SESSION['messages'] as $type => $messages) {
@@ -203,11 +203,11 @@ function jgrowl_system_messages() {
             }
             break;
         }
-        
+
         $js .= theme('jgrowl_message', $message, $options);
         unset($_SESSION['messages'][$type][$key]);
       }
-       unset($_SESSION['messages'][$type]);
+      unset($_SESSION['messages'][$type]);
     }
     drupal_add_js("$(document).ready(function() { $js });", 'inline', 'footer');
   }
@@ -217,28 +217,28 @@ function jgrowl_system_messages() {
  *  Converts a PHP variable into its Javascript equivalent.
  *
  *  This is a clone of drupal_to_js() but we removed a few extra security measures to avoid JS errors.
- * 
+ *
  *  @param variable
  *  Whatever variable to convert.
- * 
+ *
  *  @return string - json output.
  */
 function jgrowl_to_js($var) {
   // Force a numeric check because of how forgiving PHP can be.
   if (is_numeric($var)) {
-    $type = 'integer';
-  } else {
+    $type = 'integer'; }
+  else {
     $type = gettype($var);
   }
-  
+
   switch ($type) {
     case 'boolean':
       return $var ? 'true' : 'false'; // Lowercase necessary!
-    
+
     case 'integer':
     case 'double':
       return $var;
-      
+
     case 'resource':
     case 'string':
       return '"'. $var .'"';
@@ -260,15 +260,15 @@ function jgrowl_to_js($var) {
         $output[] = jgrowl_to_js(strval($k)) .': '. jgrowl_to_js($v);
       }
       return '{ '. implode(', ', $output) .' }';
-    
+
     // Handle items already in JS format.
-    case substr($var, 0, 1) == '{' && substr($var, (strlen($var) - 1)) == '}':
+    case drupal_substr($var, 0, 1) == '{' && drupal_substr($var, (drupal_strlen($var) - 1)) == '}':
       return $var;
-    
+
     // Handle custom JS functions.
-    case substr($var, 0, strlen('function')) == 'function':
+    case drupal_substr($var, 0, drupal_strlen('function')) == 'function':
       return $var;
-    
+
     default:
       return 'null';
   }
@@ -276,37 +276,37 @@ function jgrowl_to_js($var) {
 
 /**
  *  Function to retrieve the jgrowl config variables.
- * 
+ *
  *  @param: $op
- *  A string of the operation the variables are currently on. 
+ *  A string of the operation the variables are currently on.
  *  - load - on load time.
  *  - settings - when the settings form is presented.
- * 
+ *
  *  @return: struct of variables.
  */
 function jgrowl_variables($op = 'load') {
   $variables = array();
-  
+
   $defaults = jgrowl_default_variables();
-  
+
   // TODO: i added the extra __ for safety for now. is this how i want to handle having them 'separate' as specific variables to pass to JS?
   foreach ($defaults as $name => $value) {
     $variables[$name] = variable_get('jgrowl__'. $name, $value);
   }
-  
+
   // A hook to alter or add to the variables array.
   foreach (module_implements('jgrowl_variable_alter') as $module) {
     $function = $module .'_jgrowl_variable_alter';
     $function($op, $variables);
   }
-  
+
   return $variables;
 }
 
 /**
  *  A function to store all the default variables available in a jgrowl instance.
  *  TODO: redo this to be more dynamic instead of hardcoded in?
- * 
+ *
  *  @return struct of default variables.
  */
 function jgrowl_default_variables() {
@@ -323,7 +323,7 @@ function jgrowl_default_variables() {
     'easing' => 'swing',
     'closer' => 'true',
     'closerTemplate' => '<div>[ close all ]</div>',
-    'log' => 'function(e,m,o) {}', 
+    'log' => 'function(e,m,o) {}',
     'beforeOpen' => 'function(e,m,o) {}',
     'open' => 'function(e,m,o) {}',
     'beforeClose' => 'function(e,m,o) {}',
