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

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

[extensions] Autosize update to piwigo 2.5 (fix init)

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