Index: /extensions/UserCollections/include/collections.inc.php
===================================================================
--- /extensions/UserCollections/include/collections.inc.php	(revision 20096)
+++ /extensions/UserCollections/include/collections.inc.php	(revision 20097)
@@ -250,13 +250,8 @@
       }
       
-      
-      // add links for colorbox
-      add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
-      
       // add remove item links
       $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_prefilter');
       
       // thumbnails
-      define('USER_COLLEC_REMOVE_GTHUMB', true);
       include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php');
       
@@ -335,7 +330,5 @@
 function user_collections_thumbnails_in_collection($tpl_thumbnails_var, $pictures)
 {
-  global $template, $page;
-  
-  $template->set_filename('index_thumbnails', dirname(__FILE__).'/../template/thumbnails.tpl');
+  global $template;
   
   foreach ($tpl_thumbnails_var as &$thumbnail)
@@ -354,6 +347,20 @@
   }
   
+  $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
+  
   return $tpl_thumbnails_var;
 }
 
+function user_collections_add_colorbox($content)
+{
+  // add datas
+  $search = '<a href="{$thumbnail.URL}"';
+  $replace = $search.' class="preview-box" data-src="{$thumbnail.FILE_SRC}" data-id="{$thumbnail.id}"';
+  
+  // colorbox script
+  $content.= file_get_contents(USER_COLLEC_PATH.'template/thumbnails_colorbox.tpl');
+  
+  return str_replace($search, $replace, $content);
+}
+
 ?>
Index: /extensions/UserCollections/include/display_thumbnails.inc.php
===================================================================
--- /extensions/UserCollections/include/display_thumbnails.inc.php	(revision 20096)
+++ /extensions/UserCollections/include/display_thumbnails.inc.php	(revision 20097)
@@ -75,15 +75,6 @@
 }
 
-
-// display
-if (defined('USER_COLLEC_REMOVE_GTHUMB'))
-{
-  global $uc_nb_image_page_save;
-
-  $user['nb_image_page'] = $uc_nb_image_page_save['user'];
-  $page['nb_image_page'] = $uc_nb_image_page_save['page'];
-  remove_event_handler('loc_end_index_thumbnails', 'process_GThumb', 50);
-  remove_event_handler('loc_end_index', 'GThumb_remove_thumb_size');
-}
+// add links for colorbox
+add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
 
 include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');
Index: /extensions/UserCollections/include/events.inc.php
===================================================================
--- /extensions/UserCollections/include/events.inc.php	(revision 20096)
+++ /extensions/UserCollections/include/events.inc.php	(revision 20097)
@@ -2,16 +2,7 @@
 defined('USER_COLLEC_PATH') or die('Hacking attempt!');
 
-# this file contains all functions directly called by the triggers #
-
-/* compatibility fix with Gthumb+ */
-function user_collections_save_pagination()
-{
-  global $user, $page, $uc_nb_image_page_save;
-   
-  $uc_nb_image_page_save['user'] = $user['nb_image_page'];
-  $uc_nb_image_page_save['page'] = $page['nb_image_page'];
-}
-
-
+// +-----------------------------------------------------------------------+
+// | SECTION INIT
+// +-----------------------------------------------------------------------+
 /* define page section from url */
 function user_collections_section_init()
@@ -52,5 +43,8 @@
 
 
-/* add buttons on thumbnails list */
+// +-----------------------------------------------------------------------+
+// | CATEGORY PAGE
+// +-----------------------------------------------------------------------+
+/* toggle an image, in case of no javascript or first call (must create the collection) */
 function user_collections_index_actions()
 {
@@ -71,4 +65,5 @@
 }
 
+/* add buttons on thumbnails list */
 function user_collections_thumbnails_list($tpl_thumbnails_var, $pictures)
 {
@@ -77,6 +72,9 @@
   global $page, $template, $UserCollection;
   
-  // the prefilter is different on collection page
-  if (isset($page['section']) and ($page['section'] == 'collections' or $page['section'] == 'download')) return $tpl_thumbnails_var;
+  // the content is different on collection edition page and no button on batch downloader set edition page
+  if ( (@$page['section'] == 'collections' and @$page['sub_section']=='edit') or @$page['section'] == 'download')
+  {
+    return $tpl_thumbnails_var;
+  }
   
   // get existing collections
@@ -96,5 +94,5 @@
   }
   
-  // if the collection is created we don't use AJAX to force menu refresh
+  // if the collection doesn't exists we don't use AJAX to force menu refresh
   if ($col_id === false)
   {
@@ -102,6 +100,6 @@
   }
   
-  
-  $self_url = duplicate_index_url(array(), array('collection_toggle'));  
+  // template vars
+  $url = duplicate_index_url(array(), array('collection_toggle'));  
   
   foreach ($tpl_thumbnails_var as &$thumbnail)
@@ -114,9 +112,10 @@
   unset($thumbnail);
   
-  // thumbnails buttons
   $template->assign(array(
     'USER_COLLEC_PATH' => USER_COLLEC_PATH,
-    'collection_toggle_url' =>  add_url_params($self_url, array('collection_toggle'=>'')),
+    'collection_toggle_url' =>  add_url_params($url, array('collection_toggle'=>'')),
     ));
+  
+  // thumbnails buttons
   $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_prefilter');
   
@@ -127,21 +126,25 @@
 {
   // add links
-  $search = '<span class="wrap1">';
-  $replace = $search.'
+  $search = '#(<span class="wrap1">|<li class="gthumb">)#';
+  $replace = '$1
 {strip}<a class="addCollection" href="{$collection_toggle_url}{$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow">
-{if $COL_ID or $thumbnail.COLLECTION_SELECTED}
+<span class="uc_remove" {if not $COL_ID and not $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}>
 {\'Remove from collection\'|@translate}&nbsp;<img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_delete.png" title="{\'Remove from collection\'|@translate}">
-{else}
+</span>
+<span class="uc_add" {if $COL_ID or $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}>
 {\'Add to collection\'|@translate}&nbsp;<img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_add.png" title="{\'Add to collection\'|@translate}">
-{/if}
+</span>
 </a>{/strip}';
 
   // custom CSS and AJAX request
   $content.= file_get_contents(USER_COLLEC_PATH.'template/thumbnails_css_js.tpl');
-
-  return str_replace($search, $replace, $content);
-}
-
-
+  
+  return preg_replace($search, $replace, $content);
+}
+
+
+// +-----------------------------------------------------------------------+
+// | PICTURE PAGE
+// +-----------------------------------------------------------------------+
 /* add button on picture page */
 function user_collections_picture_page()
@@ -190,5 +193,8 @@
 
 
-/* menu block */
+// +-----------------------------------------------------------------------+
+// | MENU BLOCK
+// +-----------------------------------------------------------------------+
+/* register block */
 function user_collections_add_menublock($menu_ref_arr)
 {
@@ -201,10 +207,18 @@
 }
 
+/* fill block */
 function user_collections_applymenu($menu_ref_arr)
 {
   $max = 6;
   
-  global $template, $conf, $user, $UserCollection;
+  global $template, $page, $conf, $user, $UserCollection;
   $menu = &$menu_ref_arr[0];
+  
+  // the editable counter is for the active collection, except if we are currently editing a collection
+  $col_in_edit = 0;
+  if ( @$page['section'] == 'collections' and @$page['sub_section']=='edit' and !empty($page['col_id']) )
+  {
+    $col_in_edit = $page['col_id'];
+  }
   
   if (($block = $menu->get_block('mbUserCollection')) != null)
@@ -223,4 +237,5 @@
     for ($i=0; $i<$max && $i<count($collections); $i++)
     {
+      $collections[$i]['count_handler'] = $col_in_edit!=0 ? $collections[$i]['id']==$col_in_edit : $collections[$i]['active'];
       $collections[$i]['U_EDIT'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id'];
       array_push($data['collections'], $collections[$i]);
Index: /extensions/UserCollections/main.inc.php
===================================================================
--- /extensions/UserCollections/main.inc.php	(revision 20096)
+++ /extensions/UserCollections/main.inc.php	(revision 20097)
@@ -32,5 +32,4 @@
 {
   // collections page
-  add_event_handler('loc_begin_index', 'user_collections_save_pagination', EVENT_HANDLER_PRIORITY_NEUTRAL-10);
   add_event_handler('loc_end_section_init', 'user_collections_section_init');
   add_event_handler('loc_end_index', 'user_collections_page', EVENT_HANDLER_PRIORITY_NEUTRAL-10);
@@ -38,5 +37,5 @@
   // thumbnails actions
   add_event_handler('loc_end_index', 'user_collections_index_actions');
-  add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
+  add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
 
   // picture action
Index: /extensions/UserCollections/template/menublock_user_collec.tpl
===================================================================
--- /extensions/UserCollections/template/menublock_user_collec.tpl	(revision 20096)
+++ /extensions/UserCollections/template/menublock_user_collec.tpl	(revision 20097)
@@ -3,5 +3,5 @@
   <p>
     {if $block->data.NB_COL == 0}
-      {'You have no collection'|@translate|sprintf:$block->data.NB_COL}
+      {'You have no collection'|@translate}
     {else}
       <a href="{$block->data.U_LIST}">{$pwg->l10n_dec('You have %d collection', 'You have %d collections', $block->data.NB_COL)}</a>
@@ -10,9 +10,9 @@
   <ul>{strip}
 		{foreach from=$block->data.collections item=col}
-		<li>{if $col.active}
-      <a href="{$col.U_EDIT}" style="font-weight:bold;" rel="nofollow">{$col.name}</a> <i class="menuInfoCat">({'active'|@translate})</i> <span class="menuInfoCat">[<span class="nbImagesCollec">{$col.nb_images}</span>]</span>
-    {else}
-      <a href="{$col.U_EDIT}" rel="nofollow">{$col.name}</a> <span class="menuInfoCat">[{$col.nb_images}]</span>
-    {/if}</li>
+		<li>
+      <a href="{$col.U_EDIT}" {if $col.active}style="font-weight:bold;"{/if} rel="nofollow">{$col.name}</a>&nbsp; 
+      {if $col.active}<i class="menuInfoCat">({'active'|@translate})</i>&nbsp;{/if} 
+      <span class="menuInfoCat">[<span {if $col.count_handler}class="nbImagesCollec"{/if}>{$col.nb_images}</span>]</span>
+    </li>
 		{/foreach}
     {if $block->data.MORE}<li class="menuInfoCat">{'%d more...'|@translate|sprintf:$block->data.MORE}</li>{/if}
Index: tensions/UserCollections/template/thumbnails.tpl
===================================================================
--- /extensions/UserCollections/template/thumbnails.tpl	(revision 20096)
+++ 	(revision )
@@ -1,81 +1,0 @@
-{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
-{combine_css path="themes/default/js/plugins/colorbox/style2/colorbox.css"}
-
-{footer_script}
-jQuery("a.preview-box").colorbox({ldelim}
-  rel: ".preview-box",
-  title: function() {ldelim}
-    var title = $(this).attr("title");
-    {if $F_ACTION} title+= ' · <a href="{$collection_toggle_url}&amp;collection_toggle='+ $(this).data('id') +'" class="addCollection" data-id="'+ $(this).data('id') +'">{'Remove from collection'|@translate}</a>';{/if}
-    title+= ' · <a href="'+ $(this).data('url') +'" target="_blank">{'jump to photo'|@translate} →</a>';
-    return  title;
-  }
-});
-jQuery(document).on("click", "#cboxTitle .addCollection", function() {ldelim}
-  jQuery.colorbox.close();
-  jQuery("#thumbnails a.addCollection[data-id='"+ $(this).data('id')+"']").trigger("click");
-  return false;
-});
-{/footer_script}
-
-{if !empty($thumbnails)}{strip}
-{*define_derivative name='derivative_params' width=160 height=90 crop=true*}
-{html_style}
-{*Set some sizes according to maximum thumbnail width and height*}
-.thumbnails SPAN,
-.thumbnails .wrap2 A,
-.thumbnails LABEL{ldelim}
-	width: {$derivative_params->max_width()+2}px;
-}
-
-.thumbnails .wrap2{ldelim}
-	height: {$derivative_params->max_height()+3}px;
-}
-{if $derivative_params->max_width() > 600}
-.thumbLegend {ldelim}font-size: 130%}
-{else}
-{if $derivative_params->max_width() > 400}
-.thumbLegend {ldelim}font-size: 110%}
-{else}
-.thumbLegend {ldelim}font-size: 90%}
-{/if}
-{/if}
-{/html_style}
-{foreach from=$thumbnails item=thumbnail}
-{assign var=derivative value=$pwg->derivative($derivative_params, $thumbnail.src_image)}
-{if !$derivative->is_cached()}
-{combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='footer'}
-{combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'}
-{/if}
-<li>
-	<span class="wrap1">
-		<span class="wrap2">
-		<a href="{$thumbnail.FILE_SRC}" class="preview-box" title="{$thumbnail.NAME}" data-url="{$thumbnail.URL}" data-id="{$thumbnail.id}">
-			<img class="thumbnail" {if $derivative->is_cached()}src="{$derivative->get_url()}"{else}src="{$ROOT_URL}{$themeconf.img_dir}/ajax-loader-small.gif" data-src="{$derivative->get_url()}"{/if} alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}">
-		</a>
-		</span>
-		{if $SHOW_THUMBNAIL_CAPTION }
-		<span class="thumbLegend">
-		<span class="thumbName">{$thumbnail.NAME}</span>
-		{if !empty($thumbnail.icon_ts)}
-		<img title="{$thumbnail.icon_ts.TITLE}" src="{$ROOT_URL}{$themeconf.icon_dir}/recent.png" alt="(!)">
-		{/if}
-		{if isset($thumbnail.NB_COMMENTS)}
-		<span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments">
-		<br>
-		{$pwg->l10n_dec('%d comment', '%d comments',$thumbnail.NB_COMMENTS)}
-		</span>
-		{/if}
-
-		{if isset($thumbnail.NB_HITS)}
-		<span class="{if 0==$thumbnail.NB_HITS}zero {/if}nb-hits">
-		<br>
-		{$pwg->l10n_dec('%d hit', '%d hits',$thumbnail.NB_HITS)}
-		</span>
-		{/if}
-		</span>
-		{/if}
-	</span>
-	</li>
-{/foreach}{/strip}
-{/if}
Index: /extensions/UserCollections/template/thumbnails_colorbox.tpl
===================================================================
--- /extensions/UserCollections/template/thumbnails_colorbox.tpl	(revision 20097)
+++ /extensions/UserCollections/template/thumbnails_colorbox.tpl	(revision 20097)
@@ -0,0 +1,20 @@
+{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
+{combine_css path="themes/default/js/plugins/colorbox/style2/colorbox.css"}
+
+{footer_script}
+jQuery("a.preview-box").colorbox({ldelim}
+  rel: ".preview-box",
+  href: function() {ldelim} return $(this).data('src'); },
+  title: function() {ldelim}
+    var title = $(this).children("img.thumbnail").attr("alt");
+    {if $F_ACTION} title+= ' · <a href="{$collection_toggle_url}&amp;collection_toggle='+ $(this).data('id') +'" class="addCollection" data-id="'+ $(this).data('id') +'">{'Remove from collection'|@translate}</a>';{/if}
+    title+= ' · <a href="'+ $(this).attr('href') +'" target="_blank">{'jump to photo'|@translate} →</a>';
+    return  title;
+  }
+});
+jQuery(document).on("click", "#cboxTitle .addCollection", function() {ldelim}
+  jQuery.colorbox.close();
+  jQuery("#thumbnails a.addCollection[data-id='"+ $(this).data('id')+"']").trigger("click");
+  return false;
+});
+{/footer_script}
Index: /extensions/UserCollections/template/thumbnails_css_js.tpl
===================================================================
--- /extensions/UserCollections/template/thumbnails_css_js.tpl	(revision 20096)
+++ /extensions/UserCollections/template/thumbnails_css_js.tpl	(revision 20097)
@@ -1,6 +1,6 @@
 {html_style}
 .thumbnails .wrap1 {ldelim} position:relative !important; }
-.wrap1 .addCollection {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100;color:#eee;white-space:nowrap; }
-.wrap1:hover .addCollection {ldelim} display:block; }
+.wrap1 .addCollection, .gthumb .addCollection {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100 !important;color:#eee;white-space:nowrap; }
+.wrap1:hover .addCollection, .gthumb:hover .addCollection {ldelim} display:block; }
 {/html_style}
 
@@ -17,14 +17,16 @@
   }).done(function(msg) {ldelim}
     if (msg == "true") {ldelim}
-      $trigger.html('{'Remove from collection'|@translate}&nbsp;<img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_delete.png" title="{'Remove from collection'|@translate}">');
+      $trigger.children(".uc_remove").show();
+      $trigger.children(".uc_add").hide();
       jQuery(".nbImagesCollec").html(parseInt(jQuery(".nbImagesCollec").html()) +1);
     } else if (msg == "false") {ldelim}
     {if $COL_ID}
-      $trigger.parent(".wrap1").hide("fast", function() {ldelim} $trigger.remove() });
+      $trigger.parent(".wrap1, .gthumb").hide("fast", function() {ldelim} $trigger.remove() });
       if (typeof batchdown_count != 'undefined') batchdown_count-=1;
     {else}
-      $trigger.html('{'Add to collection'|@translate}&nbsp;<img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_add.png" title="{'Add to collection'|@translate}">');
+      $trigger.children(".uc_remove").hide();
+      $trigger.children(".uc_add").show();
     {/if}
-      jQuery(".nbImagesCollec").html(parseInt(jQuery(".nbImagesCollec").html()) -1);
+    jQuery(".nbImagesCollec").html(parseInt(jQuery(".nbImagesCollec").html()) -1);
     } else {ldelim}
       $trigger.html('{'Un unknown error occured'|@translate}');
