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

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

[extensions] Autosize fix compatibility with 2.4, update

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