diff --git a/dialog.module b/dialog.module
index bfa8b59..4d42578 100644
--- a/dialog.module
+++ b/dialog.module
@@ -64,7 +64,16 @@ function dialog_add_js() {
   // Get the correct CSS path based on jQuery UI version.
   $version_16 = version_compare(jquery_ui_get_version(), '1.7.0', '<');
   $css_path = $version_16 ? 'default' : 'base';
-  drupal_add_css(JQUERY_UI_PATH .'/themes/'. $css_path .'/ui.all.css');
+
+  if (defined('JQUERY_UI_PATH')) {
+     drupal_add_css(JQUERY_UI_PATH . '/themes/' . $css_path  . '/ui.all.css');
+  }
+  else if (function_exists('jquery_ui_get_path')) {
+    drupal_add_css(jquery_ui_get_path() . '/themes/' . $css_path . '/ui.all.css');
+  }
+  else {
+    drupal_set_message(t('Failed to find jQuery UI library.'), 'error');
+  }
 
   // And finally, the dialog js.
   drupal_add_js(drupal_get_path('module', 'dialog') .'/dialog.js');
