source: extensions/Autosize/js/Affiche_script.js @ 22360

Last change on this file since 22360 was 22360, checked in by cljosse, 11 years ago

[extensions] Autosize update to piwigo 2.5 (fix bugs with pamooramics, charlies's )

File size: 83.9 KB
Line 
1// problème avec GMaps+diaporama:
2// corriger   gmaps_pip.class.inc.php ajouter ligne 90 if ( !isset($_GET['slideshow']))
3//============================================================== 
4  jQuery.Affiche_script = { version: '2.0.0' };
5  /***************************************************************************
6         * document ready
7         **************************************************************************/
8  jQuery(document).ready(function (jQuery) {
9
10    var Type_Img = "";
11    var theImg = "";
12    var Zone_image = {};
13    // expire= x *24*60*60*1000
14    var OptionsCookie = jQuery.extend({}, { path: '/', expires: 1 });
15    /***************************************************************************
16    * test_theme("mont,pur") ...
17    **************************************************************************/
18    test_theme = function (param) {
19      if (!param) return
20      if (!options.theme) return;
21      regx = new RegExp(param, "gi");
22      return (options.theme.match(regx));
23    };
24    /***************************************************************************
25    * Save_cookies
26    **************************************************************************/
27    Save_cookies = function (parametres) {
28
29      if (!parametres) {
30        jQuery.cookie('windowHeight', jQuery(window).height(), OptionsCookie);
31        jQuery.cookie('windowWidth', jQuery(window).width(), OptionsCookie);
32        jQuery.cookie('picture_deriv', options.pictureDeriv, OptionsCookie);
33        jQuery.cookie('picture_sel_type', options.pictureSelType, OptionsCookie);
34        jQuery.cookie('picture_map', options.pictureMap || options.pictureDeriv, OptionsCookie);
35        return;
36      }
37      parametres.windowHeight = jQuery(window).height();
38      parametres.windowWidth = jQuery(window).width();
39      if (parametres.windowHeight) jQuery.cookie('windowHeight', parametres.windowHeight, OptionsCookie);
40      if (parametres.windowWidth) jQuery.cookie('windowWidth', parametres.windowWidth, OptionsCookie);
41      if (parametres.pictureDeriv) jQuery.cookie('picture_deriv', parametres.pictureDeriv, OptionsCookie);
42      if (parametres.pictureSelType) jQuery.cookie('picture_sel_type', parametres.pictureSelType, OptionsCookie);
43      if (parametres.pictureMap) jQuery.cookie('picture_map', parametres.pictureMap || parametres.pictureDeriv, OptionsCookie);
44
45      if (!Zone_image.container) return;
46
47      if (Zone_image.container.height) {
48        parametres.theContainerWidth = Zone_image.container.width;
49        parametres.theContainerHeight = Zone_image.container.height;
50      }
51      if (Zone_image.image.height) {
52        parametres.theMainImageWidth = Zone_image.image.width;
53        parametres.theMainImageHeight = Zone_image.image.height;
54      }
55      // if (infos_theMainImage.src == "none") return;
56      // if (!theImg.src.match(RegExp(Zone_image.name, "gi"))) return;
57      try {
58        if (Zone_image.path) jQuery.cookie('img_calc', Zone_image.path, OptionsCookie);
59        if (parametres.imgSrc) jQuery.cookie('img_src', parametres.imgSrc, OptionsCookie);
60        if (parametres.theContainerHeight) jQuery.cookie('theContainerHeight', parametres.theContainerHeight, OptionsCookie);
61        if (parametres.theContainerWidth) jQuery.cookie('theContainerWidth', parametres.theContainerWidth, OptionsCookie);
62
63        if (parametres.theMainImageHeight) jQuery.cookie('theMainImageHeight', parametres.theMainImageHeight, OptionsCookie);
64        if (parametres.theMainImageWidth) jQuery.cookie('theMainImageWidth', parametres.theMainImageWidth, OptionsCookie);
65
66        if (parametres.theContainerTop) jQuery.cookie('theContainerTop', parametres.theContainerTop, OptionsCookie);
67        if (parametres.theContainerLeft) jQuery.cookie('theContainerLeft', parametres.theContainerLeft, OptionsCookie);
68        if (parametres.theContainerRight) jQuery.cookie('theContainerRight', parametres.theContainerRight, OptionsCookie);
69        if (parametres.theContainerBottom) jQuery.cookie('theContainerBottom', parametres.theContainerBottom, OptionsCookie);
70        if (parametres.theContainerMargeZone) {
71          if (parametres.theContainerMargeZone.width) jQuery.cookie('theContainerMargeWidth', parametres.theContainerMargeZone.width, OptionsCookie);
72          if (parametres.theContainerMargeZone.height) jQuery.cookie('theContainerMargeHeight', parametres.theContainerMargeZone.height, OptionsCookie);
73        }
74      } catch (e) {
75        n = 1;
76      };
77    };
78    // ____________________ Save_cookies _____________________________
79    /***************************************************************************
80    * Get COOKIE
81    **************************************************************************/
82    Get_cookies = function () {
83      parametres = {
84        windowHeight: jQuery.cookie('windowHeight'),
85        windowWidth: jQuery.cookie('windowWidth'),
86
87        pictureDeriv: jQuery.cookie('picture_deriv'),
88        pictureMap: jQuery.cookie('picture_map'),
89        pictureSelType: jQuery.cookie('picture_sel_type'),
90
91        imgSrc: jQuery.cookie('img_src'),
92        theMainImageHeight: jQuery.cookie('theMainImageHeight'),
93        theMainImageWidth: jQuery.cookie('theMainImageWidth'),
94
95        theContainerHeight: jQuery.cookie('theContainerHeight'),
96        theContainerWidth: jQuery.cookie('theContainerWidth'),
97        theContainerTop: jQuery.cookie('theContainerTop'),
98        theContainerLeft: jQuery.cookie('theContainerLeft'),
99        theContainerBottom: jQuery.cookie('theContainerBottom'),
100        theContainerRight: jQuery.cookie('theContainerRight'),
101        theContainerMargeZone: { width: jQuery.cookie('theContainerMargeWidth'),
102          height: jQuery.cookie('theContainerMargeHeight')
103        }
104
105
106      };
107      return parametres;
108    };
109    // ____________________ Get_cookies _____________________________
110    /***************************************************************************
111    * Recupère le Type d'mage
112    **************************************************************************/
113    Get_type_img = function (e) {
114      // ====== détection du type d'images ======
115      if (jQuery("#charlie").length > 0) {
116        Type_Img = "charlie";
117      } else if (jQuery("#Panorama").length > 0) {
118        Type_Img = "panorama";
119
120      } else if (jQuery("#pamoorama").length > 0) {
121        Type_Img = "pamoorama";
122        theMainImage_Id = "#pamoorama";
123        options.valide = true;
124      } else if (jQuery("#map").length > 0 || jQuery("#mapPicture").length > 0) {
125        Type_Img = "map";
126      } else if (jQuery("#Panorama").length) {
127        Type_Img = "panorama";
128      } else if ((jQuery(theImage_id + " iframe").length + jQuery(theImage_id + " object").length + jQuery(theImage_id + " embed").length) > 0) {
129
130        if (jQuery(theImage_id + " object").length > 0) {
131          type_src = "object";
132        } else if (jQuery(theImage_id + " embed").length > 0) {
133          type_src = "embed";
134        } else {
135          type_src = "iframe";
136        }
137        iframes = jQuery(theImage_id + " " + type_src);
138        var st_frame = true;
139        nbf = iframes.length;
140        jQuery(theImage_id + " " + type_src).each(function (i) {
141          if (this.src.match(RegExp("http", "gi")) || this.src.match(RegExp("javascript", "gi"))) {
142
143          } else {
144            st_frame = false;
145            frm1 = this;
146          }
147        });
148        if (!st_frame) {
149          Type_Img = type_src;
150        } else {
151          Type_Img = "img";
152          type_src = "div";
153          return;
154        }
155        // 'fb - xfbml - like - button
156        objs = jQuery(theImage_id + " div").get(0);
157        if (jQuery(objs).length > 0) {
158          id_0 = jQuery(objs).attr("id");
159          if (id_0 == "") {
160            jQuery(objs).attr("id", "charlie");
161          } else {
162            if (nbf > 1) {
163              frm1.attr("id", "charlie");
164            } else {
165              // Type_Img = "img";
166            }
167          }
168        } else {
169          jQuery(frm1).attr("id", "iframe");
170          jQuery(frm1).wrap('<div id="' + "theMainImage" + '" style="border:1px solid Transparent" />');
171        }
172
173
174      } else if (jQuery(theImage_id).find("img").length > 0) {
175        Type_Img = "img";
176      } else if (jQuery(theImage_id + "Box").find("img").length > 0) {
177        Type_Img = "img";
178        Parent = Parent + "Box";
179      } else if (jQuery("img").length > 0) {
180        Type_Img = "img_autre";
181        return;
182      } else {
183        return;
184      };
185    };
186    // ____________________ Get_type_img _____________________________
187
188    // ====================================
189    // set_cl
190    // ====================================
191    set_cl = function (Valid) {
192      if (typeof Valid == "undefined")
193        Valid = options.pictureSelType.match(RegExp("Autosize", "gi")) || false;
194      if (typeof options.cl_visible != "undefined" && typeof src1 != "undefined") {
195        if (options.cl_visible) src = src1;
196        else src = src2;
197        if (typeof options.pictureSelType != "undefined" && (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi")) {
198          if (options.pictureSelType == "SelMaxi") src = src6;
199        } else {
200          Valid = false;
201          src = src2;
202          jQuery("#bp_cla span").text("");
203        }
204        if (options.cl_visible) {
205          src_info = src3;
206          src_infos_1 = src3;
207        } else {
208          src_info = src4;
209          src_infos_1 = src5;
210        }
211        src_info = options.pictureDeriv;
212
213
214        if ((typeof Zone_image != "undefined") && typeof Zone_image.image != "undefined") {
215          if (!Valid) {
216            Zone_image.image.height = Zone_image.image_init.height;
217            Zone_image.image.width = Zone_image.image_init.width;
218
219          }
220          Zone_image.zoom = (Zone_image.image.height / Zone_image.image_init.height);
221          zoom_cl = parseInt(100 * Zone_image.zoom) + "%"; ;
222          if (!Valid) {
223            if (options.pictureSelType == "SelMaxi")
224              zoom_cl = options.pictureSelType + " [" + options.pictureDeriv + "]";
225            else {
226              zoom_cl = "";
227              src_info = options.pictureDeriv;
228            }
229          }
230          if (Type_Img == "pamoorama" || Type_Img == "iframe" || Type_Img == "charlie") {
231            // zoom_cl = "";
232            // src_info = "";
233            // src = src2;
234          };
235
236          jQuery('#bp_cla').attr('alt', src_info);
237          jQuery('#bp_cla').attr('title', src_info);
238          jQuery('#bp_cla').attr('Stitle', src_info);
239          jQuery('#bp_cla').attr('Stip', zoom_cl);
240          jQuery('#bp_cla span').text(zoom_cl);
241          color_back = jQuery('#imageToolBar').css("backgroundColor");
242          try {
243            if (color_back.match(new RegExp("rgb", "gi"))) {
244              color_back = color_back.split("(")[1].split(")")[0].split(",");
245              color_back = "rgb(" + Math.abs(255 - color_back[0]) + ","
246                                        + Math.abs(255 - color_back[1]) + ","
247                                        + Math.abs(255 - color_back[2]) + ")";
248            }
249            else if (color_back.match(new RegExp("#", "gi")))
250              color_back = Math.abs("#65536" - color_back);
251            else
252              color_back = jQuery('body').css("color");
253            jQuery('#bp_cla span').css({ color: color_back, aling: "center" });
254          } catch (e) {
255
256          }
257          jQuery("#derivativeSwitchBox span").removeClass("auto_details linkAutosize");
258          jQuery("#derivativeSwitchBox a").removeClass("auto_details linkAutosize");
259          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
260            spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
261            spans.addClass("linkAutosize");
262            spans.find("span").addClass("auto_details");
263            jQuery(".auto_details").text("");
264          }
265          if (options.pictureDeriv) {
266            jQuery(".switchCheck").css({ visibility: "hidden" });
267            if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
268              jQuery("#derivativeChecked" + options.pictureSelType).css("visibility", "visible");
269              jQuery("#derivativeChecked" + options.pictureDeriv + ".switchCheck").css({ visibility: "visible", color: "grey" });
270            } else
271              jQuery("#derivativeChecked" + options.pictureDeriv).css("visibility", "visible");
272            jQuery('.auto_details').text(" (" + Zone_image.image.width + " x " + Zone_image.image.height + ") " + options.pictureDeriv);
273          }
274          // ===============================================
275        } else {
276          src = src6;
277          jQuery('.auto_details').text("");
278
279        }
280        bp_scr = jQuery('#bp_img_cla');
281        if (bp_scr.length > 0) {
282          src_enc = bp_scr.attr("src");
283          if (!src_enc.match(src)) {
284            bp_scr.get(0).src = src;
285            jQuery('#bp_img_cla').attr('alt', src_info);
286            jQuery('#bp_img_cla').attr('title', src_info);
287          }
288        };
289        if (typeof Affiche_limite != "function") return;
290        Affiche_limite(pictureSelType_user);
291      }
292      Save_cookies(options);
293    };
294    // ____________________ set_cl _____________________________
295
296    /***************************************************************************
297    * Set__llbgo
298    **************************************************************************/
299    Set_llbgo = function (Force) {
300      if (options.marges_llgbo == 0) return;
301      if (Force)
302        if (typeof LlgboFr_Resize == "function") {
303          LlgboFr_Resize();
304        }
305      if (Type_Img == "pamoorama" || Type_Img == "charlie") {
306        return;
307      }
308      if (!theImg) return;
309
310      if (theImg.useMap)
311        nom_map = theImg.useMap.replace("#", "");
312      else
313        nom_map = "Autosize";
314
315      maps = jQuery("map[name='" + nom_map + "']");
316      if (maps.length == 0) return;
317      // nom_map = maps[0].name;
318      maps = jQuery("map[name='" + nom_map + "']  area");
319      nb_zone = maps.length;
320      Largeur_zone = (Zone_image.image.width / nb_zone);
321      Hauteur_zone = (Zone_image.image.height);
322      init_zone = 0;
323      j = 0;
324      maps.each(function (e) {
325        init_zone = Largeur_zone * j;
326        rel = jQuery(this).attr("rel");
327        title = jQuery(this).attr("title");
328        alt = jQuery(this).attr("alt");
329        H = Hauteur_zone;
330        if (rel == "up") {
331          H = Hauteur_zone / 4;
332        }
333        coord = { x0: init_zone, y0: 0, x1: Math.ceil(init_zone + Largeur_zone), y1: Hauteur_zone };
334        jQuery(this).attr({ coords: "'" + coord.x0 + "," + coord.y0 + "," + coord.x1 + "," + coord.y1 + "'" });
335        j++;
336      });
337
338      return;
339    };
340    // __________ Set_llbgo _______________
341    var wpng = 0;
342
343
344    // ===================
345    // VARIABLES
346    // ===================
347
348
349    // ===================
350    // options
351    // =========================================================
352    if (typeof (options) == "undefined") {
353      options = { imageAutosize: false };
354    }
355    if (typeof Autosize_options == "undefined") return;
356    options = jQuery.extend(Autosize_options, options);
357
358
359    var defaults = {
360      imageAutosizeMargin: 0,
361      imageAutosize: false,
362      marge_basse: options.imageAutosizeMargin || 0,
363      DEBUG_autosize: false
364    };
365
366    options = jQuery.extend(defaults, options);
367    options.theMainImageWidth = options.theMainImageWidth;
368    options.theMainImageHeight = options.theMainImageHeight;
369    jQuery("#the_page").append("<div id='form_autosize_picture' ></div>");
370    jQuery("#form_autosize_picture").addClass("Autosize");
371    // ===== marges suplémentaires en fonction theme ===
372    options.valide = jQuery(".Autosize").css("display") != "none";
373    options.marge_haute = jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("top"));
374    options.marge_basse = Math.max(
375  jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("bottom")),
376  options.marge_basse
377  );
378
379    options.marge_gauche = jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("left"));
380    options.marge_droite = jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("right"));
381
382    jQuery(".Autosize").hide();
383    DEBUG_autosize = options.DEBUG_autosize;
384    OptionsCookie = jQuery.extend({}, { path: options.COOKIE_PATH, expires: 1 });
385
386    var cookies = Get_cookies();
387    fade_in = options.fade_in || 0;
388    imageComment_id = ".imageComment";
389    if (test_theme("simple")) {
390      jQuery("#theImage p").addClass("imageComment");
391    }
392    if (test_theme("mont")) {
393      jQuery("#content").css({ marginLeft: 'auto' }); // monblanc
394    }
395
396    var theMainImage_id = "#theMainImage";
397    var theImage_id = "#theImage";
398    var theImageAndInfos_id = "#theImageAndInfos";
399    var infos_window = jQuery(window).infos();
400    var infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
401    // general
402    var infos_content = jQuery("#content").infos({ absolute: true });
403    var infos_the_page = jQuery("#the_page").infos({ absolute: true });
404    var nopano = false;
405    var llgbo_id = "#llgbo0";
406
407    var useMap = options.pictureMap; // #mapxxx
408    var user_status = options.user_status;
409    var chk = eval("options." + user_status + "_enabled");
410    if (chk == "") { options.valide = false; }
411
412    var pictureDeriv = options.pictureDeriv; // xxx
413    var pictureSelType_user = eval("options." + user_status + "_type"); // limite
414    // taille
415    var path_names = new Array();
416    var img_finale = null;
417    var mypanorama = null;
418
419    if (pictureSelType_user != "Autosize" && pictureSelType_user != "SelMaxi") {
420      if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
421        options.pictureSelType = pictureSelType_user;
422        options.pictureDeriv = pictureSelType_user;
423      }
424    }
425    if (!cookies.pictureDeriv) Save_cookies(options);
426
427    if (pictureSelType_user != options.pictureSelType) {
428      if (pictureDeriv == null)
429        pictureDeriv = pictureDeriv_user;
430      else
431        pictureDeriv_user = pictureDeriv;
432    }
433
434    if (!options.valide) {
435
436      pictureDeriv = "medium";
437      pictureDeriv_user = pictureDeriv;
438      options.pictureDeriv = pictureDeriv;
439    }
440    if (Type_Img == "pamoorama" || Type_Img == "iframe" || Type_Img == "charlie") {
441      options.pictureSelType = "Autosize";
442    }
443    new_liste = new Array();
444    for (var i = 0; i < options.liste_type.length; i++) {
445      liste_types = options.liste_type[i].split(",");
446      new_liste.push(options.liste_type[i].split(","));
447      if (liste_types[0] == pictureSelType_user) {
448        break;
449      }
450    }
451    options.liste_type = new_liste;
452    XImg = jQuery(theMainImage_id);
453    if (XImg.length > 0)
454      if (jQuery(theMainImage_id)
455         .html()
456         .match(RegExp("charlie_", "gi"))
457         ) {
458        Xdiv = jQuery(theMainImage_id + " div");
459        Xid = jQuery(Xdiv).attr("id");
460        if (typeof Xid == "undefined") {
461          jQuery(Xdiv).attr("id", "charlie");
462        }
463      }
464    Get_type_img();
465
466    /***************************************************************************
467    *
468    **************************************************************************/
469    get_href = function (NewpictureDeriv) {
470      if (path_names.length == 0) Affiche_limite(pictureSelType_user);
471      ref = path_names[0];
472      for (i = 0; i < path_names.length; i++) {
473        newHref = path_names[i];
474        match = ",'" + NewpictureDeriv;
475        newHref_ind = newHref.indexOf(match);
476        if (newHref_ind > 0) {
477          href = newHref;
478          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
479            ref = href.replace("')", "','" + options.pictureSelType + "')");
480          } else {
481            ref = href;
482          }
483          break;
484        }
485
486      }
487
488
489      return ref;
490    };
491
492    /***************************************************************************
493    *
494    **************************************************************************/
495    Ajuste_Liens = function () {
496      // =================== 2 ============================
497      sav_p = options.pictureSelType;
498      options.pictureSelType = "SelMaxi";
499      href_path = get_href(options.pictureDeriv);
500      spans = jQuery("#derivativeCheckedSelMaxi").next();
501      spans.attr("href", "javascript:" + href_path);
502      spans.attr("name", "SelMaxi");
503      spans = spans.find("span");
504      spans.attr("name", "SelMaxi");
505      spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")");
506      // ==========================================================
507      options.pictureSelType = "Autosize";
508      href_path = get_href(options.pictureDeriv);
509      spans = jQuery("#derivativeCheckedAutosize").next();
510      spans.attr("href", "javascript:" + href_path);
511      spans.attr("name", "Autosize");
512      spans = spans.find("span");
513      spans.attr("name", "Autosize");
514      spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")");
515      // ==========================================================
516      options.pictureSelType = sav_p;
517      jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
518      if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
519        jQuery('#derivativeChecked' + options.pictureSelType).css('visibility', 'visible');
520        spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
521        spans.addClass("linkAutosize");
522        spans.find("span").addClass("auto_details");
523      } else {
524        jQuery('#derivativeChecked' + options.pictureDeriv).css('visibility', 'visible');
525      }
526      return options.pictureDeriv;
527    };
528
529
530    /***************************************************************************
531    *
532    **************************************************************************/
533    jQuery("#derivativeSwitchBox a").click(function (e) {
534      Affiche_limite(pictureSelType_user);
535      retour = decode_href(this);
536      theImg = document.getElementById(theMainImage_id.replace("#", ""));
537      if (theImg) {
538        // options.pictureDeriv = retour.pictureDeriv;
539        if (this.name) {
540          options.pictureSelType = this.name;
541          spans = jQuery("#derivativeChecked" + this.name).next();
542          if (retour.pictureSelType != this.name)
543            spans.attr("href", "javascript:" +
544  "ChangeImgSrc('" + retour.source + "," +
545  retour.pictureDeriv + "," +
546  retour.pictureMap + "," + options.COOKIE_PATH + "')");
547        }
548        options.pictureSelType = retour.pictureSelType;
549        options.pictureDeriv = retour.pictureDeriv;
550        options.pictureMap = retour.pictureDeriv;
551        Save_cookies(options);
552        if (typeof Autosize_resize == "function")
553          setTimeout(function (i) {
554            Autosize_resize(false, options);
555          }, 2);
556
557      }
558    });
559    // __________ fin click #derivativeSwitchBox a ____________
560    Affiche_limite = function (pictureSelType_Maxi) {
561      n = 0;
562      var pt = new Array();
563      path_names = new Array();
564      jQuery("#derivativeSwitchBox a").css('visibility', 'hidden');
565      // jQuery(".switchCheck").css('visibility', 'hidden');
566      var maxi_display = false;
567      jQuery("#derivativeSwitchBox a").each(function (i) {
568        href_path = jQuery(this).attr("href");
569        if (!href_path) {
570          href_path = jQuery(this).html();
571          return;
572        }
573        pt = href_path.replace(/(javascript|changeImgSrc)|[('):]/gi, "");
574
575        patname = href_path.replace("javascript\:", "");
576        if (typeof old_path == "undefined") old_path = patname;
577        pt = pt.split(",");
578        tsz = pt[pt.length - 1];
579        if (!maxi_display)
580          jQuery(this).css('visibility', 'visible');
581        else {
582          jQuery(this).next().next().remove();
583          jQuery(this).next().remove();
584          jQuery(this).remove();
585        }
586        // --- recherche limite ---
587
588        if (!options.valide && (tsz == "Autosize" || tsz == "SelMaxi")) {
589          jQuery(this).next().next().remove();
590          jQuery(this).next().remove();
591          jQuery(this).remove();
592        } else {
593          if (tsz == "Original" && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
594            maxi_display = true;
595          } else if (tsz == pictureSelType_Maxi && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
596            maxi_display = true;
597
598          } else if (tsz == "Autosize" || tsz == "SelMaxi") {
599            patname = old_path.replace("')", "','" + tsz + "')");
600          } else
601            old_path = patname;
602          path_names.push(patname);
603        }
604        // --- type en cours ---
605        if (tsz.match(RegExp("^" + options.pictureDeriv, "gi"))) {
606          us = n;
607        }
608        n++;
609      });
610    }; // _____ fin Affiche_limite ____
611    if (DEBUG_autosize.match(new RegExp("noresize", "gi"))) {
612      Ajuste_Liens();
613      Save_cookies();
614      return;
615
616    }
617    // auto_details
618    // ==== limite affichage selection = select_type ====
619
620
621
622
623    /***************************************************************************
624    * window LOAD
625    **************************************************************************/
626    jQuery(window).load(function () {
627      location_href = location.href;
628      // =======================================================================
629      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });        // Image
630      if (infos_theMainImage.src.match(RegExp("gif", "gi"))) {
631        setTimeout(function (i) {
632          jQuery(window).load();
633        }, 500);
634        return;
635      };
636      infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();         // Cadre
637      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });   // conteneur
638
639      // general
640      if (infos_theMainImage.width == 0) {
641        if (Type_Img == "pamoorama") {
642          theMainImage_id = "#pamoorama";
643          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
644          infos_theMainImage.width = options.scaled_width;
645          infos_theMainImage.height = options.scaled_height;
646          options.valide = true;
647        } else if (Type_Img == "charlie") {
648          theMainImage_id = "#charlie";
649          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
650          options.valide = true;
651        } else if (Type_Img == "iframe") {
652
653          infos_theMainImage = jQuery("#iframe").infos({ absolute: true });
654          options.valide = true;
655          infos_theMainImage.width = infos_theContainer.general.width;
656          infos_theMainImage.height = infos_window.height - infos_theContainer.top - options.marge_basse;
657          jQuery("#iframe").width(infos_theMainImage.width);
658          jQuery("#iframe").height(infos_theMainImage.height);
659
660        } else {
661          jQuery("img").each(function (i) {
662            imgSrc = options.imgSrc;
663          });
664          infos_theMainImage = jQuery("#theImage img").infos({ absolute: true });
665        }
666        if (infos_theMainImage.id == "") {
667          jQuery("#theImage img").attr("id", "theMainImage");
668          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
669        }
670
671      }
672      if (Type_Img == "charlie" || Type_Img == "iframe") {
673        options.scaled_width = options.theMainImageWidth;
674        options.scaled_height = options.theMainImageHeight;
675      }
676
677      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
678        jQuery('#derivativeSwitchLink').show();
679      }
680      if (test_theme("simple")) {
681        jQuery(theMainImage_id).css({ maxWidth: "none" });
682        theImageAndInfos_id = "#content";
683        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
684        // general
685        infos_theContainer.height = infos_window.height - infos_theContainer.top;
686        // jQuery(theImage_id).height(infos_theContainer.height);
687
688      } else {
689        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
690        // general
691        if (infos_theImageAndInfos.visible == false)
692          theImageAndInfos_id = "#imageContainer";
693      }
694
695
696      imageInfos_id = "#imageInfos";
697      content_id = "#content";
698      infos_content = jQuery(content_id).infos({ absolute: true });                 // conteneur
699      infos_imageInfos = jQuery(imageInfos_id).infos({ absolute: true });            // information
700      infos_copyright = jQuery("#copyright").infos({ absolute: true });
701
702
703      if (infos_theContainer.top > infos_window.height) {
704        zheight = infos_window.height - infos_content.top;
705      } else {
706        zheight = infos_window.height - (infos_theContainer.top);
707      }
708
709
710      if (options.check_desc_v) { }
711
712      infos_comments = jQuery("#comments").infos({ absolute: true });
713      infos_Licence = jQuery(".licencetag").infos({ absolute: true });
714      infos_imageComment = jQuery(imageComment_id).infos({ absolute: true });
715
716      if (test_theme("simple")) {
717
718
719      } else {
720        if (test_theme("stripped")) {
721
722        } else
723
724          if (test_theme("blanc , pure, hr_ ")) {
725            options.marge_gauche += 10;
726            options.marge_droite += 10;
727          }
728      }
729      // ==============================================================================
730
731      infos_theMainImage.height = infos_theMainImage.height | zheight;
732
733      if (infos_theMainImage.height > 0) {
734        rapport_i = Math.ceil(infos_theMainImage.width / infos_theMainImage.height);
735
736        Zone_image = {
737          image_init: {
738            width: options.scaled_width, height: options.scaled_height,
739            rapport: options.ratio
740          },
741          image: {
742            width: infos_theContainer.width,
743            height: infos_window.height - infos_theContainer.top - options.marge_basse,
744            rapport: rapport_i
745          },
746          container: {
747            width: infos_theContainer.general.width,
748            height: zheight,
749            margesWidth: infos_window.width - infos_theContainer.width
750          }, marges: {
751            height: 0,
752            width: 0
753          },
754          zoom: Math.ceil(infos_theContainer.width / infos_theMainImage.width)
755        };
756
757      }
758      // ========================================================================
759
760      /***********************************************************************
761      * RESIZE (une fois document chargé)
762      **********************************************************************/
763
764      jQuery(window).resize(function (event, ui) {
765        Autosize_resize(true, options);
766      });
767      // _____________ widow.resize _______________
768
769      type_src = "div";
770      old_window = { width: 0, height: 0 };
771      List_autosize = new Array();
772      nu_img = 0;
773      tempo = 0;
774
775
776      infos_llgbo = jQuery(llgbo_id).infos({ absolute: true });
777      infos_llgboh2 = jQuery("#llgboh2").infos({ absolute: true });
778      marges_llgbo = 0;
779      // ==========================================================================================
780      init_gen();
781    });
782    // __________________window.onload_________________
783
784
785    // =============================================================
786    // REPONSE ACTION
787    // =============================================================
788    theMainImage_st = false;
789    jQuery("#reset").click(function () {
790      location.reload();
791    });
792
793
794    // ===========================================================
795    // REPONSE TRIGGER
796    // ===========================================================
797    jQuery('#ret_autosize').live('ON', function (e) {
798      if (nu_img == "") nu_img = 8;
799      jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
800
801    });
802
803    // ==========================================================
804    jQuery("map area").mouseover(function (e) {
805      try {
806        nok = theImg.useMap;
807        hok = this;
808      }
809      catch (r) {
810
811      }
812    });
813
814    // ==================================
815    // jQuery("#llgbo").trigger("ON");
816    // ==================================
817    jQuery(llgbo_id).live('ON', function (e) {
818      n_id = this;
819      infos_llgbo = jQuery(llgbo_id).infos();
820      if (infos_llgbo.visible == false) return;
821
822      marges_llgbo = 0;
823      if (infos_llgbo.height > 0) {
824        infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
825        infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
826        // =============================================
827        ll2 = infos_llgboframe1.width; // llgboframe1 interieur
828        ll1 = infos_llgboframe31.exterieur.width; // llgboframe31 avec border
829        // width
830        options.marges_llgbo = (ll1 - ll2);
831        infos_llgboh2 = jQuery("#llgboh2").infos();
832      }
833    });
834    // ==============================
835    // jQuery("#mapPicture").trigger("ON");
836    // ==============================
837    jQuery("#mapPicture").live('ON', function (e) {
838      p2 = jQuery("#infoSwitcher").infos();
839    });
840    // ==============================
841    // jQuery("#map").trigger("ON");
842    // ==============================
843    jQuery("#map").live('ON', function (e) {
844      p2 = jQuery("#map").infos();
845    });
846    // ===================================
847    // jQuery(theImage_id).trigger("ON");
848    // ===================================
849    jQuery("#imageInfos").live('on', function (e) {
850      target = e.target.id;
851    });
852
853    // ===================================
854    // jQuery(theImage_id).trigger("ON");
855    // ===================================
856    jQuery(theImage_id).live('ON', function (e) {
857      target = e.target.id;
858
859      id = this.id;
860      Select_Image(); // +calcul
861    });
862
863    jQuery("#theMainImage").load(function (e) {
864      if (!e.target.src) return;
865      if (e.target.src.match(RegExp("gif", "gi"))) {
866        target = theImg.src;
867      };
868
869    });
870    jQuery("#theMainImage").resize(function (e) {
871
872      if (!e.target.src) return;
873      //loaded ajax .gif
874      if (e.target.src.match(RegExp("\.gif", "gi"))) {
875        target = theImg.src;
876      };
877
878    });
879
880
881    // =================================================================
882    jQuery(document).live('gallyInterfaceReady', function (e) {
883      i = jQuery(this).text();
884      jQuery(this).trigger('ON');
885    }
886
887          );
888
889
890    /***************************************************************************
891    *
892    **************************************************************************/
893    jQuery(theImage_id).resize(function (e) {
894      nu_img = 0;
895    });
896    jQuery("#menuSwitcher,#infoSwitcher").click(function (e) {
897      options.set_sw = this.id;
898      setTimeout(function () { div_resize(); }, 10);
899      nu_img = 0;
900    });
901
902    div_resize = function (i) {
903
904      jQuery(theImage_id).trigger("resize");
905      /*
906      * if (jQuery(theImage_id).width() != old_width) { setTimeout(function () {
907      * div_resize() }, 10); }
908      */
909    };
910    // ===========================================
911    // jQuery("#theImageAndInfos").trigger("ON");
912    // ===========================================
913    jQuery("#theImageAndInfos").live('ON', function (e) {
914      infos_theImageAndInfos = jQuery("#theImageAndInfos").infos();
915      // setTimeout(function () { Autosize_resize(true) }, 100);
916      nu_img = 0;
917    }); // fin click #theImageAndInfos ON
918
919
920    jQuery("#theImageAndInfos").resize(function (e) {
921      nu_img = 0;
922    });
923
924
925    jQuery("#linkAutosize").click(function (e) {
926      nu_img = 0;
927    });
928    // ==================================
929    //
930    // ===================================
931    jQuery('#derivativeCheckedAutosize').click(function () {
932      try {
933        pathnames = jQuery(this).attr("href").split(":");
934
935        // eval(pathnames[1]);
936      } catch (e) {
937        n = false;
938      }
939    }); // fin click derivativeCheckedAutosize
940    // ====================================================
941    if (typeof decode_href != 'function') {
942      function decode_href(myObj) {
943        retour = { source: null,
944          pictureDeriv: null,
945          pictureMap: null,
946          pictureSelType: null
947        };
948        hrefPath = jQuery(myObj).attr("href");
949        if (hrefPath.indexOf("changeImgSrc") < 0) {
950          pt = hrefPath;
951        } else {
952          pt = hrefPath.replace(/(javascript|phpWGOpenWindow|javascript|changeImgSrc)|[('):]/gi, "");
953
954        }
955        pt = pt.split(",");
956        retour.source = pt[0];
957        if (hrefPath.indexOf("phpWGOpenWindow") < 0) {
958          retour.pictureDeriv = pt[1];
959          retour.pictureMap = pt[2];
960          retour.pictureSelType = pt[pt.length - 1];
961        } else {
962          retour.pictureDeriv = options.pictureDeriv;
963          retour.pictureMap = options.pictureMap;
964          retour.pictureSelType = options.pictureSelType;
965        }
966
967        return retour;
968      }
969    }
970
971
972
973    jQuery("input").click(function () {
974      if (this.name.match(RegExp("_enabled", "gi"))) {
975        sel = "[name*=" + this.name + "]";
976        obj = jQuery("tr" + sel);
977
978        if (this.checked)
979          obj.css({ backgroundColor: "green", color: "white" });
980        else
981          obj.css({ backgroundColor: "red", color: "white" });
982        return;
983      }
984      return;
985    });
986
987
988    // ====================================
989    Autosize_init = function (name, value) {
990      img_defaut = { height: options.scaled_height, width: options.scaled_width };
991      img_reelle = { height: options.theMainImageHeight, width: options.MaintheImageWidth };
992      img_container = { height: options.theContainerHeight, width: options.theContainerWidth };  // taille
993      // initiale
994
995      img_finale = img_init;
996
997      useMap = infos_theMainImage.useMap; // #mapmedium
998
999      useMap = options.pictureMap; // #mapxxx
1000      pictureDeriv = options.pictureDeriv; // picturederiv xxx
1001
1002
1003      old_img = options.imgSrc;
1004      old_window_height = options.windowHeight || jQuery(window).height();
1005      old_window_width = options.windowWidth || jQuery(window).width();
1006      old_img_h = options.imgHeight;
1007      old_img_w = options.imgWidth;
1008      if (infos_theMainImage.visible == true) {
1009        theImg = document.getElementById(theMainImage_id.replace("#", ""));
1010        theImg.useMap = useMap;
1011      }
1012
1013
1014    };
1015    // ____________________ Autosize_init _____________________
1016
1017    /***************************************************************************
1018    * Autosize_resize
1019    **************************************************************************/
1020    Autosize_resize = function (force, parametres) {
1021      if (!force) {
1022        cookis = Get_cookies();
1023        if (cookis.pictureSelType != options.pictureSelType) {
1024          n = 0;
1025        }
1026      }
1027      nauto = Get_dimensions(true, parametres);
1028      if (nauto == "Wait") {
1029        setTimeout(function (force, parametres) { Autosize_resize(force, parametres); }, 100);
1030        return;
1031      }
1032
1033      if (!options.valide || !nauto || (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi")) {
1034        if (options.imageAutosize == true) {
1035          options.pictureSelType = options.pictureDeriv;
1036          Zone_image.image_init.width = jQuery(theImg).width();
1037          Zone_image.image_init.height = jQuery(theImg).height();
1038          set_cl("no");
1039          Set_llbgo(true);
1040          return;
1041        }
1042        // jQuery(theImg).width(Zone_image.image_init.width);
1043        for (n in options.liste_type) {
1044          if (options.liste_type[n][0] == options.pictureSelType) {
1045            Zone_image.image_init.height = options.liste_type[n][3];
1046            Zone_image.image_init.width = options.liste_type[n][2];
1047            break;
1048          }
1049        }
1050
1051
1052        jQuery(theImg).height(Zone_image.image_init.height);
1053        set_cl("no");
1054        Set_llbgo(true);
1055        return;
1056      }
1057      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });
1058      if (typeof img_finale.width == "undefined")
1059        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
1060      if (img_finale.width && (img_finale.width != Zone_image.image.width ||
1061          img_finale.height != Zone_image.image.height)) {
1062        if (Type_Img == "pamoorama") {
1063          img_finale.height = Zone_image.image.height;
1064        } else
1065          img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
1066      }
1067
1068      // ======================================================
1069
1070      affiche_debug({
1071        Debug1: Debug_info(1, "Cont:" + infos_theContainer.width
1072    + " X " + infos_theContainer.height
1073    + " IMG: " + img_finale.width
1074    + " X " + img_finale.height
1075    + " mgw : " + Zone_image.marges.width
1076    , "->")
1077      });
1078      if (Type_Img == "pamoorama") {
1079        // img_finale.width = Zone d'affichage :
1080
1081        if (nopano) {
1082          jQuery(theMainImage_id).width(img_finale.width);
1083          jQuery(theMainImage_id).height(img_finale.height);
1084          infos_pamoorama = jQuery(theMainImage_id).infos({ absolute: true });
1085          Set_Pamoorama({ width: img_finale.width, height: img_finale.height });
1086        }
1087
1088      } else if (Type_Img == "panorama") {
1089        // jQuery("#pamoorama").width(img_finale.width);
1090        // jQuery("#pamoorama").height(img_finale.height);
1091
1092
1093
1094        // jQuery("#theImage img.simple_panorama").panorama(asp_options);
1095      } else {
1096        if (options.imageAutosize == false)
1097          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
1098            jQuery(theMainImage_id).height(Zone_image.image.height);
1099            r1 = infos_theContainer.width / infos_theContainer.height;
1100            jQuery(theMainImage_id).css("margin-top", options.marge_haute);
1101          } else {
1102            jQuery(theMainImage_id).width(Zone_image.image_init.width);
1103            jQuery(theMainImage_id).height(Zone_image.image_init.height);
1104          }
1105        if (Type_Img == "charlie" || Type_Img == "iframe") {
1106          init_w1 = Zone_image.image.width;
1107          init_h1 = Zone_image.image.height;
1108          if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
1109            init_w1 = Autosize_options.ideal_size_width;
1110            init_h1 = Autosize_options.ideal_size_height;
1111          }
1112          if (Type_Img == "charlie") {
1113            the_mainImage_html = jQuery(theMainImage_id).html();
1114            img_objs = jQuery("#charlie object,#charlie embed");
1115            if (img_objs.length > 0) {
1116              jQuery(img_objs).each(function (e) {
1117             //   init_h1 = jQuery(this).height();
1118             //   init_w1 = jQuery(this).width();
1119              }); 
1120            }
1121            dp1 = jQuery("#charlie").offset();
1122            dp = jQuery(img_objs).offset();
1123            if (dp) { if (wpng == 0) wpng = Math.abs(dp.left - dp1.left) * 2; }
1124            png_h = init_h1; w01 = init_w1 - wpng;
1125            if (!png_h) {
1126              png_h = jQuery("#theMainImage").height();
1127              h01 = png_h;
1128            }
1129            else
1130              h01 = Math.ceil(w01 / Zone_image.image.rapport);
1131            // ==== Zone Affichage  =====
1132            if (h01 > png_h) {
1133              h01 = png_h;
1134              w01 = Math.ceil(h01 * Zone_image.image.rapport);
1135            }
1136            jQuery("#theMainImage").height(png_h );
1137            jQuery("#theMainImage").width(w01 + wpng);
1138            jQuery("#theMainImage").css({ verticalAlign: "middle",
1139              textAlign: "center", margin: "auto"
1140            });
1141
1142            if (jQuery("#theMainImage_vid").length > 0) {
1143              jQuery("#theMainImage_vid").attr("width", w01);
1144              jQuery("#theMainImage_vid").attr("height", h01);
1145            }
1146            if (jQuery("video").length > 0) {
1147              jQuery("video").attr("width", w01);
1148              jQuery("video").attr("height", h01);
1149            }
1150            jQuery("#" + Type_Img).height(png_h);
1151            jQuery("#" + Type_Img + "div").width(w01);
1152            jQuery(theImage_id).css({ height: "auto" });
1153
1154
1155       //     jQuery("#charlie object").attr("width", w01);
1156            jQuery("#charlie    object").attr("height", h01);
1157        //    jQuery("#charlie embed").attr("width", w01); // firefox opera
1158            jQuery("#charlie embed").attr("height", h01);
1159            jQuery("#charlie  embed").css("margin", "auto");
1160
1161          } else {
1162            jQuery(theImage_id).css({ height: "auto" });
1163            jQuery("#theMainImage").css({ width: "auto", height: "auto" });
1164            jQuery("#" + Type_Img).attr("width", init_w1 - (infos_theMainImage.borderwidth.left + infos_theMainImage.borderwidth.right));
1165            jQuery("#" + Type_Img).attr("height", init_h1 - (infos_theMainImage.borderwidth.top + infos_theMainImage.borderwidth.bottom));
1166          }
1167          // jQuery("#" + Type_Img).show(fade_in);
1168        }
1169
1170
1171      }
1172
1173      set_cl();
1174      Set_llbgo(true);
1175      return true;
1176    };
1177    // _________________Autosize ____________________________________
1178
1179
1180    /***************************************************************************
1181    * theMainImage_id=pamoorama
1182    **************************************************************************/
1183    /***************************************************************************
1184    * Wait_pamoorama
1185    **************************************************************************/
1186
1187    Wait_pamoorama = function () {
1188      if (Type_Img != "pamoorama") return true;
1189      if (nopano == true) return true;
1190      mypanorama = window.myPamoorama;
1191      if (mypanorama) {
1192        jQuery(mypanorama).live('ON', function (e) {
1193          jQuery(jQuery('.debug').get(1)).trigger('ON');
1194          Autosize_resize(true, options);
1195          jQuery("#pamoorama").fadeTo(fade_in + 20, 1);
1196        });
1197
1198        // ===============================================
1199        // jQuery(theImage_id).trigger("Start_right");
1200        // ===============================================
1201        jQuery(mypanorama).live('Start_right', function (e) {
1202          if (typeof Zone_image == "undefined") return
1203          test_w = window.myPamoorama.autoSlideFx.to;
1204          test_w = window.myPamoorama.autoScrollFx.to;
1205          nf = jQuery("#pamoorama_thumb").height();
1206          jQuery("#pamoorama_thumb img").width(200);
1207          jQuery("#pamoorama_thumb img").height(nf);
1208          // 200=window.myPamoorama.imageWidth
1209          // frame = Zone_image.container.width
1210          nw = (200 * Zone_image.image.width) / window.myPamoorama.imageWidth;
1211          jQuery("#pamoorama_frame").width(nw);
1212        });
1213        // ===============================================
1214        // jQuery(theImage_id).trigger("Start_left");
1215        // ===============================================
1216        jQuery(mypanorama).live('Start_left', function (e) {
1217          if (typeof Zone_image == "undefined") return
1218          jQuery(theImage_id).show(0);
1219          window.myPamoorama.autoSlideFx.to = 0;
1220          test_w = window.myPamoorama.autoSlideFx.to;
1221          test_w = window.myPamoorama.autoScrollFx.to;
1222          nf = jQuery("#pamoorama_thumb").height();
1223          jQuery("#pamoorama_thumb img").width(200);
1224          jQuery("#pamoorama_thumb img").height(nf);
1225        });
1226      }
1227      // =============================================================
1228      if (mypanorama && typeof mypanorama.imageHeight != "undefined" && mypanorama.skipInit == true) {
1229        nopano = true;
1230        Zone_image.image_init = {
1231          width: mypanorama.imageWidth,
1232          height: mypanorama.imageHeight,
1233          rapport: Math.ceil(mypanorama.imageWidth / mypanorama.imageHeight)
1234        };
1235        Autosize_resize();
1236
1237      } else {
1238
1239        setTimeout(function () {
1240          Wait_pamoorama();
1241        }, 500);
1242      };
1243
1244      return true;
1245
1246    };
1247    // __________________ Wait_pamoorama ______________________
1248    jQuery(".pwg-icon-clock-minus, .pwg-icon-clock-plus").click(function (i) {
1249
1250    }).mouseover(function (i) {
1251
1252    });
1253
1254
1255
1256    /***************************************************************************
1257    *
1258    **************************************************************************/
1259    Wait_Affichage = function () {
1260      Wait_Affichage_st = false;
1261      while (Wait_Affichage_st == false) {
1262        jQuery.noop();
1263        Wait_Affichage_st = Wait_Affichage_time();
1264      }
1265    };
1266    // __________________ Wait_Affichage ______________________
1267
1268
1269    Wait_Affichage_time = function () {
1270      // if (nu_img > 1) return;
1271      if (typeof stb != "undefined")
1272        stb.stop().fadeTo(3500, 0);
1273      if (typeof theMainImage_id == "undefined") return true;
1274
1275      if (theMainImage_id.selector) {
1276        theMainImage_id = theMainImage_id.selector;
1277      }
1278      if (theMainImage_id == null) return;
1279
1280      if (jQuery(theMainImage_id).length == 0) {
1281        if (jQuery("#pamoorama_inner").length > 0) {
1282          return true;
1283        }
1284        // === attente Image chargée ===
1285        if (tempo > 100) return true;
1286        tempo++;
1287        setTimeout(function () { Wait_Affichage_time(); }, 500);
1288        return false;
1289
1290      } else {
1291
1292        img_h = jQuery(theMainImage_id).height();
1293        img_w = jQuery(theMainImage_id).width();
1294
1295        if (typeof infos_theContainer == "undefined") return;
1296        jQuery("#ret_autosize").trigger('ON', {
1297          width: img_w,
1298          height: img_h,
1299          theImage: theMainImage_id,
1300          img_src: infos_theMainImage.src,
1301          window_height: infos_theContainer.height,
1302          window_width: infos_theContainer.width
1303        });
1304      }
1305      return true;
1306    };
1307    // ______________ Wait_affichage ______
1308
1309
1310    /***************************************************************************
1311    *
1312    **************************************************************************/
1313    init_img = function (theImg) {
1314      if (theImg.complete == false) {
1315        return;
1316      }
1317      name_src = theImg.src;
1318      stx = name_src.match(RegExp(Zone_image.src, "gi"));
1319      if (stx == null) {
1320        return false;
1321      }
1322      img_init = { width: jQuery(theImg).width(), height: jQuery(theImg).height() };
1323
1324      if (typeof theImg.naturalWidth != "undefined")
1325        img_init.width = theImg.naturalWidth;
1326      if (typeof theImg.naturalHeight != "undefined")
1327        img_init.height = theImg.naturalHeight;
1328      img_init.rapport = img_init.width / img_init.height;
1329      if (typeof Zone_image == "undefined") Zone_image = { image: {} };
1330      if (typeof Zone_image.image == "undefined")
1331        Zone_image.image = { height: Zone_image.image_init.height, width: Zone_image.image_init.width };
1332      // theImg.height = img_init.height;
1333      // theImg.width = img_init.width;
1334
1335      Zone_image.image_init = { height: img_init.height, width: img_init.width, rapport: img_init.rapport };
1336      Zone_image.zoom = Zone_image.image_init.height / img_init.height;
1337
1338      if (typeof Zone_image.src == "undefined") {
1339        Zone_image.src = name_src;
1340        return false;
1341      }
1342      stx = name_src.match(RegExp(Zone_image.src, "gi"));
1343      return stx;
1344    };
1345    // ___________ init_img _______
1346
1347
1348
1349    // ===========================================
1350    //
1351    // ===========================================
1352    Set_Map = function (nds) {
1353      p0 = jQuery("#map").offset();
1354      if (!p0) return;
1355      infos_mapPicture = jQuery("#mapPicture").infos({ absolute: true });
1356      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });
1357      jQuery("#map").removeAttr("height");
1358      jQuery("#map").removeAttr("width");
1359      jQuery("#map").width(infos_theContainer.width - (infos_mapPicture.width));
1360      jQuery("#map").height(jQuery(window).height() - infos_theContainer.top - infos_theContainer.general.marges.height);
1361      return true;
1362    };
1363
1364    jQuery("map [name='#Autosize'] area").mouseover(function (e) {
1365      return;
1366    });
1367    // ___ Set_Map ___
1368
1369    // =====================================
1370    //
1371    // =====================================
1372    Get_Maxi = function (Maxi_image) {
1373      var pt = options.liste_type;
1374      if (pt.length > 0) {
1375        tw = Maxi_image.width;  // valeur maxi
1376        th = Maxi_image.height;  // valeur maxi
1377        n = 0;
1378        maxi_size = { w: Maxi_image.width, h: Maxi_image.height, idx: -1 };
1379        mini_size = { w: tw, h: th, idx: 0 };
1380        size_derive = { w: 0, h: 0 };
1381        size_encours = { w: tw, h: th };
1382        // =================================
1383        jQuery(pt).each(function (i) {
1384          vn = this;
1385          v_pictureDeriv = vn[0]; v_imgSrc = vn[1]; v_width = parseInt(vn[2]); v_height = parseInt(vn[3]);
1386          size_derive = { w: v_width, h: v_height };
1387          if (v_pictureDeriv == options.pictureSelType) {
1388            maxi_size = size_derive;
1389            maxi_size.idx = n;
1390            return false;
1391          }
1392
1393          if (v_pictureDeriv != "square" && v_pictureDeriv != "thumb" && v_pictureDeriv != "SelMaxi" && v_pictureDeriv != "Autosize") {
1394            if (size_derive.h > size_encours.h || v_pictureDeriv == "Original") {
1395              if (maxi_size.idx < 0) {
1396                maxi_size = size_derive;
1397                maxi_size.idx = n;
1398                if (options.pictureSelType == "SelMaxi" || options.pictureSelType == "Autosize")
1399                  return false;
1400              }
1401            }
1402            if (size_derive.h < size_encours.h && size_derive.h > 10) {
1403              mini_size = size_derive;
1404              mini_size.idx = n;
1405            }
1406          }
1407          n++;
1408        });
1409        n = maxi_size.idx;
1410        if (n < 0) {
1411          n = mini_size.idx;
1412        }
1413        if (options.pictureSelType.match(RegExp("SelMaxi", "gi"))) {
1414          n = mini_size.idx;
1415
1416        }
1417        if (options.pictureSelType.match(RegExp("Autosize", "gi"))) {
1418
1419        }
1420
1421        pictureDeriv = pt[n][0];
1422        last_id = pt[n][0];
1423        jQuery(".switchCheck").each(function (i) {
1424          if (this.id.match(RegExp("derivative", "gi"))) {
1425            if (!this.id.match(RegExp("Original", "gi"))) {
1426              if (this.id.match(RegExp("SelMaxi", "gi"))) return false;
1427              last_id = this.id.replace("derivativeChecked", "");
1428            }
1429            if (last_id == pictureDeriv)
1430              return false;
1431          }
1432        });
1433
1434        options.pictureDeriv = last_id;
1435
1436        return { url: pt[n][1], pictureDeriv: last_id, pictureMap: last_id, width: pt[n][2], height: pt[n][3] };
1437      }
1438      return { imgSrc: "", pictureDeriv: "", width: "", height: "" };
1439    };
1440    // _______________ Get_Maxi ______
1441
1442    /***************************************************************************
1443    * Selection de l'image
1444    **************************************************************************/
1445    Select_Image = function () {
1446      memoire = options.imgSrc;
1447      if (options.imgSrc.match(RegExp("gif", "gi")))
1448        return;
1449      var pt = options.liste_type;
1450      if (pt.length > 0) {
1451        // ===== calcul Image ===
1452        if (typeof imageInfos_id == "undefined") return;
1453        if (Calcul_Image() == "Wait") {   // image en cours
1454          return "Wait";
1455        }
1456        // ==================================================
1457        options.theContainerMargeZone = Zone_image.marges;
1458        if (Type_Img != 'charlie' && Type_Img != "pamoorama") {
1459          IMg = Get_Maxi(Zone_image.image);
1460          imgSrc = IMg.url;
1461          if (options.imgSrc.match(RegExp(imgSrc, "gi")))
1462            options.imgSrc = imgSrc;
1463          // dimension image
1464          img_width = IMg.width;
1465          img_height = IMg.height;
1466          Zone_image.image_init = { height: IMg.height,
1467            width: IMg.width,
1468            rapport: IMg.width / IMg.height
1469          };
1470          if (typeof Zone_image.image == "undefined")
1471            Zone_image.image = { height: IMg.height,
1472              width: IMg.width,
1473              rapport: IMg.width / IMg.height
1474            };
1475        } else {
1476          return;
1477        }
1478        Zone_image.zoom = Math.ceil(Zone_image.image.height / Zone_image.image_init.height);
1479        if (!theImg.src)
1480          return true;
1481        if (typeof Zone_image.src == "undefined")
1482          Zone_image.src = imgSrc;
1483        if (typeof Zone_image.name == "undefined")
1484          Zone_image.name = " ";
1485        if (typeof Zone_image.path == "undefined")
1486          Zone_image.path = " ";
1487
1488        imgSrcS = imgSrc.split('/');
1489        imgSrcS = imgSrcS[imgSrcS.length - 1];
1490        if (!theImg.src)
1491          return true;
1492        identique = theImg.src.match(RegExp(imgSrc, "gi"));
1493        if (identique) return true;
1494        href_path = get_href(IMg.pictureDeriv);
1495
1496        if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
1497          spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
1498          spans.attr("href", "javascript:" + href_path);
1499        }
1500        theImg = document.getElementById(theMainImage_id.replace("#", ""));
1501        if ((theImg == null) || theImg.tagName != "IMG") {
1502          imgSrc_i = jQuery(theImg).css("backgroundImage");
1503          imgSrc_j = jQuery(theImg).css("background-image");
1504          return true;
1505        } else {
1506          eval(href_path);
1507
1508        }
1509        theImg.useMap = "#map" + IMg.pictureMap;
1510        return true;
1511
1512      } else {
1513        return false;
1514      }
1515
1516    };  // _______________ Select_Image ______
1517
1518
1519    /***************************************************************************
1520    * correction pamoorama
1521    **************************************************************************/
1522    Set_Pamoorama = function (Format) {
1523      if (Type_Img == "pamoorama") {
1524        infos_pamoorama_outter = jQuery("#pamoorama_outter").infos({ absolute: true });
1525        infos_pamoorama_inner = jQuery("#pamoorama_inner").infos({ absolute: true });
1526        infos_pamoorama_frame = jQuery("#pamoorama_frame").infos({ absolute: true });
1527        infos_frame = jQuery(myPamoorama.frame).infos({ absolute: true });
1528        // ====================================================
1529        marges_w = infos_pamoorama.general.marges.width;
1530        marges_h = infos_pamoorama.general.marges.height;
1531
1532        jQuery("#pamoorama_footer").css({
1533          width: Format.width + "px"
1534        });
1535        infos_pamoorama_footer = jQuery("#pamoorama_footer").infos();
1536        marges_h += infos_pamoorama_footer.general.height;
1537        outter_height = Format.height;
1538
1539        Zoom_pano = (Format.height - marges_h) / Zone_image.image_init.height;
1540        new_image = { height: Math.ceil(Zone_image.image_init.height * Zoom_pano),
1541          width: Math.ceil(Zone_image.image_init.width * Zoom_pano)
1542        };
1543
1544        jQuery("#pamoorama_inner").css({
1545          width: new_image.width + "px", height: new_image.height + "px", "background-size": "100%"
1546        });
1547        // ---------- test largeur image
1548        new_width = Format.width; // -(options.marge_right +
1549        // options.marge_left);
1550
1551        if (new_width > new_image.width) {
1552          new_width = new_image.width;
1553          jQuery("#pamoorama_outter").css({
1554
1555            align: "center",
1556            margin: "0"
1557          });
1558        }
1559        outter_width = new_width;
1560
1561        jQuery("#pamoorama_outter").css({
1562          align: 'center',
1563          margin: 'auto',
1564          width: outter_width + "px",
1565          height: Format.height - marges_h + "px"
1566        });
1567        // ============= Mise à l'echelle ==================
1568        window.myPamoorama.options.width = Math.ceil(Format.width);
1569        // ==================================================================
1570        new_max_left = new_image.width - outter_width;
1571        if (!window.myPamoorama.outter) return;
1572        window.myPamoorama.outter.scrollTo(new_max_left, 0);
1573
1574        if (typeof window.myPamoorama.autoScrollFx != "undefined") window.myPamoorama.autoScrollFx.to = new Array(new_max_left, 0);
1575        window.myPamoorama.ratio = Math.ceil(new_image.width / 200);
1576        window.myPamoorama.imageWidth = new_image.width;
1577        window.myPamoorama.imageHeight = new_image.height;
1578        nf = jQuery("#pamoorama_thumb").height();
1579        jQuery("#pamoorama_thumb img").width(200);
1580        jQuery("#pamoorama_thumb img").height(nf);
1581
1582        jQuery("#pamoorama_thumb").css({
1583          /* position: "absolute", */
1584          left: (Format.width - 215) + "px"
1585
1586        });
1587        jQuery("#pamoorama_thumb img").css({
1588
1589        });
1590        // 200=window.myPamoorama.width
1591        // frame = Zone_image.container.width
1592
1593        nw = (window.myPamoorama.image.width * Format.width) / window.myPamoorama.imageWidth;
1594        jQuery("#pamoorama_frame").width(nw);
1595
1596
1597        if (window.myPamoorama.options.autoscrollOnLoad && infos_frame) {
1598          window.myPamoorama.startAnimRight();
1599        }
1600      } // 
1601    }; // Set_Pamoorama
1602
1603    /** ****************************************************** */
1604
1605    Toggle_bp = function () {
1606      options.cl_visible = !options.cl_visible;
1607      Autosize_resize();
1608      Wait_Affichage();
1609
1610    };
1611
1612    // ====================================
1613    //
1614    // ====================================
1615    Calcul_Image = function () {
1616
1617      /** ************************************* */
1618      if (typeof imageInfos_id == "undefined") return;
1619      infos_imageInfos = jQuery(imageInfos_id).infos({ absolute: true });             // information
1620      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });         // Image
1621      // commentContent
1622      // copyright
1623
1624      if (options.slideshow) {
1625
1626
1627      } else {
1628
1629      }
1630      if (typeof Zone_image.name == "undefined") {
1631        var names = Array();
1632        names = options.imgSrc.toString().split("/");
1633        names = names[names.length - 1].split("-");
1634        names = names[0].split(".");
1635        Zone_image.name = names[0];
1636      }
1637
1638      if (Type_Img == "img") {
1639        Zone_image.src = jQuery(theMainImage_id).attr("src");
1640        if (typeof Zone_image.src != "undefined") {
1641          if (Zone_image.src.match(RegExp(Zone_image.name, "gi"))) {
1642            Zone_image.path = infos_theMainImage.src;
1643          } else
1644            return "Wait";
1645        } else {
1646          Zone_image.src = "";
1647          Zone_image.path = "";
1648        }
1649      } else {
1650        Zone_image.src = jQuery(theMainImage_id).attr("src");
1651        Zone_image.path = infos_theMainImage.src;
1652      }
1653      pos_top = options.pos_top;
1654      // pos_top = infos_theContainer.top;
1655
1656      pos = jQuery(theImage_id).offset();
1657      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });   // container
1658      infos_window = jQuery(window).infos({ absolute: true });   // window
1659      w = infos_theContainer.general.marges.width;
1660
1661      container = {
1662        height: infos_window.height - options.theContainerTop,
1663        width: infos_window.width - options.theContainerLeft - options.theContainerRight
1664      };
1665      marge_left = options.marge_left | 0;
1666      marge_right = options.marge_right | 0;
1667      marge_top = options.marge_top | 0;
1668
1669
1670      // ==========================================================
1671      if (test_theme("stripped")) {
1672        infos_the_page.margin.left = 20;  // taille fleche
1673        infos_the_page.margin.right = 20;
1674
1675      } else if (test_theme("kardon")) {
1676
1677      } else if (test_theme("elegant")) {
1678
1679        if (infos_imageInfos.visible == true) {
1680          // marge_right += infos_imageInfos.general.width; ;
1681
1682        } else {
1683          marge_right += 0;
1684
1685        }
1686        marge_right += 1;
1687        marge_left += 1;
1688
1689      } else if (test_theme("stripped")) {
1690
1691      } else if (test_theme("simple")) {
1692        infos_menubar = jQuery("#menubar").infos({ absolute: true });
1693        infos_imageInfoBar = jQuery("#imageInfoBar").infos({ absolute: true });
1694
1695        if (infos_imageInfoBar.left - infos_theContainer.left - 2 > 0) {
1696          jQuery(theImage_id).width(infos_imageInfoBar.left - infos_theContainer.left - 2);
1697        }
1698        marge_left += 0;
1699        marge_right += 0;
1700
1701      } else if (test_theme("OS")) {
1702
1703      } else if (test_theme("pur")) {
1704        marge_right += 0;
1705        // marge_right += 25;
1706      } else if (test_theme("mont")) {
1707        marge_right += 0;
1708
1709        // marge_right += 25;
1710
1711
1712      } else {
1713
1714
1715
1716      }
1717
1718
1719      retrait_img = {};
1720      // ========== Format Image ==============
1721      retrait_img.height = Math.ceil(options.marges_llgbo || 0)
1722      + Math.ceil(infos_theMainImage.general.marges.height) +
1723      +Math.ceil(options.marges_llgbo || 0);
1724      retrait_img.height += 2;
1725
1726
1727      // ===============================================================
1728      retrait_img.width = Math.ceil(infos_theMainImage.general.marges.width); // borderwidth+padding
1729      retrait_img.width = Math.ceil(infos_theContainer.general.marges.width); // borderwidth+padding
1730      retrait_img.width += Math.ceil(options.marges_llgbo || 0);
1731      retrait_img.width += 2;
1732      if (!options.check_desc_v)
1733        options.marge_bottom_2 = 0;
1734
1735      marge_bottom = options.marge_bottom_2 + options.marge_bottom;
1736      // ================== Limite Format Image =====================
1737      container.height_interne = container.height - marge_top - marge_bottom;
1738      container.width_interne = container.width - marge_left - marge_right;
1739
1740      container.height_interne = Math.max(
1741                  container.height_interne,
1742                  Math.ceil(options.mini_height) + retrait_img.height);
1743      container.width_interne = Math.max(container.width_interne,
1744                  Math.ceil(options.mini_width) + retrait_img.width);
1745      image_max = {
1746        height: (container.height_interne - retrait_img.height),
1747        width: (container.width_interne - retrait_img.width)
1748      };
1749      // =========================
1750      // test débordement
1751      // =========================
1752      height_theMainImage = Math.ceil(image_max.height);
1753      width_theMainImage = Math.ceil(image_max.width);
1754
1755      if (Type_Img == "charlie") {
1756        height_theMainImage = Math.ceil(width_theMainImage / options.ratio);
1757
1758        Zone_image.image_init = {
1759          width: width_theMainImage, height: height_theMainImage,
1760          rapport: options.ratio
1761        };
1762
1763      } else if (Type_Img == "pamoorama") {
1764        if (height_theMainImage > container.height_interne) {
1765          n = options.pictureSelType;
1766        }
1767      } else {
1768
1769        height_theMainImage = Math.ceil(width_theMainImage / options.ratio);
1770        // --- test si taille image inferieur au container
1771        if (height_theMainImage > container.height_interne) {
1772          image_max.height = container.height_interne;
1773          image_max.width = image_max.height * Zone_image.image_init.rapport;
1774          width_theMainImage = Math.ceil(image_max.width);
1775          height_theMainImage = Math.ceil(image_max.height);
1776        }
1777        if (width_theMainImage > container.width_interne) {
1778          image_max.width = container.width_interne;
1779          image_max.height = image_max.width / Zone_image.image_init.rapport;
1780          width_theMainImage = Math.ceil(image_max.width);
1781          height_theMainImage = Math.ceil(image_max.height);
1782
1783        }
1784      }
1785      // ======== Initilisation Zone_image ===============
1786      Zone_image.image = {
1787        width: width_theMainImage,
1788        height: height_theMainImage,
1789        rapport: width_theMainImage / height_theMainImage
1790      };
1791      Zone_image.marges = { width: marge_left + marge_right + retrait_img.width,
1792        height: marge_top + marge_bottom + retrait_img.height
1793      };
1794      return true;
1795    };
1796
1797    /***************************************************************************
1798    * Calcul les dimensions.
1799    **************************************************************************/
1800    Get_dimensions = function (force, parametres) {
1801      new_img = jQuery(theMainImage_id).infos({ absolute: true });  // image
1802      Container = jQuery(theImage_id).infos({ absolute: true });    // containeur
1803      new_win = jQuery(window).infos({ absolute: true });           // avec
1804      // ascenseur
1805      options.theContainerTop = Container.top;
1806      options.theContainerLeft = Container.left;
1807      options.theContainerRight = (new_win.width - Container.right);
1808      options.marge_bottom_2 = Math.ceil(Container.out.bottom - new_img.bottom); // marge
1809      // avec
1810      // infos
1811      options.marge_top_2 = options.marge_top_2 | 0;
1812      Container.out.bottom = new_win.height - options.marge_bottom_2;
1813      options.theContainerBottom = new_win.height - Container.out.bottom;
1814      if (options.slideshow) {
1815        options.marge_top = 0;
1816      } else {
1817        options.marge_top_2 = Math.ceil(new_img.top - Container.top) + options.marge_top;
1818      }
1819
1820      options.theContainerWidth = new_win.width - options.theContainerLeft - options.theContainerRight;
1821      options.theContainerHeight = new_win.height - options.marge_top - options.theContainerBottom - options.theContainerTop;
1822
1823      if (Type_Img != "map" && Type_Img != "iframe")
1824        if (Select_Image() == "Wait") {
1825          return "Wait";
1826        }
1827      useMap = options.pictureSelType;
1828      // =================================================================
1829      switch (Type_Img) {
1830        case "map":
1831          if (Set_Map(true)) return false;
1832          break;
1833        case "panorama":
1834          if (!theMainImage_id) {
1835
1836          }
1837          infos_theContainer = jQuery(theMainImage_id).infos();
1838          infos_the_page = jQuery("#the_page").infos();
1839          if (typeof img_finale == "undefined")
1840            img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
1841          img_finale.height = infos_theContainer.height;
1842          break;
1843        case "img":
1844          break;
1845        case "img_autre":
1846          if (!theMainImage_id) {
1847            if (DEBUG_autosize.match("true", "gi")) alert("The_MainImage=null");
1848            return;
1849
1850          }
1851
1852          infos_the_page = jQuery("#the_page").infos();
1853
1854
1855          break;
1856        case "embed":
1857          //
1858          if (infos_theMainImage.width == 0)
1859            infos_theMainImage = jQuery("#thePicturePage").infos();
1860          if (infos_theMainImage.width == 0)
1861            infos_theMainImage = jQuery("#the_page").infos();
1862          iph1 = jQuery("#theImage div").infos();
1863          break;
1864        case "charlie":
1865          Zone_image.zoom = 1;
1866          Zone_image.image.width = options.theContainerWidth;
1867          Zone_image.image.height = options.theContainerHeight;
1868          break;
1869        case "iframe":
1870          wpng = 0;
1871          Zone_image.image.width = options.theContainerWidth;
1872          Zone_image.image.height = options.theContainerHeight;
1873          Zone_image.zoom = 1;
1874          break;
1875        case "pamoorama":
1876          if (nopano == false) Wait_pamoorama();
1877          break;
1878      }
1879      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") return true;
1880      if (Type_Img != "pamoorama") {
1881        // =========== test Hauteur Mini ====================
1882        if (Zone_image.image.height < options.mini_height2) {
1883          Zone_image.image.height = parseInt(options.mini_height2);
1884          Zone_image.image.width = Math.ceil(Zone_image.image.height * Zone_image.image_init.rapport);
1885        }
1886        // =========== test Largeur Mini ====================
1887        if (Zone_image.image.width < options.mini_width2) {
1888          Zone_image.image.width = parseInt(options.mini_width2);
1889          Zone_image.image.height = Math.ceil(Zone_image.image.width / Zone_image.image_init.rapport);
1890        }
1891      }
1892      // Calcul du rapport d'agrandissement
1893      echelle_max = parseFloat(options.echelle_max, '3');
1894      // =========== test Zoom Maxi ====================
1895      Zone_image.zoom = Zone_image.image.height / Zone_image.image_init.height;
1896      if (Zone_image.zoom > echelle_max) {
1897        Zone_image.zoom = echelle_max;
1898        if (Type_Img == "pamoorama") {
1899          Zone_image.image.height = parseInt(Zone_image.image_init.height * Zone_image.zoom);
1900        } else {
1901          Zone_image.image.width = parseInt(Zone_image.image_init.width * Zone_image.zoom);
1902
1903          if (Zone_image.image_init.rapport > 0)
1904            Zone_image.image.height = parseInt(Zone_image.image.width / Zone_image.image_init.rapport);
1905        }
1906      }
1907      if (Type_Img != "pamoorama") {
1908        mxi = Math.ceil(Zone_image.image.height + Zone_image.marges.height);
1909        Zone_image.container.height = Math.max(Zone_image.container.height | mxi, mxi);
1910        mxi = Math.ceil(Zone_image.image.width + Zone_image.marges.width);
1911        Zone_image.container.width = Math.max(Zone_image.container.width | mxi, mxi);
1912        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
1913      } else {
1914        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
1915      }
1916
1917      return true;
1918    };
1919    // ________________ Get_dimensions ___________________
1920
1921
1922    /***************************************************************************
1923    * init_gen
1924    **************************************************************************/
1925    init_gen = function (e) {
1926      theImg = document.getElementById(theMainImage_id.replace("#", ""));
1927      // ==================================================
1928      marges_llgbo = 0;
1929      options.marges_llgbo = 0;
1930      if (jQuery(llgbo_id).length > 0) {
1931        infos_llgbo = jQuery(llgbo_id).infos({ absolute: true });
1932        if (infos_llgbo.visible == true) {
1933          if (infos_llgbo.height > 0) {
1934            infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
1935            infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
1936            // =============================================
1937            ll2 = infos_llgboframe1.width; // llgboframe1
1938            ll1 = infos_llgboframe31.general.width; // llgboframe31
1939            options.marges_llgbo = (ll1 - ll2);
1940            infos_llgboh2 = jQuery("#llgboh2").infos();
1941          }
1942        }
1943
1944        marges_llgbo = options.marges_llgbo;
1945      }
1946
1947      // ========= Récupération des informations =============
1948
1949      options.marge_top = 0;
1950      pAll = jQuery(llgbo_id).absoluteAll({ absolute: true });
1951      infos_llgbo.top = pAll.Top;
1952      infos_llgbo.bottom = pAll.Bottom;
1953      pAll = jQuery(theMainImage_id).absoluteAll({ absolute: true });
1954      pos_top = pAll.Top; ;
1955      pos_bottom = pAll.Bottom; ;
1956      if (infos_llgbo.top > 0) {
1957        pos_top = infos_llgbo.top;
1958        options.marge_top = infos_theMainImage.top - infos_theContainer.top;
1959        options.marge_bottom = Math.ceil(options.marge_basse + options.marge_top);
1960
1961      } else {
1962        pos_top = infos_theImageAndInfos.top;
1963        options.marge_bottom = Math.ceil(options.marge_basse);
1964      }
1965
1966      options.pos_top = pos_top;
1967      new_img = jQuery(theMainImage_id).infos({ absolute: true });
1968      Container = jQuery(theImage_id).infos({ absolute: true });
1969      options.marge_top += Math.ceil(new_img.top - Container.top);
1970
1971
1972      options.marge_left = infos_theContainer.general.marges.left + Math.ceil(options.marge_gauche);
1973      options.marge_right = infos_theContainer.general.marges.right + Math.ceil(options.marge_droite);
1974      options.marge_top += infos_theContainer.general.marges.top +
1975                           infos_content.general.marges.top +
1976                           Math.ceil(options.marge_haute);
1977
1978
1979      if (options.pictureDeriv == null)
1980        options.first = true;
1981      else
1982        options.first = false;
1983      // =================== Gestion liste photos size
1984      us = 0;
1985      if (!options.theMainImageWidth) options.theMainImageWidth = options.scaledWidth;
1986      if (!options.theMainImageHeight) options.theMainImageHeight = options.scaledHeight;
1987
1988      if (options.first) {
1989        if (options.pictureDeriv) {
1990
1991          pictureSelType = options.pictureSelType;
1992          options.pictureMap = options.pictureDeriv;
1993
1994        } else {
1995          IMg = Get_Maxi(Zone_image.image);
1996          options.pictureDeriv = IMg.pictureDeriv;
1997          imgSrc = IMg.url;
1998          width = IMg.width;
1999          height = IMg.height;
2000          options.pictureDeriv = IMg.pictureDeriv;
2001          options.pictureMap = IMg.pictureMap;
2002        }
2003      }
2004      if (pictureSelType_user != options.pictureSelType) {
2005        /*
2006        * user_status = options.user_status; pictureSelType_user =
2007        * eval("options." + user_status + "_type"); //limite taille
2008        */
2009        pictureDeriv_user = options.pictureDeriv;
2010        options.pictureDeriv_user = pictureDeriv_user;
2011        pictureSelType = options.pictureSelType;
2012      }
2013      // Affiche_limite(pictureSelType_user);
2014      pictureDeriv = Ajuste_Liens();
2015
2016      Autosize_resize(true, options);
2017      Autosize_resize(true, options);
2018      jQuery("#" + Type_Img).show(fade_in);
2019    };
2020    // _______________________ init_gen _______________________
2021
2022
2023    /***************************************************************************
2024    * DEBUG ....
2025    **************************************************************************/
2026    /*
2027    * if (DEBUG_autosize.match("true",gi)) { for (var i = 0; i < 10; i++) {
2028    * jQuery('#adddebugs').click(); } jQuery(jQuery('.debug').get(i -
2029    * 1)).click(); }
2030    */
2031
2032    // Custom Event, ON to turn on a debug.
2033    jQuery('.debug').live('ON', function (e) {
2034
2035      nu_img = jQuery(this).text();
2036      jQuery('.debug').trigger('OFF');
2037      jQuery(this).addClass('debugOn');
2038
2039    });
2040
2041    // On Click = debugs On
2042    jQuery('.debug').live('click', function (e) {
2043      i = jQuery(this).text();
2044      jQuery(this).trigger('ON');
2045    });
2046
2047    // Custom Event, Turn off a debug
2048    jQuery('.debug').live('OFF', function (e) {
2049      jQuery(this).removeClass('debugOn');
2050    });
2051
2052    // on Double Click, remove the debug from the DOM
2053    jQuery('.debug').live('dblclick', function () {
2054      jQuery(this).fadeOut(function () { jQuery(this).remove(); });
2055    });
2056
2057    // Add another debug to the DOM
2058    jQuery('#adddebugs').click(function () {
2059      i = jQuery('.debug').length;
2060      jQuery('<div>' + i + '</div>')
2061    .addClass('debug')
2062    .appendTo('#debugsContainer');
2063    });
2064
2065
2066
2067    if (DEBUG_autosize.match("mouse", "gi")) {
2068      var mouseLocation = new Point(-500, -500);
2069      function Point(x, y) {
2070        this.x = x; this.y = y;
2071      }
2072      register_position();
2073
2074      function register_position() {
2075        mouse_x = 0;
2076        mouse_y = 0;
2077        // document.onmousemove = position;
2078
2079      }
2080
2081      function position(evt) {
2082        if (!evt) evt = window.event;
2083        mouseLocation.x = evt.clientX;
2084        mouseLocation.y = evt.clientY;
2085      }
2086
2087      jQuery("div,a,img").mousemove(function (evt) {
2088
2089        if (!evt) evt = window.event;
2090        mouseLocation.x = evt.clientX;
2091        mouseLocation.y = evt.clientY;
2092        Context = jQuery(this).context.nodeName;
2093        obj_id = "#" + this.id.toString();
2094        infos_g = jQuery(obj_id).infos({ absolute: true });
2095        infos_g.top = jQuery(obj_id).absoluteTop();
2096        wg = jQuery("body").width() - infos_g.right;
2097
2098        affiche_debug({
2099
2100          Debug1: Debug_info(1, "x:" + mouseLocation.x
2101    + " y: " + mouseLocation.y
2102    + " id: " + obj_id
2103    + " top: " + infos_g.top,
2104    +" Node: " + Context
2105    , "->")
2106    ,
2107          Debug2: Debug_info(2, "W:" + infos_g.general.width
2108    + " H: " + infos_g.general.height
2109    + " right: " + (wg)
2110    + " left: " + infos_g.left
2111    + " Node: " + Context
2112    , "->")
2113        });
2114
2115      });
2116
2117    }
2118
2119
2120    // =======================================================================================
2121    Debug_info = function (index, infos, Nom_str) {
2122      if (typeof infos == "undefined") return;
2123      width_g = Math.ceil(jQuery("body").width() / 5) - 10;
2124      if (typeof infos.height != "undefined") {
2125        message = " -- > Info : " + Nom_str + " " + infos.id + "\n" +
2126                         "Info nodeName: " + infos.nodeName + "\n" +
2127                         "Info width: " + infos.width + "\n" +
2128                         "Info height: " + infos.height + "\n" +
2129                         "Info top: " + infos.top + "\n" +
2130                         "Info left: " + infos.left + "\n" +
2131                         "Info position: " + infos.position + "\n";
2132
2133        myDebug = { id: "Debug" + index, texte: message,
2134          css: {
2135            color: "black",
2136            opacity: "1",
2137            position: "absolute",
2138            height: infos.height || pos_top - 30 + "px",
2139            width: infos.width || width_g + "px",
2140            left: infos.left || 0 + "px",
2141            border: "solid 1px green",
2142            top: infos.top + "px"
2143          }
2144        };
2145        return myDebug;
2146
2147      } else {
2148        if (typeof old_messages == "undefined") {
2149          old_messages = new Array();
2150
2151        }
2152        if (infos != "" && infos != "undefined") {
2153          nc0 = old_messages[index] || "";
2154          if (typeof nc0 != "undefined") {
2155            nc0 = nc0.toString().split("<br />");
2156            if (nc0.length > 4) nc0.shift();
2157            old_messages[index] = nc0.join("<br />");
2158          }
2159          old_messages[index] += "" + Nom_str + "->" + infos + "<br />";
2160          message = old_messages[index];
2161          colors = Array('black', 'white', 'white', 'white', 'white', 'white', 'red');
2162          myDebug = { id: "Debug" + index, texte: message,
2163            css: { display: "block",
2164              color: colors[index - 1],
2165              opacity: "1",
2166              position: "absolute",
2167              align: "left",
2168              height: 80 + "px",
2169              width: width_g + "px",
2170              left: ((index - 1) * width_g) + "px",
2171              border: "solid 1px green",
2172              top: 0 + "px"
2173            }
2174          };
2175          return myDebug;
2176        }
2177      }
2178
2179
2180    }; // Debug_info
2181    // ====================================================
2182    affiche_debug = function (aff_infos) {
2183      jQuery(jQuery("[id ^='Debug']")).each(function (i) {
2184        if (aff_infos[this.id]) {
2185          if (aff_infos[this.id].css) {
2186            jQuery("#" + this.id).css(aff_infos[this.id].css);
2187            jQuery("#" + this.id).html(aff_infos[this.id].texte);
2188          }
2189        }
2190      });
2191      return;
2192    };
2193    // ___________ affiche_debug ____
2194    // ====================================================
2195    function Debug_pos() {
2196      return;
2197      if (DEBUG_autosize.match("true", gi)) {
2198
2199        jQuery("[id ^='Debug']").show();
2200        /*
2201        * Debug2 background-color:yellow Debug3 background-color:blue Debug4
2202        * background-color:green Debug5 background-color:red
2203        *
2204        */
2205
2206        affiche_debug({
2207          Debug5: Debug_info(5, infos_theMainImage, "infos_theMainImage")
2208        });
2209      }
2210    } // Debug_pos
2211    // ==========================================================
2212
2213  });                                                 // ready
2214  jQuery("#derivativeSwitchBox a").click(function (e) {
2215    k1 = 0;
2216  });
2217  // ==========================================================
2218  if(typeof changeImgSrc=="undefined"){
2219  function changeImgSrc(url, typeSave, typeMap) {
2220    var theImg = document.getElementById("theMainImage");
2221    if (theImg) {
2222      theImg.removeAttribute("width"); theImg.removeAttribute("height");
2223      theImg.src = url;
2224      theImg.useMap = "#map" + typeMap;
2225    }
2226    jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
2227    jQuery('#derivativeChecked' + typeSave).css('visibility', 'visible');
2228    document.cookie = 'picture_deriv=' + typeSave + ';path='+options.COOKIE_PATH;
2229  }
2230  }
Note: See TracBrowser for help on using the repository browser.