Index: /extensions/Autosize/admin/admin_autosize.php
===================================================================
--- /extensions/Autosize/admin/admin_autosize.php	(revision 6977)
+++ /extensions/Autosize/admin/admin_autosize.php	(revision 6978)
@@ -37,4 +37,5 @@
 
 $my_base_url = get_admin_plugin_menu_link(__FILE__);
+
 
 
Index: /extensions/Autosize/admin/template/admin.tpl
===================================================================
--- /extensions/Autosize/admin/template/admin.tpl	(revision 6977)
+++ /extensions/Autosize/admin/template/admin.tpl	(revision 6978)
@@ -48,4 +48,9 @@
   {assign var="visible" value="none"}
 {/if}
+{if $check_auto_w == true} 
+     {assign var="visible_w" value="visible"}
+  {else}
+     {assign var="visible_w" value="hidden"}
+{/if}
 <div class="titrePage">
 		<h2>{'Autosize'|translate} {'version'|translate}{$version}</h2>
@@ -62,33 +67,37 @@
     <fieldset>
   	<legend class="cluetip" title="{'cl_autosize_config_title_1'|@translate}|{'cl_autosize_hlp_line1'|@translate}">{'cl_autosize_config_title_1'|@translate}</legend>
-        <td>{'User status'|@translate}</td><td>{'cl_autosize_height'|@translate}</td><td style="visibility:hidden">{'width'|@translate}</td>
+        <td>{'User status'|@translate}</td>
+        <td>{'cl_autosize_height'|@translate}</td>
+        <td style="visibility:visible">{'cl_autosize_width'|@translate}
+         <input type="checkbox" name="check_auto_w" value="on"  {$check_auto_w}  /></td>
         <tr>
         <td>{'user_status_webmaster'|@translate}</td>
         <td><input name="webmaster_height" id="Text7" type="text"  value ="{$webmaster_height}" /></td>
-        <td style="visibility:hidden"><input name="webmaster_width" id="Text8" type="text"  value ="{$webmaster_width}" /></td>
+        <td style="visibility:{$visible_w}"><input name="webmaster_width" id="Text8" type="text"  value ="{$webmaster_width}" /></td>
         </tr>
         <tr>
         <td>{'user_status_admin'|@translate}</td>
         <td><input name="admin_height" id="admin_height" type="text"  value ="{$admin_height}" /></td>
-        <td style="visibility:hidden"><input name="admin_width" id="admin_width" type="text"  value ="{$admin_width}" /></td>
+        <td style="visibility:{$visible_w}"><input name="admin_width" id="admin_width" type="text"  value ="{$admin_width}" /></td>
         </tr>
         <tr>
         <td>{'user_status_generic'|@translate}</td>
         <td><input name="generic_height" id="Text1" type="text"  value ="{$generic_height}" /></td>
-        <td style="visibility:hidden"><input name="generic_width" id="Text2" type="text"  value ="{$generic_width}" /></td>
+        <td style="visibility:{$visible_w}"><input name="generic_width" id="Text2" type="text"  value ="{$generic_width}" /></td>
         </tr>
         <tr>
         <td>{'user_status_guest'|@translate}</td>
         <td><input name="guest_height" id="Text3" type="text"  value ="{$guest_height}" /></td>
-        <td style="visibility:hidden"><input name="guest_width" id="Text4" type="text"  value ="{$guest_width}" /></td>
+        <td style="visibility:{$visible_w}"><input name="guest_width" id="Text4" type="text"  value ="{$guest_width}" /></td>
         </tr>
         <tr>
         <td>{'user_status_normal'|@translate}</td>
         <td><input name="normal_height" id="Text5" type="text"  value ="{$normal_height}" /></td>
-        <td style="visibility:hidden"><input name="normal_width" id="Text6" type="text"  value ="{$normal_width}" /></td>
+        <td style="visibility:{$visible_w}"><input name="normal_width" id="Text6" type="text"  value ="{$normal_width}" /></td>
         </tr>
 
   </fieldset>
   </table>
+
 <br />
  <table id="table_d" style=" background:none;border:outset;width:90%; z-index:-500 " >
Index: /extensions/Autosize/include/affiche.php
===================================================================
--- /extensions/Autosize/include/affiche.php	(revision 6977)
+++ /extensions/Autosize/include/affiche.php	(revision 6978)
@@ -5,6 +5,5 @@
 $img_height=isset($picture['current']['height'])?$picture['current']['height']:200;
 $version=isset($version)?$version:"";
-
-
+$theme=$user['theme'];
  $user_status = $user['status'] ;
 
@@ -14,4 +13,5 @@
                     'version' => $version,
                     'AUTOSIZE_PATH' => AUTOSIZE_PATH,
+                    'theme' => $theme,
 					 'SCALED_WIDTH' 				=> $picture['current']['scaled_width'],
 					 'SCALED_HEIGHT' 			=> $picture['current']['scaled_height'],                    
@@ -22,4 +22,5 @@
                     'MARGE_BASSE' => $autosize_parametres->marge_basse,
                     'ECHELLE_MAX' => $autosize_parametres->echelle_max,
+                    'check_auto_w' => ($autosize_parametres->check_auto_w == 'on') ? 'checked="checked"'  : '' ,
                     'webmaster_width' => $autosize_parametres->webmaster_width,
                     'webmaster_height' => $autosize_parametres->webmaster_height,
Index: /extensions/Autosize/js/Affiche_script.js
===================================================================
--- /extensions/Autosize/js/Affiche_script.js	(revision 6977)
+++ /extensions/Autosize/js/Affiche_script.js	(revision 6978)
@@ -1,10 +1,28 @@
 ﻿jQuery.noConflict();
 jQuery(document).ready(
+
+
 function (jQuery) {
+    function Marge_haute(myObj, ajoute_h) {
+        if (ajoute_h) h_p = parseInt(jQuery(myObj).height());
+        else h_p = 0;
+
+        if (jQuery(myObj).css("marginTop"))
+            if (jQuery(myObj).css("marginTop") != "auto") h_p += parseInt(jQuery(myObj).css("marginTop"));
+        if (jQuery(myObj).css("marginBottom"))
+            if (jQuery(myObj).css("marginBottom") != "auto") h_p += parseInt(jQuery(myObj).css("marginBottom"));
+        if (jQuery(myObj).css("paddingTop"))
+            if (jQuery(myObj).css("paddingTop") != "auto") h_p += parseInt(jQuery(myObj).css("paddingTop"));
+        if (parseInt(jQuery(myObj).css("paddingBottom")))
+            if (jQuery(myObj).css("paddingBottom") != "auto") h_p += parseInt(jQuery(myObj).css("paddingBottom"));
+        return h_p;
+    }
     //===================================================================	
+
 
 
     jQuery(window).resize(function (event, ui) {
         if (typeof (event) == 'undefined') return;
+
         var Type_Img = "";
         //====== détection du type d'images ======
@@ -22,9 +40,13 @@
             return;
         }
+
+
         //=================================================================
         switch (Type_Img) {
             case "img":
                 var Image = jQuery("#theImage").find("img");
-                var TheImg = jQuery(Image).get(0);
+                var TheImg = jQuery("#theImg").find("img").get(0);
+                if (!TheImg)
+                    TheImg = jQuery(Image).get(0);
                 break
             case "img_autre":
@@ -39,4 +61,5 @@
                 break
             case "pamoorama":
+                //=========================================================
                 var Images = jQuery("#pamoorama");
                 var Image = jQuery(Images).get(0);
@@ -44,4 +67,7 @@
                 var TheImg = jQuery("#pamoorama").get(0);
                 if (!TheImg) return;
+                TheImg = jQuery("#pamoorama_inner");
+                if (TheImg.length < 1) return;
+
                 break
         }
@@ -49,5 +75,17 @@
         //==================================================================================
         var sel0 = jQuery(TheImg).position();
+
         if (!sel0) return;
+        type_pos = jQuery(TheImg).css("position"); //static
+        if (jQuery(TheImg).css("position") == "relative") {
+            sel0.top += Marge_haute("#theHeader", true);
+            sel0.top += Marge_haute("#imageHeaderBar", true);
+            sel0.top += Marge_haute(TheImg, false);
+            if (jQuery("#theImage").css("marginTop"))
+                if (jQuery("#theImage").css("marginTop") != "auto") sel0.top += parseInt(jQuery("#theImage").css("marginTop"));
+            if (jQuery("#theImage").css("paddingTop"))
+                if (jQuery("#theImage").css("paddingTop") != "auto") sel0.top += parseInt(jQuery("#theImage").css("paddingTop"));
+
+        }
 
         mini_width = parseInt(mini_width);
@@ -81,12 +119,5 @@
             for (var i = 0; i < Pars.length; i++) {
                 P0 = Pars.get(i);
-                h_p += parseInt(jQuery(P0).height());
-             if (jQuery(P0).css("marginTop"))
-                    if (jQuery(P0).css("marginTop") != "auto") h_p += parseInt(jQuery(P0).css("marginTop"));
-             if (jQuery(P0).css("marginBottom"))
-                    if (jQuery(P0).css("marginBottom") != "auto") h_p += parseInt(jQuery(P0).css("marginBottom"));
-             if (jQuery(P0).css("paddingTop")) h_p += parseInt(jQuery(P0).css("paddingTop"));
-             if (parseInt(jQuery(P0).css("paddingBottom"))) h_p += parseInt(jQuery(P0).css("paddingBottom"));
-
+                h_p += Marge_haute(P0, true);
             }
 
@@ -101,5 +132,5 @@
         var Image_height = (winheight - sel0.top) - parseInt(marge_basse) - lmt;
         var height_user = eval(user_status + "_height");
-        var width_user = eval(user_status + "_width");
+
         //=============================================================
         var reg1 = new RegExp("%", "g");
@@ -108,5 +139,6 @@
         else
             Image_height = parseInt(height_user);
-        //=============================================================
+
+        //============================================================
         echelle_max = parseFloat(echelle_max, '3');
         var echelle = parseFloat(Image_height / H0, 3);
@@ -117,30 +149,78 @@
         }
 
-        var Imgage_Width = parseInt(Image_height * rapport);
-        jQuery("#theImage").width("100%");
-        jQuery("#theImage").height("auto");
-
-
+        var Image_Width = parseInt(Image_height * rapport);
+
+        //===============================================================
+        twidth = jQuery("#imageHeaderBar").width();
+        img_la = jQuery(TheImg).width(); //initiale 
+        offset = jQuery(TheImg).position();
+
+        var winwidth = jQuery(window).width();
+        var width_user = eval(user_status + "_width");
+         
+        if (check_auto_w == 'checked="checked"') {
+            if (Type_Img != "pamoorama") {
+                widthmin = (winwidth - offset.left);
+
+                if (Image_Width > widthmin) {
+                    //=============================================================
+                    if (width_user.match(reg1))
+                        Image_Width = Image_Width * parseInt(width_user) / 100;
+                    else
+                        Image_Width = parseInt(width_user);
+
+                    var echelle_w = parseFloat(winwidth / W0, 3);
+                    if (echelle_w > echelle_max) {
+                        echelle_w = echelle_max;
+                        Image_Width = parseInt(W0 * echelle_w);
+                    }
+                    Image_Width = parseInt(W0 * echelle_w);
+                     
+                    align_auto = "left";
+                } else {
+                    
+                    align_auto = "center";
+                }
+                Image_height = parseInt(Image_Width / rapport);
+
+            }
+
+
+        }
+        //=============================================================
 
         if (Type_Img == "pamoorama") {
-            h1 = jQuery("#pamoorama").height();
-            jQuery("#pamoorama").css("overflow", "hidden");
-            jQuery("#pamoorama").css(jQuery(window).width() + "px");
-  
+
+
+            jQuery("#pamoorama").css("height", Image_height + "px");
+            jQuery("#pamoorama").css("width", twidth + "px");
+
+            jQuery("#pamoorama").height(Image_height + "px");
+            jQuery("#pamoorama").width(twidth + "px");
+
+
+
+            jQuery("#pamoorama_outter").height(Image_height + "px");
+            jQuery("#pamoorama_outter").width(twidth + "px");
+
             jQuery("#pamoorama_outter").css("height", Image_height + "px");
-            jQuery("#pamoorama_outter").css("width", jQuery(window).width() + "px");
-/*
-            jQuery(TheImg).css(Image_height + "px");
-            jQuery(TheImg).css(jQuery(window).width() + "px");
-            */
+            jQuery("#pamoorama_outter").css("width", twidth + "px");
+
             zoom = Image_height / img_height;
 
-            jQuery("#pamoorama_inner").css("zoom", zoom);
+            h_frame = jQuery("#pamoorama_frame").height();
+            h_width = jQuery("#pamoorama_frame").width();
+            jQuery(TheImg).css("zoom", zoom);
 
 
 
         } else {
-        jQuery(TheImg).height(Image_height + "px");
-        jQuery(TheImg).width(Imgage_Width + "px");
+            if (jQuery("#theImg").css("textAlign"))
+                jQuery("#theImg").css("textAlign", align_auto);
+ 
+            jQuery(TheImg).height(Image_height + "px");
+            jQuery(TheImg).width(Image_Width + "px");
+            jQuery(TheImg).css("height", Image_height + "px");
+            jQuery(TheImg).css("width", Image_Width + "px");
 
         }
@@ -155,5 +235,7 @@
 
     //===================================================================	  
+
     jQuery(window).resize();
+
     jQuery(window).resize();
 
Index: /extensions/Autosize/main.inc.php
===================================================================
--- /extensions/Autosize/main.inc.php	(revision 6977)
+++ /extensions/Autosize/main.inc.php	(revision 6978)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: AutoSize
-Version: 1.0.6
+Version: 1.0.7
 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
@@ -22,5 +22,6 @@
     global $content, $element_info;   
     global $infos_message,$erreur_message;
-    global  $conf,$lang ;
+    global  $conf,$lang ,$user;
+
     if ( $page['body_id']=='thePicturePage'  ) {
    if ( isset($picture['current'])){
@@ -51,6 +52,7 @@
 function cl_autosize_aff_infos_plus()
 {
- global $template,$infos_message,$erreur_message, $user ;;
+ global $template,$infos_message,$erreur_message, $user ;
 global  $conf,$lang ;
+
  //==============================================================
   if (isset($erreur_message))
@@ -93,17 +95,17 @@
 //=============================================================================
 $autosize_parametres->webmaster_height =(isset($_POST['webmaster_height'])) ? $_POST['webmaster_height'] : ((isset($autosize_parametres->webmaster_height )) ? $autosize_parametres->webmaster_height : '100%' ) ;
-$autosize_parametres->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($autosize_parametres->webmaster_width)) ? $autosize_parametres->webmaster_width:  '100%') ;
+$autosize_parametres->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($autosize_parametres->webmaster_width)) ? $autosize_parametres->webmaster_width:  '90%') ;
 
-$autosize_parametres->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($autosize_parametres->admin_height )) ? $autosize_parametres->admin_height : '100%' ) ;
-$autosize_parametres->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($autosize_parametres->admin_width)) ? $autosize_parametres->admin_width:  '100%') ;
+$autosize_parametres->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($autosize_parametres->admin_height )) ? $autosize_parametres->admin_height : '90%' ) ;
+$autosize_parametres->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($autosize_parametres->admin_width)) ? $autosize_parametres->admin_width:  '90%') ;
 
-$autosize_parametres->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($autosize_parametres->generic_height )) ? $autosize_parametres->generic_height : '200px' ) ;
-$autosize_parametres->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($autosize_parametres->generic_width)) ? $autosize_parametres->generic_width:  '300px') ;
+$autosize_parametres->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($autosize_parametres->generic_height )) ? $autosize_parametres->generic_height : '100%' ) ;
+$autosize_parametres->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($autosize_parametres->generic_width)) ? $autosize_parametres->generic_width:  '90%') ;
 
-$autosize_parametres->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($autosize_parametres->guest_height )) ? $autosize_parametres->guest_height : '150px' ) ;
-$autosize_parametres->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($autosize_parametres->guest_width)) ? $autosize_parametres->guest_width:  '200px') ;
+$autosize_parametres->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($autosize_parametres->guest_height )) ? $autosize_parametres->guest_height : '100%' ) ;
+$autosize_parametres->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($autosize_parametres->guest_width)) ? $autosize_parametres->guest_width:  '90%') ;
 
-$autosize_parametres->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($autosize_parametres->normal_height )) ? $autosize_parametres->normal_height : '150px' ) ;
-$autosize_parametres->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($autosize_parametres->normal_width)) ? $autosize_parametres->normal_width:  '100px') ;
+$autosize_parametres->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($autosize_parametres->normal_height )) ? $autosize_parametres->normal_height : '100%' ) ;
+$autosize_parametres->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($autosize_parametres->normal_width)) ? $autosize_parametres->normal_width:  '90%') ;
 
 
@@ -113,9 +115,14 @@
 $autosize_parametres->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($autosize_parametres->echelle_max)) ? $autosize_parametres->echelle_max :  '1.2'); 
 $autosize_parametres->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($autosize_parametres->marge_basse)) ? $autosize_parametres->marge_basse :  '50');
-//==================================================================================
+//===============================================================================	
+
+if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') )  {  
+
+ 	$autosize_parametres->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ;
+	 }else{
+   $autosize_parametres->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : ( ( isset($autosize_parametres->check_auto_w) ) ? $autosize_parametres->check_auto_w :   'off') ; ;
+   }
 
 return $autosize_parametres;
-
-
 }
 //========================================================================	
Index: /extensions/Autosize/template/autosize.tpl
===================================================================
--- /extensions/Autosize/template/autosize.tpl	(revision 6977)
+++ /extensions/Autosize/template/autosize.tpl	(revision 6978)
@@ -20,9 +20,10 @@
         var generic_height='{ $generic_height   }';
         var guest_width='{ $guest_width   }';
-        var guest_height='{ $guest_height   }';
-        var normal_width='{ $normal_width   }';
-        var normal_height='{ $normal_height   }';
-        var user_status='{ $user_status   }';
-
+        var guest_height='{$guest_height}';
+        var normal_width='{$normal_width}';
+        var normal_height='{$normal_height}';
+        var user_status='{$user_status}';
+        var user_status = '{$user_status}';
+        var check_auto_w = '{$check_auto_w}';
      </script>
     <style type="text/css">
