--- /Users/gedmanning/Desktop/refine_by_taxo/refine_by_taxo.module	2006-08-21 10:18:23.000000000 +0100
+++ /Users/gedmanning/Desktop/refine_by_taxo_new.module	2006-08-29 20:59:31.000000000 +0100
@@ -126,7 +126,19 @@ function refine_by_taxo_view_blocks($del
  */
 function refine_by_taxo_build_body($terms, $op) {
   //placeholder for tagadelic integration
-
+  if (module_exist('tagadelic')){
+    $tids = array();
+    $vids = array();
+    foreach($terms as $term){
+      $tids[] = $term->tid;
+      if (!in_array($term->vid)) {
+        $vids[] = $term->vid;
+      }
+    }
+    if (count($tids) != 0 && count($vids != 0)) {
+      return theme('refined_tagadelic', tagadelic_get_weighted_tags($vids, 4, 60, $tids));
+    }
+  }
   foreach ($terms as $term) {
     // BAH Drupal encodes teh paths, what a crap.
     // $items[] = l($term->name, refine_by_taxo_build_url($term->tid, $op));
@@ -136,6 +148,17 @@ function refine_by_taxo_build_body($term
 }
 
 /**
+ * theme function that renders the HTML for the tags when using tagadelic
+ * @ingroup themable
+ */
+function theme_refined_tagadelic($terms) {
+  foreach ($terms as $term) {
+    $output .= '<a href="'. refine_by_taxo_build_url($term->tid, $op) .'" class="tagadelic level'. $term->weight .'">'. $term->name .'</a>';
+  }
+  return $output;
+}
+
+/**
  * Returns TRUE when we are looking at a term page, else FALSE.
  * TODO: add views smartness here!
  */
