Index: /extensions/Autosize/admin/template/admin.tpl
===================================================================
--- /extensions/Autosize/admin/template/admin.tpl	(revision 18233)
+++ /extensions/Autosize/admin/template/admin.tpl	(revision 18234)
@@ -6,6 +6,23 @@
 <style type="text/css">
 .td_autosize {
-  width: 25%;
-  font-style: italic;  
+  font-weight: bold;  
+  background-color:transparent;
+  border:none;
+  padding-right:10px;
+}
+
+.sizeForUserStatus, .autosizeConfig {
+  margin:0;
+  background:none;
+  z-index:-500;
+}
+
+.autosizeConfig .cluetip {
+  font-weight:bold;
+  padding-right:10px;
+}
+
+.autosizeConfig input[type="text"] {
+  width:50px;
 }
 </style>
@@ -87,21 +104,18 @@
 		<h2>{'Autosize'|translate} {'version'|translate} {$cl_version}</h2>
 </div>
-  <span>{'cl_autosize_Howto'|translate}</span>
-
-
 
 <!--============== !DIV ==={$IMG_WIDTH  }=={$IMG_HEIGHT  }======-->	
-<table >
   <form action="" method="post" name="form_autosize" id="form_autosize"    >
 
-  <table id="table0" style=" background:none;border:outset;width:90%; z-index:-500 " >
     <fieldset>
   	<legend class="cluetip" title="{'cl_autosize_config_title_1'|@translate}|{'cl_autosize_hlp_line1'|@translate}">{'cl_autosize_config_title_1'|@translate}</legend>
+  <table class="sizeForUserStatus">
+        <tr>
         <td class="td_autosize pluginBox">{'User status'|@translate}</td>
          <td class="td_autosize pluginBox">{'Photo sizes'|@translate}</td>        
-         <td class="td_autosize pluginBox">{'cl_autosize_enabled'|@translate}</td>
+        </tr>
         <tr name="webmaster_enabled">
 
-        <td>{'user_status_webmaster'|@translate}</td>
+        <td><label><input name="webmaster_enabled" id="webmaster_enabled" type="checkbox"  value ="on" {$webmaster_enabled}  /> {'user_status_webmaster'|@translate}</label></td>
          <td> 
          {if isset ($webmaster_type)}
@@ -113,9 +127,8 @@
         {/if}
       </td>
-         <td ><input name="webmaster_enabled" id="webmaster_enabled" type="checkbox"  value ="on" {$webmaster_enabled}  /></td>
         </tr>
 
         <tr name="admin_enabled">
-        <td>{'user_status_admin'|@translate}</td>
+        <td><label><input name="admin_enabled" id="admin_enabled" type="checkbox"  value ="on" {$admin_enabled} /> {'user_status_admin'|@translate}</label></td>
         <td> {if isset ($admin_type)}
           <select name="admin_type">
@@ -126,8 +139,8 @@
         {/if}
         </td>
-         <td ><input name="admin_enabled" id="admin_enabled" type="checkbox"  value ="on" {$admin_enabled} /></td>
-        </tr>
+        </tr>
+
         <tr name="generic_enabled">
-        <td>{'user_status_generic'|@translate}</td>
+        <td><label><input name="generic_enabled" id="generic_enabled" type="checkbox"  value ="on" {$generic_enabled} /> {'user_status_generic'|@translate}</label></td>
         <td>{if isset ($generic_type)}
           <select name="generic_type">
@@ -138,8 +151,9 @@
         {/if}
         </td>
-         <td ><input name="generic_enabled" id="generic_enabled" type="checkbox"  value ="on" {$generic_enabled} /></td>
-        </tr>
+         <td ></td>
+        </tr>
+
         <tr name="guest_enabled">
-        <td>{'user_status_guest'|@translate}</td>
+        <td><label><input name="guest_enabled" id="guest_enabled" type="checkbox"  value ="on" {$guest_enabled} /> {'user_status_guest'|@translate}</label></td>
         <td>{if isset ($guest_type)}
           <select name="guest_type">
@@ -149,8 +163,8 @@
         </select>
         {/if}</td>
-         <td ><input name="guest_enabled" id="guest_enabled" type="checkbox"  value ="on" {$guest_enabled} /></td>
-        </tr>
+        </tr>
+
         <tr name="normal_enabled">
-        <td>{'user_status_normal'|@translate}</td>
+        <td><label><input name="normal_enabled" id="normal_enabled" type="checkbox"  value ="on" {$normal_enabled} /> {'user_status_normal'|@translate}</label></td>
         <td>{if isset ($normal_type)}
           <select name="normal_type">
@@ -160,15 +174,13 @@
         </select>
         {/if}</td>
-         <td ><input name="normal_enabled" id="normal_enabled" type="checkbox"  value ="on" {$normal_enabled} /></td>
-        </tr>
+        </tr>
+  </table>
 
   </fieldset>
 
-  </table>
-
-<br />
- <table id="table_d" style=" background:none;border:outset;width:90%; z-index:-500 " >
+
    <fieldset>
   	<legend class="cluetip" title="{'cl_autosize_config_title_2'|@translate}|{'cl_autosize_hlp_line2'|@translate}">{'cl_autosize_config_title_2'|@translate}</legend>
+ <table class="autosizeConfig">
 
     <!--======== Dimensions HL ===================-->	
@@ -176,10 +188,13 @@
       <td class="cluetip" title="{'cl_autosize_miniheight'|@translate}|{'cl_autosize_hlp_line3'|@translate}" >{'cl_autosize_miniheight'|translate}</td>
       <td ><input name="mini_height" id="mini_height" type="text"  value ="{$MINI_HEIGHT}" /> px 
-           </td> 
-	 
-     <td class="cluetip" title="{'cl_autosize_miniwidth'|translate}|{'cl_autosize_hlp_line3'|@translate}"  > {'cl_autosize_miniwidth'|translate}</td>
-   <td  >
-    <input name="mini_width"  id="mini_width" type="text" value =  "{$MINI_WIDTH}" /> px
-       </tr>
+      </td> 
+    </tr>
+    <tr>
+      <td class="cluetip" title="{'cl_autosize_miniwidth'|translate}|{'cl_autosize_hlp_line3'|@translate}"  > {'cl_autosize_miniwidth'|translate}</td>
+      <td>
+        <input name="mini_width"  id="mini_width" type="text" value =  "{$MINI_WIDTH}" /> px
+      </td>
+    </tr>
+
     <!--======== Dimensions HL2 ===================-->	
     <tr> 
@@ -187,4 +202,6 @@
       <td ><input name="mini_height2" id="Text2" type="text"  value ="{$MINI_HEIGHT2}" /> px 
            </td> 
+    </tr>
+    <tr>
 	 
      <td class="cluetip" title="{'cl_autosize_miniwidth2'|translate}|{'cl_autosize_hlp_line32'|@translate}"  > {'cl_autosize_miniwidth2'|translate}</td>
@@ -211,32 +228,23 @@
 
 </tr>	
-  <!--======================================================================================-->	
-     <tr >
-	 
-	 </tr>
-
-
-  </fieldset>
  </table>
- <!--=================== Bloc choix =============================-->	 
- <table>
-  <tr><td style="visibility:visible">{'cl_autosize_icon_view'|@translate}
-         <input type="checkbox" name="check_icon_v" value="on"  {$check_icon_v}  />
-  </td>
-  <td>{'cl_autosize_desc_view'|@translate}
-         <input type="checkbox" name="check_desc_v" value="on"  {$check_desc_v}  />
-  </td>
-  <td>
-  </td>
-  
-  </tr>
-</table>
- 
-  <table>
-  <td><input name="submit" type="submit" value="{'cl_autosize_save'|@translate}" /></td>
-</table> 
+</fieldset>
+
+<fieldset>
+  <legend>{'Options'|@translate}</legend>
+
+  <label>
+    <input type="checkbox" name="check_icon_v" value="on"  {$check_icon_v}  />
+    {'cl_autosize_icon_view'|@translate}
+  </label>
+  <br>
+  <label>
+    <input type="checkbox" name="check_desc_v" value="on"  {$check_desc_v}  />
+    {'cl_autosize_desc_view'|@translate}
+  </label>
+</fieldset>
+
+<p class="formButtons">
+  <input type="submit" name="submit" value="{'cl_autosize_save'|@translate}">
+</p>
 </form>
- 
- </table >                
- 
- 
Index: /extensions/Autosize/autosize.inc.php
===================================================================
--- /extensions/Autosize/autosize.inc.php	(revision 18233)
+++ /extensions/Autosize/autosize.inc.php	(revision 18234)
@@ -38,11 +38,15 @@
  global  $template,$version,$icon_path,$page,$picture,$conf;
   
-$current = $template->get_template_vars('current');  
+  $current = $template->get_template_vars('current');  
   $has_pamoorama=isset($template->files['pamooramics_content']);
 //====================================================================    
-$pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']); 
-$SRC_IMG=""; 
-if(isset($current['derivatives']['Autosize']))
-    $_COOKIE['picture_deriv']="Autosize";
+  $pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']); 
+  $default_size =  $conf['derivative_default_size'];
+  $SRC_IMG=""; 
+//=====================================================================
+if(!isset($_COOKIE['picture_deriv']))
+    if(isset($current['derivatives']['Autosize']))
+        $_COOKIE['picture_deriv']="Autosize";
+
 if(isset( $_COOKIE['picture_deriv']))
   $model=  $_COOKIE['picture_deriv'] ;
@@ -50,12 +54,16 @@
   $model= $pictureDeriv ;
 
+ if(!isset($current['derivatives'][$model]))
+   $model=$default_size ;
+
 $selected_derivative =  $current['derivatives'][$model];
+
+
 if (!isset($current['selected_derivative'])){  
-  $_COOKIE['picture_deriv']="Autosize";
-  $model=  $_COOKIE['picture_deriv'] ;
-  $current['SelMaxi']=ImageStdParams::get_custom(900,900); 
-  $current['derivatives'][$model]=ImageStdParams::get_custom($_COOKIE['theImageWidth'], $_COOKIE['theImageHeight']); 
-  $selected_derivative=$current['derivatives'][$model];
-  $selected_derivative->type="Autosize";
+
+  $current['SelMaxi'] = ImageStdParams::get_custom(900,900); 
+  $selected_derivative = ImageStdParams::get_custom($_COOKIE['theImageWidth'], $_COOKIE['theImageHeight']); 
+ 
+  $selected_derivative->type=$model;
   $template->append('current', array(
                                 'selected_derivative' => $selected_derivative
@@ -63,4 +71,5 @@
                       true);
   $current = $template->get_template_vars('current');
+   
   }
  
@@ -138,5 +147,5 @@
       
     }else{
-        $model=$conf['derivative_default_size'] ;  
+        $model=$conf['derivative_default_size'] ;  // format par défaut
     }
     $derivative=$current['derivatives'][$model] ;  
@@ -150,5 +159,5 @@
      $window_width=$imgSizeWH[0];
      $window_height=$imgSizeWH[1];
- //echo "<div style='background-color:black;color:white' >INIT: $model  w:$window_width x  h:$window_height  </div>";
+
 
    
@@ -159,15 +168,15 @@
 if (!isset($_COOKIE['theMainImageWidth']))  setcookie('theMainImageWidth',$window_width); 
 
-//echo "<div style='background-color:black;color:white' >$select_type w: $window_width x h: $window_height  </div>";
-
-    $last_defined=ImageStdParams::get_defined_type_map();    
-
+//
+
+    $last_defined=ImageStdParams::get_defined_type_map();  
     foreach ($img_all as $img_select){
             $img_type  =  $img_select->get_type();	
             if ($img_type=="square" || $img_type=="thumb" ) continue ;
-            if (!isset($last_img)) $last_img=$img_select; 
+            if (!isset($last_img)) $last_img = $img_select; 
            
             $img_url  = $img_select->get_url();
             $imgSizeWH  =  $img_select->get_size();	
+       
 
             if($img_type=="Autosize" || $img_type=="SelMaxi"){
@@ -175,17 +184,8 @@
                 $imgSizeWH  =  $img_select->src_image->get_size();
                 $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
-            }else{ 
+
+            } 
               $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
-              if ($img_type=="Original"){    
-                          $maxi_img=  $img_type;
-                          $maxi_url= $img_url;
-                          $maxi_i=$img_select;      
-                break ;
-
-
-            }
-            
-               
-
+ 
               if($window_height < $imgSizeWH[0] ){
                           $maxi_img=  $img_type;
@@ -193,54 +193,51 @@
                           $maxi_i=$img_select;
               }
+
               if($window_height < $imgSizeWH[0] && $mini_img==""){ 
                       $mini_img=  $img_type;
                       $mini_url= $img_url;
                       $mini_i=$img_select;
-                      
-                 }else if($imgSizeWH[0] > 10 && $maxi_img==""){ 
-                      $last_img=$img_select;
-              }
-
- 
-               if($select_type==$img_type){ 
+                 }
+
+               if($select_type == $img_type){ 
                   if($maxi_img==""){
-                      $maxi_img=  $img_type;
-                      $maxi_url= $img_url;
-                      $maxi_i=$img_select;
-                  }
-                     
-                      break ;
-                    }
-         }
-
+                      $maxi_img =  $img_type;
+                      $maxi_url =  $img_url;
+                      $maxi_i   = $img_select;
+                  } 
+                  if($mini_img==""){
+                      $mini_img=  $img_type;
+                      $mini_url= $img_url;
+                      $mini_i=$img_select;
+                  }                    
+               break ;
+                }
       }
-  
 //==============================================================    
   //==== Réécriture selection ====
   if( $img_type=="SelMaxi"){
-  $maxi_img= $mini_img;
-  $maxi_url= $mini_img;
+      $maxi_img= $mini_img;
+      $maxi_url= $mini_img;
   }
   if ( !array_key_exists($maxi_img, $last_defined) ){
+   
             $maxi_img = $last_img->get_type();	 
             $maxi_url  = $last_img->get_url();
             $imgSizeWH  =  $last_img->get_size();	
+ 
   }
-    $model= $maxi_img;
-    pwg_set_session_var('picture_deriv', $maxi_img);
-    $_COOKIE['picture_deriv']=$maxi_img ;
+ $model= $maxi_img;
+   
+  /*  $_COOKIE['picture_deriv']=$maxi_img ;
     $_COOKIE['picture_map']=  $maxi_img ;
     $_COOKIE['imgSrc']=       $maxi_url;
-
+   */
   if (isset($_COOKIE['picture_deriv'])){    
       if ( array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map()) ){
-            pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
+   //         pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
         }else{
-       /* echo "<pre>".$_COOKIE['picture_deriv']. "No exist  " ;
-        print_r($img_all );
-        die();
-        */
+     //       pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
         }
-    setcookie('picture_deriv', false, 0, cookie_path() );
+  //  setcookie('picture_deriv', false, 0, cookie_path() );
   }  
 
@@ -254,11 +251,12 @@
 *************************/	
 	static public function cl_autosize_affiche(){
-		global $user, $picture, $template,$page,$known_script;
-		global $content, $element_info;   
-		global $infos_message,$erreur_message;
-		global  $conf,$lang ,$user,$userdata;
-      global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type;
-  global  $has_pamoorama;
-  global $autosize_parametres,$user_status;
+    global $user, $picture, $template,$page,$known_script;
+    global $content, $element_info;   
+    global $infos_message,$erreur_message;
+    global  $conf,$lang ,$user,$userdata;
+    global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type;
+    global  $has_pamoorama;
+    global $autosize_parametres,$user_status;
+  
 
     if(isset($page['body_id']) &&	$page['body_id'] == 'theAdminPage' ) return ;   
@@ -270,5 +268,4 @@
 		$AUTOSIZE_PATH = dirname(__FILE__).'/';
 		 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage'  ) {
-
 			if ( isset($picture['current'])){	
 				include (AUTOSIZE_PATH."include/affiche.php"); 
@@ -285,8 +282,7 @@
         $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ;
         $template->set_filenames(array('autosize_init_header'=> $file ));
-        $template->parse( 'autosize_init_header', false);      
-
-        	$theme=$user['theme'];  
-                         		
+        $template->parse( 'autosize_init_header', false);  
+        $theme=$user['theme'];  
+                      		
 				if($autosize_parametres->check_icon_v == 'on'){				 
 						$template->assign('cl_autosize_button', 
@@ -308,6 +304,5 @@
              'theme' => $theme   )
 					);
-			$template->concat('autosize_content', $template->parse('autosize_content_header', true));	
-      	
+			$template->concat('autosize_content', $template->parse('autosize_content_header', true));	 	
       if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){
         $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') );
Index: /extensions/Autosize/js/Affiche_script.js
===================================================================
--- /extensions/Autosize/js/Affiche_script.js	(revision 18233)
+++ /extensions/Autosize/js/Affiche_script.js	(revision 18234)
@@ -443,5 +443,5 @@
       marges_llgbo = 0;
       //========================================================================================== 
-       
+
       init_gen();
       jQuery(window).resize();
@@ -511,4 +511,5 @@
     jQuery("#form_autosize_picture").addClass("Autosize_margin");
     //===== marges suplémentaires en fonction theme ===
+    options.valide = jQuery(".Autosize_margin").css("display");
     options.marge_haute = jQuery(".Autosize_margin").Get_Val_int(jQuery(".Autosize_margin").css("top"));
     options.marge_basse = jQuery(".Autosize_margin").Get_Val_int(jQuery(".Autosize_margin").css("bottom"));
@@ -551,4 +552,10 @@
     var pictureDeriv_maxi = eval("options." + user_status + "_type"); //limite taille
 
+    if (pictureDeriv_maxi != pictureDeriv) {
+      if (pictureDeriv == null)
+        pictureDeriv = pictureDeriv_maxi;
+      else
+        pictureDeriv_maxi = pictureDeriv;
+    }
 
 
@@ -919,4 +926,5 @@
         theImg.removeAttribute("width");
         theImg.removeAttribute("height");
+
         // jQuery(theMainImage_id).eq(0).removeAttr("style");
         jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
@@ -933,6 +941,11 @@
           jQuery("#loading").hide(0);
         }
-        Zone_image.src = theImg.src;
-        theImg.src = url; // charge Image       
+
+        theImg.src = url; // charge Image   
+        if (Zone_image) {
+          Zone_image.src = theImg.src;
+          Zone_image.image_init = { width: jQuery(theImg).width(), height: jQuery(theImg).height() };
+
+        }
         //===================================================
         options.pictureDeriv = typeSave;
@@ -1296,4 +1309,9 @@
           vn = this;
           size_derive = { w: parseInt(vn[2]), h: parseInt(vn[3]) };
+          if (vn[0] == options.select_type) {
+            maxi_size = size_derive;
+            maxi_size.idx = n;
+            return false
+          }
           if (vn[0] != "square" && vn[0] != "thumb" && vn[0] != "SelMaxi" && vn[0] != "Autosize") {
             if (size_derive.h > size_encours.h) {
@@ -1330,4 +1348,5 @@
 
     Select_Image = function () {
+
       var pt = options.liste_type;
       if (pt.length > 0) {
@@ -1335,5 +1354,13 @@
         //===== calcul Image ===
         Calcul_Image();
-        IMg = Get_Maxi(Zone_image.image);
+
+        if (options.select_type != "SelMaxi" && options.select_type != "Autosize") {
+         
+           IMg = Get_Maxi(Zone_image.image_init);
+        } else {
+          IMg = Get_Maxi(Zone_image.image);
+        }
+
+
         imgSrc = IMg.url;
 
@@ -1341,5 +1368,6 @@
         ing_height = IMg.height;
         if (Type_Img == "pamoorama") return;
-        if (options.select_type != "SelMaxi" && options.select_type != "Autosize") return;
+        //  if (options.select_type != "SelMaxi" && options.select_type != "Autosize") return;
+
         if (typeof Zone_image.src == "undefined") Zone_image.src = " ";
         status = imgSrc.match(RegExp(Zone_image.src, "gi")); // status = '' si ==
@@ -1614,4 +1642,7 @@
       height_theMainImage = Math.ceil(image_max.height);
       width_theMainImage = Math.ceil(image_max.width);
+      if (typeof Zone_image.image_init.rapport == "undefined") {
+        Zone_image.image_init.rapport = Math.ceil(width_theMainImage) / height_theMainImage;
+      }
 
       if (Type_Img == "pamoorama") {
@@ -1870,9 +1901,13 @@
         height = IMg.height;
       }
-      user_status = options.user_status;
-      pictureDeriv_maxi = eval("options." + user_status + "_type"); //limite taille
-      options.pictureDeriv_maxi = pictureDeriv_maxi;
-      pictureDeriv_maxi = options.select_type;
-
+      if (pictureDeriv_maxi != options.select_type) {
+        /*
+        user_status = options.user_status;
+        pictureDeriv_maxi = eval("options." + user_status + "_type"); //limite taille
+        */
+        options.select_type = pictureDeriv_maxi;
+        options.pictureDeriv_maxi = pictureDeriv_maxi;
+        pictureDeriv_maxi = options.select_type;
+      }
       //==========================================================
       href_path = "javascript:changeImgSrc('" + options.src_img + "', '" + "SelMaxi" + "', '" + "SelMaxi" + "')";
@@ -1957,5 +1992,5 @@
     //_______________________ init_gen _______________________
 
-  });                                                                                                                                                                                                                                          // ready
+  });                                                                                                                                                                                                                                                      // ready
 
 
Index: /extensions/Autosize/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/Autosize/language/fr_FR/plugin.lang.php	(revision 18233)
+++ /extensions/Autosize/language/fr_FR/plugin.lang.php	(revision 18234)
@@ -36,6 +36,6 @@
 $lang['cl_autosize_hlp_line4'] = "Valeur maximale d'agrandissement(photo réelle/photo affichée) supportée sans dégradation visuelle.";  
  
-$lang['cl_autosize_marge_basse'] = "Marge inférieure.";
-$lang['cl_autosize_hlp_line5'] = "Réserve inférieure, pour afficher la légende"; 
+$lang['cl_autosize_marge_basse'] = "Marges.";
+$lang['cl_autosize_hlp_line5'] = "Utiliser la classe<br/><span style='color:#80a080;'> .Autosize_margin{left:0px;right:0px;bottom:0px;top:0px} </span>en éditant le CSS(LocalFileEditor) du theme voulu"; 
 
 $lang['cl_autosize_save'] = "Sauvegarde";
Index: /extensions/Autosize/main.inc.php
===================================================================
--- /extensions/Autosize/main.inc.php	(revision 18233)
+++ /extensions/Autosize/main.inc.php	(revision 18234)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: AutoSize
-Version: 2.08
+Version: 2.0.9
 Description: Ajuste l'affichage des photos en fonction de la hauteur de la fenetre de navigation
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=448
