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

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

[extensions] Autosize update to piwigo 2.5 (fix bugs with jquery 1.9 )

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