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

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