diff --git a/jcalendar/jcalendar.js b/jcalendar/jcalendar.js
index e387785..b484aa4 100644
--- a/jcalendar/jcalendar.js
+++ b/jcalendar/jcalendar.js
@@ -7,7 +7,7 @@ if (Drupal.jsEnabled) {
    
     // on click of a link
     $('a.popup').click(function(a) {
-    
+
       // Make sure that other stuff is closed. This seems to cause a problem in Fx2 and IE7.
       $('div#calpopup').fadeOut();
       $('div#calpopup').remove();
@@ -39,15 +39,10 @@ if (Drupal.jsEnabled) {
       // Show Popup
       $('#calpopup').fadeIn('slow');
       
-      // If sucessful call this
-      function domCallback(msg) {
-        $('#calpopup-body').html(msg);
-      }
-      
       // Get NodeID and ItemID
-      var ids = $(this).parent().parent().attr('class');
-      var arrs = ids.split(" ");
-      var arr = arrs[0].split(".");
+      var parents = $(this).parents('.calendar');
+      var ids = $(parents[0]).attr('id');
+      var arr = ids.split(".");
       var nid = arr[1];
       var id = arr[4];
             
@@ -56,7 +51,7 @@ if (Drupal.jsEnabled) {
         type: "GET",
         url: Drupal.settings.basePath + "?q=jcalendar/getnode/"+nid+"/"+ids,
         success: function(msg){
-          domCallback(msg);
+          $('#calpopup-body').html(msg);
         }
       });
       
@@ -74,9 +69,10 @@ if (Drupal.jsEnabled) {
           $(document).unbind("click");
         }
       });
-      
-      // Don't Follow the real link
+
+      // Don't follow the real link.
       return false;
+
     });
   });
 }
