--- uc_option_image.orig.js	2008-04-15 11:04:55.000000000 -0600
+++ uc_option_image.js	2008-04-24 12:28:26.000000000 -0600
@@ -19,6 +19,14 @@ UCOI.init = function() {
       UCOI.switchImage(this, size);  
     }
   });
+  
+  $('.add_to_cart input.form-radio').change(function(){
+    var name = $(this).attr('name');
+    
+    if (name.substr(0, 10) == 'attributes'){
+      UCOI.switchRadio(this, size);  
+    }
+  });
 };
 
 /**
@@ -55,6 +63,44 @@ UCOI.switchImage = function(input, size)
 };
 
 /**
+* Switch an option image for a radio button!
+*/
+UCOI.switchRadio = function(input, size) {
+  var id = $(input).attr('name');
+  var pid = $(input).parents('.node').attr('id');
+  var nid = pid.replace('node-', '');
+
+  // get the attribute id from the name
+  var aid = id.match(/attributes\[(\d+)\]/)[1];
+  
+  // figure out which option is checked
+  var oid = $("input[@name='"+id+"']:checked").val();
+  var image = $(input).parents('.content').children('img.uc-option-image');
+  
+  // Make sure we have permission to switch this attribute
+  if (this.attributes[aid] === 0){
+    return;
+  }
+          
+  try {          
+    var images = this.images[nid][aid];
+                                          
+    if (images[oid].derivatives[size]){ 
+      var imagepath = Drupal.settings.base_path + images[oid].derivatives[size];   
+      this.switchImageEffect(image, imagepath);
+    } 
+    else { 
+      var imagepath = Drupal.settings.base_path + images[oid].derivatives[this.defaultSize];   
+      this.switchImageEffect(image, imagepath);
+    }
+  }
+  catch (e){   
+    this.switchImageEffect(image, this.noimage); 
+  }
+};
+
+
+/**
 * Switch the imagepath based on the selected effect.
 */
 UCOI.switchImageEffect = function(image, imagepath) {
