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

Last change on this file since 17538 was 17538, checked in by cljosse, 12 years ago

[extensions] Autosize fix compatibility with 2.4, update

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