Index: /extensions/Autosize/js/Affiche_script.js
===================================================================
--- /extensions/Autosize/js/Affiche_script.js	(revision 16609)
+++ /extensions/Autosize/js/Affiche_script.js	(revision 16610)
@@ -135,21 +135,14 @@
       theImg = this;
       name_src = theImg.src;
+      img_init.width = jQuery(this).width();
+      img_init.height = jQuery(this).height();
       if (theImg.naturalWidth)
         img_init.width = theImg.naturalWidth;
       if (theImg.naturalHeight)
         img_init.height = theImg.naturalHeight;
-
+      img_init.rapport = theImg.naturalWidth / theImg.naturalHeight;
+      nu_img = 0;
       theMainImage_obj = "#theMainImage";
-
-      nds = jQuery("#imageInfos").css("display"); //inline-block 
-      Zone_image = Calcul_Image(nds == "none");
-
-      jQuery("#theImage").width(Zone_image.container.width);
-      jQuery("#theImage").height(Zone_image.image.height + 5);
-
-      jQuery(theMainImage_obj).width(Zone_image.image.width);
-      jQuery(theMainImage_obj).height(Zone_image.image.height);
-
-
+      Autosize_resize(true);
     });
 
@@ -163,17 +156,34 @@
     // jQuery("#theImage").trigger("OK");
     jQuery("#theImage").live('Start_right', function (e) {
+      if (typeof Zone_image == "undefined") return
       if (nu_img == "") nu_img = 7;
       jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
       test_w = window.myPamoorama.autoSlideFx.to;
       test_w = window.myPamoorama.autoScrollFx.to;
-      jQuery("#pamoorama_thumb img").height(47);
+      nf = jQuery("#pamoorama_thumb").height();
+      jQuery("#pamoorama_thumb img").width(200);
+      jQuery("#pamoorama_thumb img").height(nf);
+      // 200=window.myPamoorama.imageWidth 
+      // frame = Zone_image.container.width
+
+      nw = (200 * Zone_image.container.width) / window.myPamoorama.imageWidth;
+      jQuery("#pamoorama_frame").width(nw);
+
+
+
     });
 
     jQuery("#theImage").live('Start_left', function (e) {
+      if (typeof Zone_image == "undefined") return
       if (nu_img == "") nu_img = 7;
       jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
       test_w = window.myPamoorama.autoSlideFx.to;
       test_w = window.myPamoorama.autoScrollFx.to;
-      jQuery("#pamoorama_thumb img").height(47);
+      nf = jQuery("#pamoorama_thumb").height();
+      jQuery("#pamoorama_thumb img").width(200);
+      jQuery("#pamoorama_thumb img").height(nf);
+
+      nw = (200 * Zone_image.container.width) / window.myPamoorama.imageWidth;
+      jQuery("#pamoorama_frame").width(nw);
 
     });
@@ -214,6 +224,7 @@
 
 
-    //=====================================================================
+    //===========================================
     // jQuery("#theImageAndInfos").trigger("ON");
+    //===========================================
     jQuery("#theImageAndInfos").live('ON', function (e) {
       infos_theImageAndInfos = jQuery("#theImageAndInfos").infos();
@@ -221,17 +232,18 @@
 
     }); // fin click #theImageAndInfos ON
-    //=====================================================================
-    jQuery("#infoSwitcher").click(function () {
-
+
+    //==========================================
+    //
+    //==========================================
+    jQuery("#infoSwitcher, #menuSwitcher").click(function () {
       jQuery("#llgbo").trigger("ON");
       jQuery("#theImage").css({ textAlign: "center" });
-
+      nu_img = 0;
+      theImage_init("#theImage");
       Autosize_resize(true);
-
     }); // fin click infoSwitcher
-    //====================================================
-
-    //piwigo 2.4
-    // Add another debug to the DOM 
+    //==================================
+    //
+    //===================================
     jQuery('#derivativeCheckedAutosize').click(function () {
       pathnames = jQuery(this).attr("href").split(":");
@@ -366,53 +378,21 @@
       if (chk == "") { return true; }
       //================================================================= 
-      var winwidth = jQuery(window).width();
-      var winheight = jQuery(window).height();
+      var winwidth = infos_body.width;
+      var winheight = infos_body.height;
       nds = jQuery("#imageInfos").css("display"); //inline-block //block simple
+      nds1 = jQuery("#menubar").css("display"); //inline
+      if (Type_Img == "pamoorama") {
+        theMainImage_obj = "#pamoorama";
+      }
       Zone_image = Calcul_Image(nds == "none");
-      //=============================================================
-      if (Type_Img == "pamoorama") {
-        theMainImage_obj = "#pamoorama"
-          Set_Pamoorama();
-
-      }
-      if (Type_Img == "map") {
-
-        Set_Map();
-
-      }
-
       //=================================================================
-      set_cl();
-      jQuery("#theImage").width(Zone_image.container.width);
-      jQuery("#theImage").height(Zone_image.container.height);
-      n = winwidth - old_window.width;
-      if (Math.abs(n) < 1) {
-        n = winheight - old_window.height;
-        if (Math.abs(n) < 1) {
-          return false;
-        }
-      }
-
-      if (Math.abs(n) > 30) nu_img = 0;
-      nu_img++;
-      if (nu_img > 10) return true;
-
       old_window = jQuery(window).infos();
       //========= Récupération des informations =============       
-
-
       var Licence = jQuery(".licencetag");
       infos_Licence = jQuery(".licencetag").infos();
-
-
       //=================================================================
-
       switch (Type_Img) {
         case "map":
-
           Set_Map(true);
-
-          ;
-
           break
         case "panorama":
@@ -432,5 +412,4 @@
           jQuery("#theImage").height(infos_theImage.height);
           img_finale.height = infos_theImage.height;
-
           break
         case "img":
@@ -482,5 +461,6 @@
           break
         case "charlie":
-          infos_theImage = infos_img;
+          img_reelle = { height: img_height, width: img_width };
+          infos_img = jQuery(theMainImage_obj).infos(); ;
           infos_the_page = jQuery("#the_page").infos();
           if (rapport < 0) {
@@ -498,5 +478,5 @@
           img_reelle.height = img_height;
           img_reelle.width = Zone_Affichage.width;
-          if (typeof myPamoorama != "undifened") theMainImage_obj = myPamoorama.image;
+          if (typeof myPamoorama != "undefined") theMainImage_obj = myPamoorama.image;
           infos_theImage = jQuery("#pamoorama").infos();
           infos_theImage.height = infos_theImage.height;
@@ -539,9 +519,4 @@
       if (img_reelle.height < parseInt(mini_height))
         return true;
-      //======================================================================
-      set_cl();
-      Set_Pamoorama();
-
-
 
       //=============== Zone d'affichage ============================  
@@ -565,11 +540,8 @@
         Zone_Affichage.width = mini_width2;
       //=================================================
-
-
-
-      //=============================================================
       var height_user = eval(user_status + "_height");
       var width_user = eval(user_status + "_width");
       var reg1 = new RegExp("%", "g");
+      //=============================================================     
       if (height_user.match(reg1))
         Image_height = img_reelle.height * parseInt(height_user) / 100;
@@ -582,9 +554,7 @@
 
       Image_height = parseInt(img_reelle.height * echelle);
-
-      var widthmin = winwidth;
+      Image_width = parseInt(img_reelle.width * echelle);
 
       if (check_auto_w == 'checked="checked"') {
-
         //==== largeur à atteindre ===
         var width_user = eval(user_status + "_width");
@@ -592,21 +562,22 @@
         if (width_user.match(reg1))
         // pourcentage
-          Image_width = widthmin * parseInt(width_user) / 100;
+          Image_width = Zone_image.container.width * parseInt(width_user) / 100;
         else
           Image_width = parseInt(width_user);
 
-      }
       Image_height = parseInt(Image_width / rapport);
+      } else {
       Image_width = parseInt(Image_height * rapport);
+      }
       //====================================================
       //  Zone_image.image.height = Image_height;
       //  Zone_image.image.width = Image_width;
-
+      //======================================================================
+      set_cl();
       Set_Pamoorama();
-      set_cl();
-      jQuery(theMainImage_obj).height(Zone_image.image.height);
       jQuery("#theImage").width(Zone_image.container.width);
       jQuery("#theImage").height(Zone_image.container.height);
-
+      jQuery(theMainImage_obj).height(Zone_image.image.height);
+      jQuery(theMainImage_obj).width(Zone_image.image.width);
       return true;
 
@@ -1132,5 +1103,5 @@
       });
       */
-      // jQuery(':Set_Class');
+      //=========================================================       
       if (typeof img_width == "undefined") {
         if (List_autosize.length == 0) return;
@@ -1139,9 +1110,4 @@
         return true;
       }
-      //=========================================================         
-
-
-
-
       //============================================================
       Autosize_init();
@@ -1149,10 +1115,6 @@
       if (typeof Bandeau_bas != "undefined") Bandeau = Bandeau_bas.top;
       else Bandeau = 0;
-
-      theMainImage_obj = theMainImage_obj;
       Wait_Affichage();
       Autosize_resize(true, { id_map: "autosize" });
-
-
     }); // window.onload
     /***********************************************************
@@ -1848,10 +1810,12 @@
         tw = jQuery(window).width();
 
+        th = infos_body.height;
+        tw = infos_body.width;
+
         nds = jQuery("#imageInfos").css("display"); //inline-block 
-        Zone_image = Calcul_Image(false);
+        Zone_image = Calcul_Image(nds == "none");
         n0 = 0;
         n1 = 0;
         t0 = 0;
-        th = th - Zone_image.top;
         tw = Zone_image.container.width;
         th = Zone_image.container.height;
@@ -2010,5 +1974,4 @@
 
 
-
         window.myPamoorama.outter.scrollTo(new_max_left, 0);
 
@@ -2017,5 +1980,15 @@
         window.myPamoorama.imageWidth = new_image.width;
         window.myPamoorama.imageHeight = new_image.height;
-
+        nf = jQuery("#pamoorama_thumb").height();
+        jQuery("#pamoorama_thumb img").width(200);
+        jQuery("#pamoorama_thumb img").height(nf);
+        // 200=window.myPamoorama.width 
+        // frame = Zone_image.container.width
+
+        nw = (window.myPamoorama.image.width * Zone_image.container.width) / window.myPamoorama.imageWidth;
+        jQuery("#pamoorama_frame").width(nw);
+        jQuery("#pamoorama").css({
+        width:"auto",height:"auto"
+      });
 
       } // test img
@@ -2047,5 +2020,5 @@
         src_infos_1 = src5;
       }
-      jQuery("#theMainImage").height(jQuery("#theMainImage").width() / rapport);
+
       Zone_image.zoom = (Zone_image.image.height / Zone_image.height_init);
       zoom_cl = parseInt(100 * Zone_image.zoom);
@@ -2114,4 +2087,5 @@
                                 + infos_theImage.padding.right);
 
+
       retrait_w += Math.ceil(infos_the_page.margin.left
                                 + infos_the_page.margin.right
@@ -2124,4 +2098,6 @@
                                 infos_body.margin.right);
 
+      retrait_w += Math.ceil(infos_content.margin.left +
+                                infos_content.margin.right);
 
 
@@ -2152,7 +2128,12 @@
       retrait_img += Math.ceil(infos_llgbo.borderwidth.right + infos_llgbo.borderwidth.right);
 
+
+
+
+      //  menuSwitcherwidth+padding
+
       if (theme.match(RegExp("elegant", "gi"))) {
         if (all_width != true) {
-          new_width = Math.ceil(8 +
+          new_width = Math.ceil(
                                 infos_imageInfos.width +
                                 infos_imageInfos.borderwidth.left +
@@ -2162,8 +2143,9 @@
                                 infos_imageInfos.padding.left +
                                 infos_imageInfos.padding.right);
+     
         } else {
           new_width = 0;
         }
-        width_theImage = (jQuery(window).width() - new_width)
+        width_theImage = (infos_body.width - new_width)
 
       } else if (theme.match(RegExp("stripped", "gi"))) {
@@ -2174,5 +2156,5 @@
 
       } else {
-        width_theImage = (jQuery(window).width());
+        width_theImage = (infos_body.width);
       }
 
@@ -2190,4 +2172,5 @@
       retrait_h += (b * 2) - 5;
       retrait_img += 5;
+      retrait_w += 20; //???
 
       height_theImage = jQuery(window).height() - retrait_h;
@@ -2256,62 +2239,4 @@
     }
 
-
-    /**************************************************
-    *  onProperty
-    **************************************************/
-    onPropertyChange = function (e, obj) {
-      var el = obj;
-      attributs = el.attributes;
-      type_action = e.type;
-      style = "";
-      alt = "";
-      src = "";
-
-      if (attributs.id) id = attributs.id.value;
-      if (attributs.style) style = attributs.style.value;
-      if (attributs.alt) alt = attributs.alt.value;
-      /* Image */
-      if (attributs.src) {
-        src = attributs.src.value;
-        if (attributs.width) width = attributs.width.value;
-        if (attributs.height) height = attributs.height.value;
-      }
-      affiche_debug({
-        Debug1: Debug_info(1, type_action + " : " + src, id + " action ")
-
-      });
-
-
-      if (style)
-        switch (style) {
-        case "style.opacity":
-
-          break;
-        case "style.transform":
-
-          break;
-        case "style.display":
-
-          break;
-        case "style.color":
-
-          break;
-        case "style.width":
-          width = el.style.width;
-          break;
-        case "style.height":
-          height = el.style.height;
-          break;
-
-        case 'width':
-
-          break;
-        case 'height':
-
-          el.style.height = el.attributes.height.nodeValue + 'px';
-          el.firstChild.style.height = el.clientHeight + 'px';
-          break;
-      }
-    }
 
 
@@ -2498,20 +2423,18 @@
   * TEST
   **************************************************/
+
+  jQuery(document).ready(function () {
   /*
-  var y = 3; 
-  var txtTestBox = document.getElementById('testBox');
-  XBrowserAddHandler(txtTestBox, 'keyup', function() {
-  myFunctionRef(y) 
+    var txtTestBox = document.getElementById('menubar');
+    XBrowserAddHandler(txtTestBox, 'propertychange', function () {
+      onPropertyChange(txtTestBox);
   });
-  var myFunctionRef = function myFunction(x, e) {
-  var keyCode; 
-  if (!e && window.event)
-  e = window.event; 
-  if (e)
-  keyCode = (window.Event) ? e.which : e.keyCode; 
-  alert('You pressed: ' + keyCode + '. Event object is :' + e + '. x is: ' + x);
-  }
-
-  */
+   var txtTestBox2 = document.getElementById('imageInfos');
+   XBrowserAddHandler(txtTestBox2, 'propertychange', function () {
+      onPropertyChange(txtTestBox2);
+    });
+*/
+
+    /**/
   /**************************************************
   * XBrowserAddHandler
@@ -2524,5 +2447,74 @@
     else
       target["on" + eventName] = handlerName;
+
+    }
+
+    /**************************************************
+    *  onProperty
+    **************************************************/
+    function onPropertyChange(obj,e) {
+      if (!e && window.event)
+        e = window.event;
+      if (e)
+        keyCode = (window.Event) ? e.which : e.keyCode;     
+      var el = obj;
+      attributs = el.attributes;     
+      type_action = e.type;
+      style = "";
+      alt = "";
+      src = "";
+      if (attributs.id) id = attributs.id.value;
+      if (attributs.style) style = attributs.style.value;
+      if (attributs.alt) alt = attributs.alt.value;
+      /* Image */
+      if (attributs.src) {
+        src = attributs.src.value;
+        if (attributs.width) width = attributs.width.value;
+        if (attributs.height) height = attributs.height.value;
+      }
+      affiche_debug({
+        Debug1: Debug_info(1, type_action + " : " + src, id + " action ")
+
+      });
+
+
+      if (style)
+        switch (style) {
+        case "style.opacity":
+
+          break;
+        case "style.transform":
+
+          break;
+        case "style.display":
+
+          break;
+        case "style.color":
+
+          break;
+        case "style.width":
+          width = el.style.width;
+          break;
+        case "style.height":
+          height = el.style.height;
+          break;
+
+        case 'width':
+
+          break;
+        case 'height':
+
+          el.style.height = el.attributes.height.nodeValue + 'px';
+          el.firstChild.style.height = el.clientHeight + 'px';
+          break;
   }
+    }
+
+
+    /**************************************************
+    * TEST
+    **************************************************/
+
+  });
 
   /********************************************************
@@ -2541,2 +2533,3 @@
   }
 
+  /**/
