Index: /extensions/GThumb/js/gthumb.js
===================================================================
--- /extensions/GThumb/js/gthumb.js	(revision 12709)
+++ /extensions/GThumb/js/gthumb.js	(revision 12710)
@@ -1,5 +1,4 @@
 var GThumb = {
 
-  selector: null,
   max_height: 200,
   margin: 10,
@@ -17,9 +16,8 @@
   }),
 
-  build: function (selector) {
-
-    this.t = new Array;
-    this.selector = selector;
-    jQuery(selector+' img.thumbnail').each(function() {
+  build: function () {
+
+    GThumb.t = new Array;
+    jQuery('#thumbnails img.thumbnail').each(function() {
       id = parseInt(this.id.substring(2));
       width = parseInt(jQuery(this).attr('width'));
@@ -39,11 +37,10 @@
     jQuery.resize.throttleWindow = false;
     jQuery.resize.delay = 50;
-    jQuery(selector).resize(function() { GThumb.process(); });
-    this.process();
+    GThumb.process();
   },
 
   addToQueue: function (id, loop) {
 
-    this.queue.add({
+    GThumb.queue.add({
       type: 'GET', 
       url: 'ws.php', 
@@ -69,26 +66,26 @@
   process: function() {
 
-    var width_count = this.margin;
+    var width_count = GThumb.margin;
     var line = 1;
     var round_rest = 0;
-    var main_width = jQuery(this.selector).width();
-    var first_thumb = jQuery(this.selector+' img:first');
+    var main_width = jQuery('#thumbnails').width();
+    var first_thumb = jQuery('#thumbnails img:first');
     var best_size = {width:1,height:1};
 
-    if (this.big_thumb != null && this.big_thumb.height < main_width * this.max_first_thumb_width) {
+    if (GThumb.big_thumb != null && GThumb.big_thumb.height < main_width * GThumb.max_first_thumb_width) {
 
       // Compute best size for landscape picture (we choose bigger height)
-      min_ratio = Math.min(1.05, this.big_thumb.width/this.big_thumb.height);
-
-      for(width = this.big_thumb.width; width/best_size.height>=min_ratio; width--) {
-        width_count = this.margin;
-        height = this.margin;
+      min_ratio = Math.min(1.05, GThumb.big_thumb.width/GThumb.big_thumb.height);
+
+      for(width = GThumb.big_thumb.width; width/best_size.height>=min_ratio; width--) {
+        width_count = GThumb.margin;
+        height = GThumb.margin;
         max_height = 0;
-        available_width = main_width - (width + this.margin);
+        available_width = main_width - (width + GThumb.margin);
         line = 1;
-        for (i=1;i<this.t.length;i++) {
-
-          width_count += this.t[i].width + this.margin;
-          max_height = Math.max(this.t[i].height, max_height);
+        for (i=1;i<GThumb.t.length;i++) {
+
+          width_count += GThumb.t[i].width + GThumb.margin;
+          max_height = Math.max(GThumb.t[i].height, max_height);
 
           if (width_count > available_width) {
@@ -97,7 +94,7 @@
             line++;
             max_height = 0;
-            width_count = this.margin;
+            width_count = GThumb.margin;
             if (line > 2) {
-              if (height >= best_size.height && width/height >= min_ratio && height<=this.big_thumb.height) {
+              if (height >= best_size.height && width/height >= min_ratio && height<=GThumb.big_thumb.height) {
                 best_size = {width:width,height:height}
               }
@@ -108,9 +105,9 @@
         if (line <= 2) {
           if (max_height == 0 || line == 1) {
-            height = this.big_thumb.height;
+            height = GThumb.big_thumb.height;
           } else {
             height += max_height;
           }
-          if (height >= best_size.height && width/height >= min_ratio && height<=this.big_thumb.height) {
+          if (height >= best_size.height && width/height >= min_ratio && height<=GThumb.big_thumb.height) {
             best_size = {width:width,height:height}
           }
@@ -118,51 +115,51 @@
       }
 
-      if (this.big_thumb.src != first_thumb.attr('src')) {
-        first_thumb.attr('src', this.big_thumb.src).attr({width:this.big_thumb.width,height:this.big_thumb.height});
-        this.t[0].width = this.big_thumb.width;
-        this.t[0].height = this.big_thumb.height;
-      }
-      this.t[0].crop = best_size.width;
-      this.resize(first_thumb, this.big_thumb.width, this.big_thumb.height, best_size.width, best_size.height, true);
+      if (GThumb.big_thumb.src != first_thumb.attr('src')) {
+        first_thumb.attr('src', GThumb.big_thumb.src).attr({width:GThumb.big_thumb.width,height:GThumb.big_thumb.height});
+        GThumb.t[0].width = GThumb.big_thumb.width;
+        GThumb.t[0].height = GThumb.big_thumb.height;
+      }
+      GThumb.t[0].crop = best_size.width;
+      GThumb.resize(first_thumb, GThumb.big_thumb.width, GThumb.big_thumb.height, best_size.width, best_size.height, true);
 
     }
 
     if (best_size.width == 1) {
-      if (this.small_thumb != null && this.small_thumb.src != first_thumb.attr('src')) {  
-        first_thumb.prop('src', this.small_thumb.src).attr({width:this.small_thumb.width,height:this.small_thumb.height});
-        this.t[0].width = this.small_thumb.width;
-        this.t[0].height = this.small_thumb.height;
-      }
-      this.t[0].crop = false;
-    }
-
-    width_count = this.margin;
+      if (GThumb.small_thumb != null && GThumb.small_thumb.src != first_thumb.attr('src')) {  
+        first_thumb.prop('src', GThumb.small_thumb.src).attr({width:GThumb.small_thumb.width,height:GThumb.small_thumb.height});
+        GThumb.t[0].width = GThumb.small_thumb.width;
+        GThumb.t[0].height = GThumb.small_thumb.height;
+      }
+      GThumb.t[0].crop = false;
+    }
+
+    width_count = GThumb.margin;
     max_height = 0;
     line = 1;
     thumb_process = new Array;
 
-    for (i=this.t[0].crop!=false?1:0;i<this.t.length;i++) {
-
-      width_count += this.t[i].width + this.margin;
-      max_height = Math.max(this.t[i].height, max_height);
-      thumb_process.push(this.t[i]);
+    for (i=GThumb.t[0].crop!=false?1:0;i<GThumb.t.length;i++) {
+
+      width_count += GThumb.t[i].width + GThumb.margin;
+      max_height = Math.max(GThumb.t[i].height, max_height);
+      thumb_process.push(GThumb.t[i]);
 
       available_width = main_width;
-      if (line <= 2 && this.t[0].crop !== false) {
-        available_width -= (this.t[0].crop + this.margin);
+      if (line <= 2 && GThumb.t[0].crop !== false) {
+        available_width -= (GThumb.t[0].crop + GThumb.margin);
       }
 
       if (width_count > available_width) {
 
-        last_thumb = this.t[i].id;
+        last_thumb = GThumb.t[i].id;
         ratio = width_count / available_width;
         new_height = Math.round(max_height / ratio);
         round_rest = 0;
-        width_count = this.margin;
+        width_count = GThumb.margin;
 
         for (j=0;j<thumb_process.length;j++) {
 
           if (thumb_process[j].id == last_thumb) {
-            new_width = available_width - width_count - this.margin;
+            new_width = available_width - width_count - GThumb.margin;
           } else {
             new_width = (thumb_process[j].width + round_rest) / ratio;
@@ -170,10 +167,10 @@
             new_width = Math.round(new_width);
           }
-          this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false);
-
-          width_count += new_width + this.margin;
+          GThumb.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false);
+
+          width_count += new_width + GThumb.margin;
         }
         thumb_process = new Array;
-        width_count = this.margin;
+        width_count = GThumb.margin;
         max_height = 0;
         line++;
@@ -183,9 +180,9 @@
     // Last line does not need to be cropped
     for (j=0;j<thumb_process.length;j++) {
-      this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false);
-    }
-
-    if (main_width != jQuery(this.selector).width()) {
-      this.process();
+      GThumb.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false);
+    }
+
+    if (main_width != jQuery('#thumbnails').width()) {
+      GThumb.process();
     }
   },
@@ -193,5 +190,5 @@
   resize: function(thumb, width, height, new_width, new_height, is_big) {
 
-    if (this.method == 'resize' || height < new_height || width < new_width) {
+    if (GThumb.method == 'resize' || height < new_height || width < new_width) {
       real_width = new_width;
       real_height = new_height;
Index: /extensions/GThumb/main.inc.php
===================================================================
--- /extensions/GThumb/main.inc.php	(revision 12709)
+++ /extensions/GThumb/main.inc.php	(revision 12710)
@@ -128,5 +128,5 @@
   global $conf;
 
-  if (empty($picture['width']))
+  if (!in_array(get_extension($picture['file']), $conf['picture_ext']))
   {
     $file = get_thumbnail_url($picture);
Index: /extensions/GThumb/template/gthumb.css
===================================================================
--- /extensions/GThumb/template/gthumb.css	(revision 12709)
+++ /extensions/GThumb/template/gthumb.css	(revision 12710)
@@ -1,11 +1,9 @@
 #thumbnails {
-  padding: 0;
-  width:auto;
-  overflow:hidden;
+  overflow: hidden;
 }
 
 #thumbnails li {
   position: relative;
-  overflow:hidden;
+  overflow: hidden;
   float: left;
   display: inline;
@@ -18,4 +16,6 @@
 
 .thumbnail, .thumbnail:hover {
-  border: 0 none;
+  border: 0 none !important;
+  margin: 0 !important;
+  padding: 0 !important;
 }
Index: /extensions/GThumb/template/gthumb.tpl
===================================================================
--- /extensions/GThumb/template/gthumb.tpl	(revision 12709)
+++ /extensions/GThumb/template/gthumb.tpl	(revision 12710)
@@ -10,7 +10,7 @@
 
 {combine_css path="plugins/GThumb/template/gthumb.css"}
-{combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
-{combine_script id='jquery.ba-resize' path='plugins/GThumb/js/jquery.ba-resize.min.js'}
-{combine_script id='gthumb' require='jquery,jquery.ajaxmanager,jquery.ba-resize' path='plugins/GThumb/js/gthumb.js'}
+{combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load="footer"}
+{combine_script id='jquery.ba-resize' path='plugins/GThumb/js/jquery.ba-resize.min.js' load="footer"}
+{combine_script id='gthumb' require='jquery,jquery.ajaxmanager,jquery.ba-resize' path='plugins/GThumb/js/gthumb.js' load="footer"}
 
 {footer_script require="gthumb"}
@@ -24,6 +24,7 @@
 {/if}
 
-GThumb.build('#thumbnails');
-$(window).bind('RVTS_loaded', function() {ldelim} GThumb.build('#thumbnails'); });
+GThumb.build();
+jQuery(window).bind('RVTS_loaded', GThumb.build);
+jQuery('#thumbnails').resize(GThumb.process);
 {/footer_script}
 
