Index: /extensions/Autosize/js/Affiche_script.js
===================================================================
--- /extensions/Autosize/js/Affiche_script.js	(revision 18940)
+++ /extensions/Autosize/js/Affiche_script.js	(revision 18941)
@@ -338,5 +338,5 @@
 
             imgSrc = options.imgSrc;
-            n = this.src;
+
 
           });
@@ -471,5 +471,5 @@
     ********************************************/
     jQuery(window).unload(function () {
-    //  return;
+      //  return;
     });
     //_________ unload ___________
@@ -566,40 +566,4 @@
 
 
-
-    jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
-    jQuery('#derivativeChecked' + options.pictureSelType).css('visibility', 'visible');
-    //======================================================================================
-    href_path = "javascript:changeImgSrc('" + options.imgSrc + "', '" + options.pictureDeriv + "', '" + options.pictureDeriv + "', '" + "SelMaxi" + "')";
-
-    /*   */
-    //  jQuery('#derivativeCheckedSelMaxi').hide();
-    jQuery('#derivativeCheckedSelMaxi').next().show();
-    jQuery('#derivativeCheckedSelMaxi').next().next().show();
-
-    spans = jQuery("#derivativeCheckedSelMaxi").next();
-    spans.attr("href", href_path);
-    spans.attr("name", "SelMaxi");
-
-    spans = spans.find("span");
-    spans.attr("name", "SelMaxi");
-    spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")");
-    spans = spans.find("span");
-    spans.text(options.pictureDeriv);
-    //==========================================================
-    href_path = "javascript:changeImgSrc('" + options.imgSrc + "', '" + options.pictureDeriv + "', '" + options.pictureDeriv + "', '" + "Autosize" + "')";
-
-    spans = jQuery("#derivativeCheckedAutosize").next();
-    spans.attr("href", href_path);
-    spans.attr("name", "Autosize");
-    spans = spans.find("span");
-    spans.attr("name", "Autosize");
-    spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")");
-    spans.next().text(options.pictureDeriv);
-    //==========================================================
-    /*
-    jQuery('#derivativeCheckedAutosize').hide();
-    jQuery('#derivativeCheckedAutosize').next().hide();
-    jQuery('#derivativeCheckedAutosize').next().next().hide();
-    */
     //=============================================================
     // REPONSE ACTION
@@ -932,23 +896,35 @@
       }
       url2 = jQuery("#theMainImage").attr("src");
-    
+      if (typeof type != "undefined")
+        options.pictureSelType = type;
+      else {
+        options.pictureSelType = typeSave;
+        type = typeSave;
+
+      }
+      options.pictureDeriv = typeSave;
+      typeMap = typeSave;
+
+      jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
+      if (typeof type != "undefined" && (type == "Autosize" || type == "SelMaxi")) {
+        jQuery('#derivativeChecked' + type).css('visibility', 'visible');
+        document.cookie = 'picture_sel_type=' + type + ';path=' + COOKIE_PATH;
+      } else {
+     
+        jQuery('#derivativeChecked' + typeSave).css('visibility', 'visible');
+        document.cookie = 'picture_sel_type=' + typeSave + ';path=' + COOKIE_PATH;
+      }
+      options.pictureMap = typeMap;
+      options.pictureDeriv = typeSave;
+      document.cookie = 'picture_deriv=' + typeSave + ';path=' + COOKIE_PATH;
+
+
 
       jQuery("#theMainImage").removeAttr("width height").attr("src", url)
       .load(function (i) {
-        if (!init_img(this))
+        if (!init_img(this)) {
           return;
-        //=======================================================================       
-        jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
-        newtype = options.pictureSelType;
-        if (typeof type != "undefined" && (type == "Autosize" || type == "SelMaxi")) {
-          jQuery('#derivativeChecked' + type).css('visibility', 'visible');
-          document.cookie = 'picture_sel_type=' + type + ';path=' + COOKIE_PATH;
-        } else {
-          jQuery('#derivativeChecked' + typeSave).css('visibility', 'visible');
-          document.cookie = 'picture_sel_type=' + typeSave + ';path=' + COOKIE_PATH;
-        }
-        options.pictureMap = typeMap;
-        options.pictureDeriv = typeSave;
-        document.cookie = 'picture_deriv=' + typeSave + ';path=' + COOKIE_PATH;
+        }
+        //=======================================================================    
 
       })
@@ -1006,6 +982,10 @@
             if (data.src) {
               if (typeof imageInfos_id == "undefined") return;
-              if (!data.src.match(RegExp(options.pictureDeriv.substr(0, 2) + ".jpg", "gi"))) {
+              if (options.pictureDeriv == "Original" && data.src.match(RegExp("\-.." + ".jpg", "gi"))) {
                 Autosize_resize(true, options);
+              } else if (data.src.match(RegExp(options.pictureDeriv.substr(0, 2) + ".jpg", "gi"))) {
+                Autosize_resize(true, options);
+              } else {
+
               }
             }
@@ -1282,9 +1262,10 @@
           vn = this;
           size_derive = { w: parseInt(vn[2]), h: parseInt(vn[3]) };
-          if (vn[0] == options.pictureSelType) {
+          if (vn[0] == options.pictureSelType || vn[0] == "Original" ) {
             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) {
@@ -1303,4 +1284,8 @@
           n++;
         });
+
+
+
+
         n = maxi_size.idx;
         if (n < 0) {
@@ -1315,6 +1300,18 @@
         }
 
-        options.pictureDeriv = pt[n][0];
-        return { url: pt[n][1], pictureDeriv: pt[n][0], pictureMap: pt[n][0], width: pt[n][2], height: pt[n][3] };
+        pictureDeriv = pt[n][0];
+        last_id = pt[n][0];
+        jQuery(".switchCheck").each(function (i) {
+
+          if (!this.id.match(RegExp("Original", "gi"))) {
+            if (this.id.match(RegExp("SelMaxi", "gi"))) return false;
+            last_id = this.id.replace("derivativeChecked", "");
+          }
+          if (last_id.match(RegExp(pictureDeriv, "gi"))) return false;
+        });
+
+        options.pictureDeriv = last_id;
+
+        return { url: pt[n][1], pictureDeriv: last_id, pictureMap: last_id, width: pt[n][2], height: pt[n][3] };
       }
       return { imgSrc: "", pictureDeriv: "", width: "", height: "" };
@@ -1374,5 +1371,5 @@
         identique = Zone_image.src.match(RegExp(imgSrc, "gi"));
         if (identique) return;
-        href_path = "javascript:changeImgSrc('" + imgSrc + "', '" + IMg.pictureMap + "', '" + IMg.pictureDeriv + "', '" + options.pictureSelType + "')";
+        href_path = "javascript:changeImgSrc('" + imgSrc + IMg.pictureDeriv + "', '"+ "', '" + IMg.pictureMap + "', '"  + options.pictureSelType + "')";
         jQuery(".linkAutosize").attr("href", href_path);
         theImg = document.getElementById(theMainImage_id.replace("#", ""));
@@ -1383,5 +1380,6 @@
           return;
         } else {
-          changeImgSrc(imgSrc, IMg.pictureDeriv, IMg.pictureMap, options.pictureSelType);
+          last_id = IMg.pictureDeriv;
+          changeImgSrc(imgSrc, last_id, IMg.pictureMap, options.pictureSelType);
         }
 
@@ -1888,5 +1886,5 @@
         pictureSelType = options.pictureSelType;
       }
-      //==========================================================
+      //=================== 2==================================
       href_path = "javascript:changeImgSrc('" + options.imgSrc + "', '" + options.pictureDeriv + "', '" + options.pictureDeriv + "', '" + "SelMaxi" + "')";
       spans = jQuery("#derivativeCheckedSelMaxi").next();
@@ -1915,54 +1913,4 @@
       Autosize_resize(true, options);
       Autosize_resize(true, options);
-      return;
-
-      IMg = Get_Maxi(Zone_image.image);
-      imgSrc = IMg.url;
-
-      width = IMg.width;
-      height = IMg.height;
-
-      n = 0;
-      var pt = new Array();
-
-
-      //uyu = jQuery(uyu + " span");
-      //
-
-      // auto_details
-      //==== limite affichage selection = pictureSelType ====
-      jQuery("#derivativeSwitchBox a").css('visibility', 'hidden');
-      jQuery("#derivativeSwitchBox a").each(function (i) {
-        href_path = jQuery(this).attr("href");
-        pt[i] = href_path.split("'");
-        tsz = pt[i][5];
-
-        jQuery(this).css('visibility', 'visible');
-        //--- recherche limite ---
-        if (tsz.match(RegExp(pictureSelType_user, "gi"))) {
-          if (tsz.match(RegExp(options.pictureSelType, "gi"))) {
-            us = n;
-          } else {
-            return false;
-          }
-        }
-        //--- type en cours ---
-        if (tsz.match(RegExp("^" + pictureDeriv, "gi"))) {
-          us = n;
-        }
-
-        n++;
-      });
-      jQuery(".switchCheck").css('visibility', 'hidden');
-      jQuery("derivativeChecked" + pictureSelType_user).css('visibility', 'visible');
-      /*  */
-      //==== en cours ============
-      if (options.imgSrc) {
-        changeImgSrc(options.imgSrc, options.pictureDeriv, options.pictureDeriv, options.pictureSelType);
-        imgSrc = options.imgSrc;
-      }
-
-      href_path = "";
-
     };
     //_______________________ init_gen _______________________
@@ -2172,5 +2120,5 @@
 
 
-  });                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             // ready
+  });                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           // ready
 
 
