Index: /trunk/admin/themes/default/js/LocalStorageCache.js
===================================================================
--- /trunk/admin/themes/default/js/LocalStorageCache.js	(revision 28554)
+++ /trunk/admin/themes/default/js/LocalStorageCache.js	(revision 28555)
@@ -85,15 +85,18 @@
   /*
    * Load Selectize with cache content
-   * @param $target {jQuery}
-   * @param options {object}
+   * @param $target {jQuery} may have some data attributes (create, default, value)
+   * @param options {object}
+   *    - value (optional) list of preselected items (ids, or objects with "id" attribute")
    *    - default (optional) default value which will be forced if the select is emptyed
+   *    - create (optional) allow item user creation
    *    - filter (optional) function called for each select before applying the data
    *      takes two parameters: cache data, options
    *      must return new data
    */
-  AbstractSelectizer.prototype._selectize = function($target, options) {
+  AbstractSelectizer.prototype._selectize = function($target, globalOptions) {
     this.get(function(data) {
       $target.each(function() {
-        var filtered, value;
+        var filtered, value, defaultValue,
+            options = $.extend({}, globalOptions);
         
         // apply filter function
@@ -106,8 +109,9 @@
         
         // active creation mode
-        if (this.hasAttribute('data-selectize-create')) {
-          this.selectize.settings.create = true;
-        }
-        
+        if (this.hasAttribute('data-create')) {
+          options.create = true;
+        }
+        this.selectize.settings.create = !!options.create;
+
         // load options
         this.selectize.load(function(callback) {
@@ -119,4 +123,7 @@
         // load items
         if ((value = $(this).data('value'))) {
+          options.value = value;
+        }
+        if (options.value != undefined) {
           $.each(value, $.proxy(function(i, cat) {
             if ($.isNumeric(cat))
@@ -125,4 +132,12 @@
               this.selectize.addItem(cat.id);
           }, this));
+        }
+        
+        // set default
+        if ((defaultValue = $(this).data('default'))) {
+          options.default = defaultValue;
+        }
+        if (options.default == 'first') {
+          options.default = filtered[0] ? filtered[0].id : undefined;
         }
         
Index: /trunk/admin/themes/default/js/addAlbum.js
===================================================================
--- /trunk/admin/themes/default/js/addAlbum.js	(revision 28554)
+++ /trunk/admin/themes/default/js/addAlbum.js	(revision 28555)
@@ -5,17 +5,21 @@
   
   var $popup = jQuery('#addAlbumForm');
-  if (!$popup.data('init')) {
-    $popup.find('[name="category_parent"]').selectize({
-      valueField: 'id',
-      labelField: 'fullname',
-      sortField: 'global_rank',
-      searchField: ['fullname'],
-      plugins: ['remove_button'],
-      onInitialize: function() {
-        this.on('dropdown_close', function() {
-          if (this.getValue() == '') {
-            this.setValue(0);
-          }
+  
+  function init() {
+    if ($popup.data('init')) {
+      return;
+    }
+    $popup.data('init', true);
+    
+    options.cache.selectize($popup.find('[name="category_parent"]'), {
+      'default': 0,
+      'filter': function(categories) {
+        categories.push({
+          id: 0,
+          fullname: '------------',
+          global_rank: 0
         });
+        
+        return categories;
       }
     });
@@ -48,8 +52,10 @@
 
           var newAlbum = data.result.id,
-              newAlbum_name = '';
+              newAlbum_name = '',
+              newAlbum_rank = '0';
               
           if (parent_id != 0) {
             newAlbum_name = albumParent[0].selectize.options[parent_id].fullname +' / ';
+            newAlbum_rank = albumParent[0].selectize.options[parent_id].global_rank +'.1';
           }
           newAlbum_name+= name;
@@ -75,10 +81,22 @@
           // target is selectize
           else {
-            $albumSelect[0].selectize.addOption({
-              id: newAlbum,
-              fullname: newAlbum_name
-            });
+            var selectize = $albumSelect[0].selectize;
             
-            $albumSelect[0].selectize.setValue(newAlbum);
+            if (jQuery.isEmptyObject(selectize.options)) {
+              options.cache.clear();
+              options.cache.selectize($albumSelect, {
+                'default': newAlbum,
+                'value': newAlbum
+              });
+            }
+            else {
+              $albumSelect[0].selectize.addOption({
+                id: newAlbum,
+                fullname: newAlbum_name,
+                global_rank: newAlbum_rank
+              });
+              
+              $albumSelect[0].selectize.setValue(newAlbum);
+            }
           }
 
@@ -99,23 +117,7 @@
     width: 350, height: 300,
     onComplete: function() {
-      var albumParent = $popup.find('[name="category_parent"]')[0];
-      
+      init();
       $popup.data('target', jQuery(this).data('addAlbum'));
-
-      albumParent.selectize.clearOptions();
-      
-      options.cache.get(function(categories) {
-        categories.push({
-          id: 0,
-          fullname: '------------',
-          global_rank: 0
-        });
-        
-        albumParent.selectize.load(function(callback) {
-          callback(categories);
-        });
-        
-        albumParent.selectize.setValue(0);
-      });
+      $popup.find('[name=category_name]').focus();
     }
   });
Index: /trunk/admin/themes/default/template/batch_manager_global.tpl
===================================================================
--- /trunk/admin/themes/default/template/batch_manager_global.tpl	(revision 28554)
+++ /trunk/admin/themes/default/template/batch_manager_global.tpl	(revision 28555)
@@ -99,5 +99,4 @@
       }
       else {
-        options.default = categories[0].id;
         return categories;
       }
@@ -604,5 +603,5 @@
         {'Album'|@translate}
         <select data-selectize="categories" data-value="{$filter_category_selected|@json_encode|escape:html}"
-          name="filter_category" style="width:400px"></select>
+          data-default="first" name="filter_category" style="width:400px"></select>
         <label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
       </li>
@@ -613,4 +612,5 @@
         {'Tags'|@translate}
         <select data-selectize="tags" data-value="{$filter_tags|@json_encode|escape:html}"
+          placeholder="{'Type in a search term'|translate}"
           name="filter_tags[]" multiple style="width:400px;"></select>
         <label><span><input type="radio" name="tag_mode" value="AND" {if !isset($filter.tag_mode) or $filter.tag_mode eq 'AND'}checked="checked"{/if}> {'All tags'|@translate}</span></label>
@@ -812,5 +812,5 @@
     <!-- associate -->
     <div id="action_associate" class="bulkAction">
-      <select data-selectize="categories" name="associate" style="width:400px"></select>
+      <select data-selectize="categories" data-default="first" name="associate" style="width:400px"></select>
       <br>{'... or '|@translate}
       <a href="#" data-add-album="associate" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
@@ -819,5 +819,5 @@
     <!-- move -->
     <div id="action_move" class="bulkAction">
-      <select data-selectize="categories" name="move" style="width:400px"></select>
+      <select data-selectize="categories" data-default="first" name="move" style="width:400px"></select>
       <br>{'... or '|@translate}
       <a href="#" data-add-album="move" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
@@ -827,5 +827,6 @@
     <!-- dissociate -->
     <div id="action_dissociate" class="bulkAction albumDissociate" style="display:none">
-      <select data-selectize="categories" name="dissociate" style="width:400px"></select>
+      <select data-selectize="categories" placeholder="{'Type in a search term'|translate}"
+        name="dissociate" style="width:400px"></select>
     </div>
 
@@ -833,5 +834,6 @@
     <!-- add_tags -->
     <div id="action_add_tags" class="bulkAction">
-      <select data-selectize="tags" data-selectize-create name="add_tags[]" multiple style="width:400px;"></select>
+      <select data-selectize="tags" data-create="true" placeholder="{'Type in a search term'|translate}"
+        name="add_tags[]" multiple style="width:400px;"></select>
     </div>
 
@@ -839,5 +841,6 @@
     <div id="action_del_tags" class="bulkAction">
 {if !empty($associated_tags)}
-      <select data-selectize="tags" name="del_tags[]" multiple style="width:400px;">
+      <select data-selectize="tags" name="del_tags[]" multiple style="width:400px;"
+        placeholder="{'Type in a search term'|translate}">
       {foreach from=$associated_tags item=tag}
         <option value="{$tag.id}">{$tag.name}</option>
Index: /trunk/admin/themes/default/template/batch_manager_unit.tpl
===================================================================
--- /trunk/admin/themes/default/template/batch_manager_unit.tpl	(revision 28554)
+++ /trunk/admin/themes/default/template/batch_manager_unit.tpl	(revision 28555)
@@ -99,5 +99,6 @@
       <td>
         <select data-selectize="tags" data-value="{$element.TAGS|@json_encode|escape:html}"
-          name="tags-{$element.id}[]" multiple style="width:500px;" data-selectize-create></select>
+          placeholder="{'Type in a search term'|translate}"
+          data-create="true" name="tags-{$element.id}[]" multiple style="width:500px;"></select>
       </td>
     </tr>
Index: /trunk/admin/themes/default/template/cat_perm.tpl
===================================================================
--- /trunk/admin/themes/default/template/cat_perm.tpl	(revision 28554)
+++ /trunk/admin/themes/default/template/cat_perm.tpl	(revision 28555)
@@ -73,5 +73,6 @@
     <br>
     <select data-selectize="groups" data-value="{$groups_selected|@json_encode|escape:html}"
-        name="groups[]" multiple style="width:600px;"></select>
+      placeholder="{'Type in a search term'|translate}"
+      name="groups[]" multiple style="width:600px;"></select>
 {else}
     {'There is no group in this gallery.'|@translate} <a href="admin.php?page=group_list" class="externalLink">{'Group management'|@translate}</a>
@@ -83,5 +84,6 @@
     <br>
     <select data-selectize="users" data-value="{$users_selected|@json_encode|escape:html}"
-        name="users[]" multiple style="width:600px;"></select>
+      placeholder="{'Type in a search term'|translate}"
+      name="users[]" multiple style="width:600px;"></select>
   </p>
 
Index: /trunk/admin/themes/default/template/photos_add_direct.tpl
===================================================================
--- /trunk/admin/themes/default/template/photos_add_direct.tpl	(revision 28554)
+++ /trunk/admin/themes/default/template/photos_add_direct.tpl	(revision 28555)
@@ -28,5 +28,4 @@
     if (categories.length > 0) {
       jQuery("#albumSelection, .selectFiles, .showFieldset").show();
-      options.default = categories[0].id;
     }
     
@@ -202,5 +201,5 @@
       <span id="albumSelection" style="display:none">
       <select data-selectize="categories" data-value="{$selected_category|@json_encode|escape:html}"
-        name="category" style="width:400px"></select>
+        data-default="first" name="category" style="width:400px"></select>
       <br>{'... or '|@translate}</span>
       <a href="#" data-add-album="category" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
Index: /trunk/admin/themes/default/template/picture_modify.tpl
===================================================================
--- /trunk/admin/themes/default/template/picture_modify.tpl	(revision 28554)
+++ /trunk/admin/themes/default/template/picture_modify.tpl	(revision 28555)
@@ -17,10 +17,5 @@
 });
 
-categoriesCache.selectize(jQuery('[data-selectize=categories]'), { {if $STORAGE_ALBUM}
-  filter: function(categories, options) {
-    options.default = (this.name == 'associate[]') ? {$STORAGE_ALBUM} : undefined;
-    return categories;
-  }
-{/if} });
+categoriesCache.selectize(jQuery('[data-selectize=categories]'));
 
 {* <!-- TAGS --> *}
@@ -110,5 +105,6 @@
       <br>
       <select data-selectize="categories" data-value="{$associated_albums|@json_encode|escape:html}"
-        name="associate[]" multiple style="width:600px;"></select>
+        placeholder="{'Type in a search term'|translate}"
+        data-default="{$STORAGE_ALBUM}" name="associate[]" multiple style="width:600px;"></select>
     </p>
 
@@ -117,4 +113,5 @@
       <br>
       <select data-selectize="categories" data-value="{$represented_albums|@json_encode|escape:html}"
+        placeholder="{'Type in a search term'|translate}"
         name="represent[]" multiple style="width:600px;"></select>
     </p>
@@ -124,5 +121,6 @@
       <br>
       <select data-selectize="tags" data-value="{$tag_selection|@json_encode|escape:html}"
-        name="tags[]" multiple style="width:600px;" data-selectize-create></select>
+        placeholder="{'Type in a search term'|translate}"
+        data-create="true" name="tags[]" multiple style="width:600px;"</select>
     </p>
 
Index: /trunk/admin/themes/default/template/user_list.tpl
===================================================================
--- /trunk/admin/themes/default/template/user_list.tpl	(revision 28554)
+++ /trunk/admin/themes/default/template/user_list.tpl	(revision 28555)
@@ -1105,5 +1105,6 @@
 
       <div class="userProperty"><strong>{'Groups'|translate}</strong><br>
-        <select data-selectize="groups" name="group_id[]" multiple style="width:340px;"></select>
+        <select data-selectize="groups" placeholder="{'Type in a search term'|translate}" 
+          name="group_id[]" multiple style="width:340px;"></select>
       </div>
     </div>
