PageSourceSearch

https://www.tours-tourism.co.uk/script/scripts/gmaps.leaflet_otmKe…w8_FgOCbn3wdrhs-sitekey-ot-tours-v-2.1-W.js

js tours-tourism.co.uk collected 2026-10-08 05:53:04 UTC 88,555 bytes, 2,909 lines download raw bytes

1var myScript = document.currentScript || (function() {
2	var scripts = document.getElementsByTagName('script');
3	return scripts[scripts.length - 1];
4})();
5
6var infobox, map, mapHeight, mapWidth, mapDiv, fullScreenDiv, mapParent, oldScroll, currentPOI, topControlsDiv, fromCol;
7var markersLayer = L.layerGroup();
8var markers = markerClusterer = previewMaps = globalPanelArray = globalDivArray = listFiches = [];
9var detailPanel = false;
10var markersFacette = {};
11var defaultLng = 2.303466;
12var defaultLat = 46.593599;
13var uf = '';
14
15function createNewEvent(eventName) {
16	var event;
17	if (typeof(Event) === 'function') {
18		event = new Event(eventName);
19	} else {
20		event = document.createEvent('Event');
21		event.initEvent(eventName, true, true);
22	}
23	return event;
24}
25
26// (function () {
27
28// 	if (!L) return;
29
30//     L.Control.FullScreen = L.Control.extend({
31//         options: {
32//             position: 'topleft',
33//             title: '', // Full Screen
34//             titleCancel: '', // Exit Full Screen
35//             forceSeparateButton: fal
35se,
36//             forcePseudoFullscreen: false,
37//             fullscreenElement: false
38//         },
39
40//         onAdd: function (map) {
41//             var className = 'leaflet-control-zoom-fullscreen', container, content = '';
42
43//             if (map.zoomControl && !this.options.forceSeparateButton) {
44//                 container = map.zoomControl._container;
45//             } else {
46//                 container = L.DomUtil.create('div', 'leaflet-bar');
47//             }
48
49//             if (this.options.content) {
50//                 content = this.options.content;
51//             } else {
52//                 className += 'icon icon-font-zoom-in';
53//             }
54
55//             this._createButton(this.options.title, className, content, container, this.toggleFullScreen, this);
56
57//             this._map.on('enterFullscreen exitFullscreen', this._toggleTitle, this);
58
59//             return container;
60//         },
61
62//         _createButton: function (title, className, content, container, fn, context) {
63//             this.link = L.DomUtil.create('a', className, container);
64//             this.link.href = '#';
65//             this.link.title = title;
66//             this.link.innerHTML = content;
67
68//             L.DomEvent
69//                 .addListener(this.link, 'click', L.DomEvent.stopPropagation)
70//                 .addListener(this.link, 'click', L.DomEvent.preventDefault)
71//                 .addListener(this.link, 'click', fn, context);
72
73//             L.DomEvent
74//                 .addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
75//                 .addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
76//                 .addListener(container, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context);
77
78//             L.DomEvent
79//                 .addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
80//                 .addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
81//                 .addListener(document, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context);
82
83//             return this.link;
84//         },
85
86//         toggleFullScreen: function () {
87//             var map = this._map;
88//             map._exitFired = false;
89//             if (map._isFullscreen) {
90//                 if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
91//                     fullScreenApi.cancelFullScreen();
92//                 } else {
93//                     L.DomUtil.removeClass(this.options.fullscreenElement ? this.options.fullscreenElement : map._container, 'leaflet-pseudo-fullscreen');
94//                 }
95//                 map.fire('exitFullscreen');
96//                 map._exitFired = true;
97//                 map._isFullscreen = false;
98//             }
99//             else {
100//                 if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
101//                     fullScreenApi.requestFullScreen(this.options.fullscreenElement ? this.options.fullscreenElement : map._container);
102//                 } else {
103//                     L.DomUtil.addClass(this.options.fullscreenElement ? this.options.fullscreenElement : map._container, 'leaflet-pseudo-fullscreen');
104//                 }
105//                 map.fire('enterFullscreen');
106//                 map._isFullscreen = true;
107//             }
108//         },
109
110//         _toggleTitle: function () {
111//             this.link.title = this._map._isFullscreen ? this.options.title : this.options.titleCancel;
112//         },
113
114//         _handleFullscreenChange: function () {
115//             var map = this._map;
116//             map.invalidateSize();
117//             if (!fullScreenApi.isFullScreen() && !map._exitFired) {
118//                 map.fire('exitFullscreen');
119//                 map._exitFired = true;
120//                 map._isFullscreen = false;
121//             }
122//         }
123//     });
124
125//     L.Map.addInitHook(function () {
126//         if (this.options.fullscreenControl) {
127//             this.fullscreenControl = L.control.fullscreen(this.options.fullscreenControlOptions);
128//             this.addControl(this.fullscreenControl);
129//         }
130//     });
131
132//     L.control.fullscreen = function (options) {
133//         return new L.Control.FullScreen(options);
134//     };
135
136//     /*
137//     Native FullScreen JavaScript API
138//     -------------
139//     Assumes Mozilla naming conventions instead of W3C for now
140
141//     source : http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
142
143//     */
144
145//         var
146//             fullScreenApi = {
147//                 supportsFullScreen: false,
148//                 isFullScreen: function () { return false; },
149//                 requestFullScreen: function () {},
150//                 cancelFullScreen: function () {},
151//                 fullScreenEventName: '',
152//                 prefix: ''
153//             },
154//             browserPrefixes = 'webkit moz o ms khtml'.split(' ');
155
156//         // check for native support
157//         if (typeof document.exitFullscreen !== 'undefined') {
158//             fullScreenApi.supportsFullScreen = true;
159//         } else {
160//             // check for fullscreen support by vendor prefix
161//             for (var i = 0, il = browserPrefixes.length; i < il; i++) {
162//                 fullScreenApi.prefix = browserPrefixes[i];
163//                 if (typeof document[fullScreenApi.prefix + 'CancelFullScreen'] !== 'undefined') {
164//                     fullScreenApi.supportsFullScreen = true;
165//                     break;
166//                 }
167//             }
168//             if (typeof document['msExitFullscreen'] !== 'undefined') {
169//                 fullScreenApi.prefix = 'ms';
170//                 fullScreenApi.supportsFullScreen = true;
171//             }
172//         }
173
174//         // update methods to do something useful
175//         if (fullScreenApi.supportsFullScreen) {
176//             if (fullScreenApi.prefix === 'ms') {
177//                 fullScreenApi.fullScreenEventName = 'MSFullscreenChange';
178//             } else {
179//                 fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
180//             }
181//             fullScreenApi.isFullScreen = function () {
182//                 switch (this.prefix) {
183//                     case '':
184//                         return document.fullscreen;
185//                     case 'webkit':
186//                         return document.webkitIsFullScreen;
187//                     case 'ms':
188//                         return document.msFullscreenElement;
189//                     default:
190//                         return document[this.prefix + 'FullScreen'];
191//                 }
192//             };
193//             fullScreenApi.requestFullScreen = function (el) {
194//                 switch (this.prefix) {
195//                     case '':
196//                         return el.requestFullscreen();
197//                     case 'ms':
198//                         return el.msRequestFullscreen();
199//                     default:
200//                         return el[this.prefix + 'RequestFullScreen']();
201//                 }
202//             };
203//             fullScreenApi.cancelFullScreen = function () {
204//                 switch (this.prefix) {
205//                     case '':
206//                         return document.exitFullscreen();
207//                     case 'ms':
208//                         return document.msExitFullscreen();
209//                     default:
210//                         return document[this.prefix + 'CancelFullScreen']();
211//                 }
212//             };
213//         }
214
215//         // jQuery plugin
216//         if (typeof jQuery !== 'undefined') {
217//             jQuery.fn.requestFullScreen = function () {
218//                 return this.each(function () {
219//                     var el = jQuery(this);
220//                     if (fullScreenApi.supportsFullScreen) {
221//                         fullScreenApi.requestFullScreen(el);
222//                     }
223//                 });
224//             };
225//         }
226
227//         // export api
228//         window.fullScreenApi = fullScreenApi;
229//     })();
230
231
232if (window.google && google.maps && !L.Google) {
233    /*
234    * L.TileLayer is used for standard xyz-numbered tile layers.
235    */
236
237    L.Google = L.Class.extend({
238        includes: L.Mixin.Events,
239
240        options: {
241            minZoom: 0,
242            maxZoom: 18,
243            tileSize: 256,
244            subdomains: 'abc',
245            errorTileUrl: '',
246            attribution: '',
247            opacity: 1,
248            continuousWorld: false,
249            noWrap: false,
250        },
251
252        // Possible types: SATELLITE, ROADMAP, HYBRID
253        initialize: function(type, options) {
254            L.Util.setOptions(this, options);
255
256            this._type = google.maps.MapTypeId[type || 'SATELLITE'];
257        },
258
259        onAdd: function(map, insertAtTheBottom) {
260            this._map = map;
261            this._insertAtTheBottom = insertAtTheBottom;
262
263            // create a container div for tiles
264            this._initContainer();
265            this._initMapObject();
266
267            // set up events
268            map.on('viewreset', this._resetCallback, this);
269
270            this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this);
271            map.on('move', this._update, this);
272            //map.on('moveend', this._update, this);
273
274            this._reset();
275            this._update();
276        },
277
278        onRemove: function(map) {
279            this._map._container.removeChild(this._container);
280            //this._container = null;
281
282            this._map.off('viewreset', this._resetCallback, this);
283
284            this._map.off('move', this._update, this);
285            //this._map.off('moveend', this._update, this);
286        },
287
288        getAttribution: function() {
289            return this.options.attribution;
290        },
291
292        setOpacity: function(opacity) {
293            this.options.opacity = opacity;
294            if (opacity < 1) {
295                L.DomUtil.setOpacity(this._container, opacity);
296            }
297        },
298
299        _initContainer: function() {
300            var tilePane = this._map._container,
301                first = tilePane.firstChild;
302
303            if (!this._container) {
304                this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left');
305                this._container.id = "_GMapContainer";
306            }
307
308            if (true) {
309                tilePane.insertBefore(this._container, first);
310
311                this.setOpacity(this.options.opacity);
312                var size = this._map.getSize();
313                this._container.style.width = size.x + 'px';
314                this._container.style.height = size.y + 'px';
315            }
316        },
317
318        _initMapObject: function() {
319            this._google_center = new google.maps.LatLng(0, 0);
320            var map = new google.maps.Map(this._container, {
321                center: this._google_center,
322                zoom: 0,
323                mapTypeId: this._type,
324                disableDefaultUI: true,
325                keyboardShortcuts: false,
326                draggable: false,
327                disableDoubleClickZoom: true,
328                scrollwheel: false,
329                streetViewControl: false
330            });
331
332            var _this = this;
333            this._reposition = google.maps.event.addListenerOnce(map, "center_changed",
334                function() { _this.onReposition(); });
335
336            map.backgroundColor = '#ff0000';
337            this._google = map;
338        },
339
340        _resetCallback: function(e) {
341            this._reset(e.hard);
342        },
343
344        _reset: function(clearOldContainer) {
345            this._initContainer();
346        },
347
348        _update: function() {
349            this._resize();
350
351            var bounds = this._map.getBounds();
352            var ne = bounds.getNorthEast();
353            var sw = bounds.getSouthWest();
354            var google_bounds = new google.maps.LatLngBounds(
355                new google.maps.LatLng(sw.lat, sw.lng),
356                new google.maps.LatLng(ne.lat, ne.lng)
357            );
358            var center = this._map.getCenter();
359            var _center = new google.maps.LatLng(center.lat, center.lng);
360
361            this._google.setCenter(_center);
362            this._google.setZoom(this._map.getZoom());
363            //this._google.fitBounds(google_bounds);
364        },
365
366        _resize: function() {
367            var size = this._map.getSize();
368            if (this._container.style.width == size.x &&
369                this._container.style.height == size.y)
370                return;
371            this._container.style.width = size.x + 'px';
372            this._container.style.height = size.y + 'px';
373            google.maps.event.trigger(this._google, "resize");
374        },
375
376        onReposition: function() {
377            google.maps.event.trigger(this._google, "resize");
378
379        }
380    });
381}
382
383function initLeafletTiles (map, controls) {
384
385	markersLayer.addTo(map);
386
387	controls = typeof controls !== 'undefined' ? controls : true;
388    var queryString = myScript.src.replace(/^[^\?]+\??/,'');
389    var mapProviderKeys = parseQuery( queryString );
390
391    function parseQuery ( query ) {
392        var Params = null;
393        if ( ! query ) return Params; // return null
394        var Pairs = query.split(/[;&]/);
395        for ( var i = 0; i < Pairs.length; i++ ) {
396            var KeyVal = Pairs[i].split('=');
397            if ( ! KeyVal || KeyVal.length != 2 ) continue;
398            var key = unescape( KeyVal[0] );
399            var val = unescape( KeyVal[1] );
400			val = val.replace(/\+/g, ' ');
401			if (val === 'null') val = null;
402            if (!Params) Params = {};
403            Params[key] = val;
404        }
405        return Params;
406	}
407
408    if (!mapProviderKeys || (!mapProviderKeys.otmKey && !mapProviderKeys.ignKey && !mapProviderKeys.gmKey)) {
409        var $map = $(map._container);
410        if ($map.length) {
411            console.warn('Error: No Key provided for any provider');
412            var errorText = {
413                en: 'Map display is no more available. An GoogleMaps API Key is needed to keep displaying the Google Map layer configured for this page',
414                fr: 'L’affichage de la carte n’est plus disponible. Une clé API GoogleMaps est nécessaire pour continuer à afficher le fond de carte GoogleMaps configuré pour cette page.'
415            }
416            var lang = 'fr';
417            $map.html('<div style="display: flex; margin: auto;max-width: 80%;flex-direction: column;text-align: center;"><div>'+ errorText[lang] +'</div></div>').css({
418                'font-weigth': 'bold',
419                'font-size': '16px',
420				'display': 'flex',
421                'align-items': 'center'
422            });
423            createFeedBackButton($map.children().first('div'));
424
425        }
426        return false;
427    }
428
429	window.dispatchEvent(createNewEvent('resize'));
430
431    // CONTROL INITIALISATION
432    if (controls) {
433        L.control.zoom({ position: 'bottomright' }).addTo(map);
434        // L.control.fullscreen({ position: 'bottomright' }).addTo(map);
435        L.control.scale({ imperial: false }).addTo(map);
436    }
437
438    var tileLayerOptions = {},
439        tileLayersCache = {};
440
441    if (mapProviderKeys.otmKey) {
442        tileLayerOptions.main_otm = {
443			type: 'Tangram',
444			title: 'TouristicMaps',
445			provider: 'TouristicMaps',
446		};
447    }
448
449    if (mapProviderKeys.ignKey) {
450        tileLayerOptions.fr_ign_carte = {
451            title: 'IGN Map',
452            provider: 'IGN',
453            // image: basepath + '/images/ign.png',
454            uri: 'https://wxs.ign.fr/' + mapProviderKeys.ignKey + '/geoportail/wmts/?service=WMTS&version=1.0.0&request=GetTile&layer=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&style=normal&tilematrixset=PM&tilematrix={z}&tilerow={y}&tilecol={x}&format=image/png',
455            params: {
456                attribution: '&copy; <a href="http://www.ign.fr">IGN</a> - 2012'
457            }
458        };
459        tileLayerOptions.fr_ign_satellite = {
460            title: 'IGN Satellite',
461            provider: 'IGN',
462            // image: basepath + '/images/cadastre.png',
463            uri: 'https://wxs.ign.fr/'+ mapProviderKeys.ignKey +'/geoportail/wmts?service=WMTS&version=1.0.0&request=GetTile&layer=ORTHOIMAGERY.ORTHOPHOTOS&style=normal&tilematrixset=PM&tilematrix={z}&tilerow={y}&tilecol={x}&format=image/jpeg',
464            params: {
465                attribution: '&copy; <a href="http://www.ign.fr">IGN</a> - 2012'
466            }
467        };
468    }
469
470    if (mapProviderKeys.gmKey && !mapProviderKeys.ignKey && google && google.maps && L.Google) {
471        if (!mapProviderKeys.otmKey) {
472			tileLayerOptions.com_google_roadmap = {
473				title: 'Google RoadMap',
474				provider: 'Google',
475				// image: basepath + '/images/google.png',
476				type: 'Google',
477				uri: 'ROADMAP',
478				params: {
479					pane: 'tiles',
480				}
481			};
482		}
483        tileLayerOptions.com_google_satellite = {
484            title: 'GMap satellite',
485            provider: 'Google',
486            // image: basepath + '/images/satellite.png',
487            type: 'Google',
488            uri: 'SATELLITE'
489        };
490    }
491
492    if (Object.keys(tileLayerOptions).length > 1) {
493        if (controls) {
494            L.control.layers(null, null, {collapsed: true, position: 'topright'}).addTo(map);
495        }
496        $parentNode = $('.leaflet-control-layers').parent();
497        $('.leaflet-control-layers').remove().clone().appendTo($parentNode);
498    }
499
500    function createFeedBackButton(elementToAppendTo) {
501		var sitekey = mapProviderKeys.sitekey;
502		if (!sitekey) {
503			return;
504		}
505		sitekey = (sitekey.lastIndexOf('?') > 0) ? sitekey.substr(0, sitekey.lastIndexOf('?')) : sitekey;
506
507		var feedbackText = {
508			fr: 'Signaler cette erreur',
509			en: 'Report this error'
510		};
511		var successText = {
512			fr: 'Votre signalement a été transmis au webmaster de ce site internet',
513			en: 'Your error report has been sent to the website webmaster',
514		}
515		var lang = 'fr';
516		var apptype = 'website_drupal6_tourism';
517
518        var $button = $('<button class="map-key-feedback-btn"></button>').css({
519            'display' : 'block',
520			'cursor' : 'pointer',
521			'margin': 'auto',
522			'margin-top' : '20px',
523			'font-size': '14px',
524            'border' : '1px solid #fff',
525            'border-radius' : '3px',
526            'padding' : '15px',
527			'background' : 'black',
528			'color': 'white',
529            'min-width' : '200px',
530            'max-width' : '320px',
531		});
532		$button.html(feedbackText[lang]);
533		$button.click(function (e) {
534			$.post('/api/public/website/'+ sitekey +'/slug/'+ apptype +'/lang/'+ lang +'/feedback/google_map', function(data, textStatus, xhr) {
535				if (xhr.status === 201) {
536					$button.prev().html(successText[lang]);
537					$button.remove();
538				}
539			});
540        });
541        $button.appendTo(elementToAppendTo);
542        return;
543    }
544
545    function createMapTileLayerMenuItem(id, options) {
546        var $element = $('<div class="base-layer-item"></div>'),
547            $label = $('<label for="'+ id +'"></label>'),
548            // $image = $('<img />'),
549            $title = $('<div class="base-layer-item-title"></div>'),
550            $selector = $('<input type="radio" class="leaflet-control-layers-selector" name="leaflet-base-layers" id="'+ id +'">'),
551            $provider = $('<div class="base-layer-item-provider"></div>');
552
553        // $image.attr('src', options.image);
554        $title.text(options.title);
555        $provider.text(options.provider);
556        if (self.currentLayerId === id) {
557            $selector.attr('checked', true);
558        }
559
560        $element.append($selector);
561        $element.append($label);
562        $label.append($title);
563        // $label.append($image);
564        // $label.append($provider);
565
566        $element.click(function() {
567            self.map.removeLayer(self.tileLayer);
568            // Cookie.create('cdf_fond_carte_id', id, 3600, true);
569            self.tileLayer = getTileLayer(id);
570            self.currentLayerId = id;
571            self.map.addLayer(self.tileLayer);
572            $('.leaflet-control-layers-list').hide();
573
574        });
575
576        return $element;
577    }
578
579    function getTileLayer(id) {
580		if (!tileLayersCache[id]) {
581			var options = tileLayerOptions[id],
582				type = options.type || 'TileLayer';
583			if (type == 'Tangram') {
584				// tileLayersCache[id] = Tangram.leafletLayer(options.params);
585				//le.warn(self.map._container);
586				tileLayersCache[id] = tangram(self.map , self.map._container, 'theme_tm', CurrentLang || 'fr', mapProviderKeys.otmKey);
587			} else {
588				tileLayersCache[id] = new L[type](options.uri, $.extend({ reuseTiles: true }, options.params));
589			}
590		}
591		return tileLayersCache[id];
592	}
593
594    // generate $baseLayerControlMenu
595    var $baseLayerControlMenu = $('.leaflet-control-layers-base');
596    [].forEach.call(Object.keys(tileLayerOptions), function (layerOption, index) {
597        var tileLayer = getTileLayer(layerOption);
598        if (!index) {
599			if (!tileLayerOptions.main_otm) {
600				// add first layer if not TM (added by tangram fn)
601				map.addLayer(tileLayer);
602			}
603            self.tileLayer = tileLayer;
604            self.currentLayerId = layerOption;
605        }
606
607        if (Object.keys(tileLayerOptions).length > 1) {
608            var $element = createMapTileLayerMenuItem(layerOption, tileLayerOptions[layerOption])
609            $baseLayerControlMenu.append($element);
610        }
611    });
612
613    $('.leaflet-control-layers-toggle').click(function (event) {
614        $('.leaflet-control-layers-list').toggle();
615        event.preventDefault();
616    });
617
618    $('.leaflet-control-layers-toggle, .leaflet-control-layers-list').live('mousedown dblclick', function(event) {
619        event.stopPropagation();
620    });
621
622    return true;
623};
624
625
626/**
627*  @desc Initialise la Map
628*  @param list liste des POI fiche à afficher
629*/
630initialize = function(list, latLngParam)
631{
632	if (!L) return;
633
634	var minLat, maxLat, minLng, maxLng;
635	listFiches = list;
636	var zoomOption = 6;
637	var panelIsOpen = false;
638	markers = [];
639
640	if (typeof(latLngParam) != "undefined") {
641		defaultLat = latLngParam.lat;
642		defaultLng = latLngParam.lng;
643		zoomOption = latLngParam.zoom;
644	}
645
646	// Europe bbox
647	var topLeftCorner = L.latLng(51.83, -5.53),
648		bottomRightCorner = L.latLng(41.1, 9.96),
649		maxBounds = L.latLngBounds(topLeftCorner, bottomRightCorner),
650		minZoom = 5,
651		maxZoom = 20;
652
653	var mapOpts = {
654		zoom: 12,
655		zoomControl: false,
656		maxBounds: maxBounds,
657		minZoom: minZoom,
658		maxZoom: maxZoom
659	};
660
661	if(typeof(mapSettings) != 'undefined'){
662		for(var i in mapSettings){
663			mapOpts[i] = mapSettings[i];
664		}
665	}
666
667	// si la map existe deja
668	var showControlsLeaflet = false;
669	if (document.querySelector('#map_canvas').children.length === 0) {
670		map = L.map(document.getElementById('map_canvas'), mapOpts);
671		map.setView([defaultLat, defaultLng], map.getZoom(), {reset: false});
672		showControlsLeaflet = true;
673	}
674
675	// Init Fullscreen button
676	mapDiv = $('#map_canvas');
677	topControlsDiv = $(document.createElement('DIV')).css("z-index","5000").css("position","absolute").css("top","20px").css("right","20px");
678	topControlsDiv.addClass("top_control_wrapper");
679
680
681	var initLeafletTilesTest = initLeafletTiles(map, showControlsLeaflet);
682
683	//Controle FullScreen
684	var fullscreenControl = new FullScreenControl(displayText.fullscreen_title,topControlsDiv, map);
685	// var customMapTypecontrol = new MapTypeControl(topControlsDiv, map);
686	mapHeight = mapDiv.innerHeight();
687	mapWidth = mapDiv.innerWidth();
688	mapParent = mapDiv.parent();
689	fullScreenDiv = $(document.createElement('DIV'));
690	mapDiv.append(topControlsDiv);
691
692	$(window).resize(function() {
693		resizeMap();
694	});
695
696	if (!initLeafletTilesTest) return;
697
698	var panelIsOpen = false;
699	markers = [];
700
701	//Boucle sur les fiches
702	for(var i in list) {
703		list[i].gps_lat = parseFloat(list[i].gps_lat);
704		list[i].gps_lng = parseFloat(list[i].gps_lng);
705
706		minLat = (typeof(minLat) == 'undefined' || list[i].gps_lat < minLat) ? list[i].gps_lat : minLat;
707		maxLat = (typeof(maxLat) == 'undefined' || list[i].gps_lat > maxLat) ? list[i].gps_lat : maxLat;
708		minLng = (typeof(minLng) == 'undefined' || list[i].gps_lng < minLng) ? list[i].gps_lng : minLng;
709		maxLng = (typeof(maxLng) == 'undefined' || list[i].gps_lng > maxLng) ? list[i].gps_lng : maxLng;
710
711		var marker = makeMarkerWithContent(i, list[i]);
712
713		markers.push(marker);
714	}
715
716	if (!list) {
717		map.setView([defaultLat, defaultLng], zoomOption);
718	} else {
719		var bounds = new L.LatLngBounds(new L.latLng(minLat, minLng), new L.latLng(maxLat, maxLng));
720		map.setView([bounds.getCenter().lat, bounds.getCenter().lng], mapOpts.zoom);
721		map.fitBounds(bounds);
722	}
723
724	// add markers
725	[].forEach.call(markers, function(marker) {
726		marker.addTo(markersLayer);
727	});
728
729
730	// var cParams = {
731	// 	opt_anchor: [8, 0]
732    // };
733    // var styles = GetClustersStyles(false, 40, 40, cParams);
734	// // Mise en cluster des markers
735        // markerClusterer = [];
736        // markerClusterer = new MarkerClusterer(map, markers, {
737        //     styles: styles
738        // });
739
740
741}
742
743/**
744* @desc enl�ve les points de la map et rajoute les nouveaux
745* @param list des item a mettre
746*/
747update = function(list, type, icone) {
748	if(!list){
749		return;
750	}
751
752	listFiches = list;
753	clearMyMap(type, false);
754
755	var splitArray = type.split("_");
756	var categorie = splitArray[1];
757	var type = splitArray[0];
758
759	    // markerClusterer[categorie] = [];
760	markersFacette[categorie] = markersFacette[categorie] || {} ;
761	markersFacette[categorie][type] = [];
762
763	for(var i in list) {
764		list[i].gps_lat = parseFloat(list[i].gps_lat);
765		list[i].gps_lng = parseFloat(list[i].gps_lng);
766
767		minLat = (typeof(minLat) == 'undefined' || list[i].gps_lat < minLat) ? list[i].gps_lat : minLat;
768		maxLat = (typeof(maxLat) == 'undefined' || list[i].gps_lat > maxLat) ? list[i].gps_lat : maxLat;
769		minLng = (typeof(minLng) == 'undefined' || list[i].gps_lng < minLng) ? list[i].gps_lng : minLng;
770		maxLng = (typeof(maxLng) == 'undefined' || list[i].gps_lng > maxLng) ? list[i].gps_lng : maxLng;
771
772		var marker = makeMarkerWithContent(i, list[i], icone);
773		markersFacette[categorie][type].push(marker);
774
775	}
776
777	var tempArray = [];
778
779	for (var w in markersFacette[categorie]) {
780		tempArray = $.merge( tempArray, markersFacette[categorie][w]);
781    }
782
783    [].forEach.call(tempArray, function(marker) {
784        marker.addTo(markersLayer);
785    });
786	// markerClusterer[categorie] = new MarkerClusterer(map, tempArray, {
787	// 	styles: GetClustersStyles(categorie, 40, 40)
788	// }, 1);
789
790
791	var bounds = new L.LatLngBounds([minLat, minLng], [maxLat, maxLng]);
792	map.setView([bounds.getCenter().lat, bounds.getCenter().lng], map.getZoom());
793	map.fitBounds(bounds);
794}
795
796/**
797*  @desc Objet OverlayDiv
798*  @param side Côté duquel sort le panel
799*  @param width largeur du panel
800*  @param height hauteur du panel
801*  @param margin distance du panel au bord (gauche/haut)
802*  @returns The overlay div
803*/
804OverlayDiv = function(name, side, width, height, margin) {
805
806	//récupération locale des paramètres
807	this.mapSize = mapHeight;
808	this.placingSize = height;
809	this.height = height;
810	this.width = width;
811	this.margin = margin;
812	//offset pour la div des controles
813	this.topOffset = 0;
814	//création du conteneur panel
815	this.rootDiv = $(document.createElement('div')).addClass('overlay_div').attr('id', 'rootdiv-' + name);
816
817	//détermination de l'ordre d'apparition des div dans le panel
818	//et détermination de la direction du slide
819	switch(side)
820	{
821		case "top":
822			this.cssDirection = "bottom";
823			this.topOffset = topControlsDiv.innerHeight()-1;
824			this.marginDirection = "left";
825			break;
826		case "left":
827			this.cssDirection = "right";
828			this.marginDirection = "top";
829			break;
830		case "right":
831			this.cssDirection = "left";
832			this.marginDirection = "top";
833			break;
834		default:
835			this.cssDirection = "top";
836			this.marginDirection = "left";
837	}
838
839	//actualise les valeurs utilisées pour le positionnement
840	this.refreshSizes = function(){
841		mapHeight = mapDiv.innerHeight();
842		mapWidth = mapDiv.innerWidth();
843		switch(side){
844			case "top":
845				this.topOffset = topControlsDiv.innerHeight()-2;
846				this.mapSize = mapHeight;
847				this.placingSize = this.height;
848				break;
849			case "left":
850				this.mapSize = mapWidth;
851				this.placingSize = this.width;
852				break;
853			case "right":
854				this.mapSize = mapWidth;
855				this.placingSize = this.width;
856				break;
857			default:
858				this.mapSize = mapHeight;
859				this.placingSize = this.height;
860		}
861	}
862
863	//initialisation des valeurs de positionnement
864	this.refreshSizes();
865
866	//initialisation de la taille et du positionnement du panel
867	this.rootDiv.css("width",this.width);
868	this.rootDiv.css("height",this.height);
869	this.rootDiv.css(this.marginDirection,this.margin);
870
871	//repositionnement du panel
872	this.replacePanel = function(){
873		this.refreshSizes();
874		var positionFinale = this.mapSize-this.placingSize-this.topOffset;
875		var anim = {};
876		anim[this.cssDirection] = positionFinale;
877		this.rootDiv.animate(anim, 30);
878	}
879
880	//mise en place du panneau
881	this.replacePanel();
882	mapDiv.append(this.rootDiv);
883	globalDivArray.push(this);
884
885	return this.rootDiv;
886
887}
888
889/**.map
890*  @desc Objet OverlayPanel
891*  @param side Côté duquel sort le panel
892*  @param width largeur du panel
893*  @param height hauteur du panel
894*  @param margin distance du panel au bord (gauche/haut)
895*  @param headerThickness épaisseur
896*  @param moveHeaderWithPanel - indique si le header du panel doit rester coller a la bordure ou doit suivre la rootDiv
897*  @returns The panel div
898*/
899OverlayPanel = function(name, panelClass, side, width, height, margin, headerThickness, moveHeaderWithPanel, returnType)
900{
901	moveHeaderWithPanel = moveHeaderWithPanel || false;
902	returnType = returnType || 'div';
903
904	//récupération locale des paramètres
905	this.onglets = [];
906	this.mapSize = mapHeight;
907	this.placingSize = height;
908	this.headerThickness = headerThickness;
909	this.height = height;
910	this.width = width;
911	this.margin = margin;
912	this.topOffset = 0; //offset pour la div des controles
913	this.ongletWidth = 150;
914
915	//création des div
916	this.rootDiv = $(document.createElement('div')).addClass('overlay_panel overlay_panel_closed').attr('id', 'rootdiv-' + panelClass);
917	this.header = $(document.createElement('div')).addClass('overlay_panel_header overlay_panel_header_closed').attr('id', 'headerdiv-' + panelClass).html(name);
918
919	// bind du click sur le panel
920	this.header.bind('click',{scopeThis:this},function(event) {
921		event.data.scopeThis.togglePanel();
922		for (i in globalPanelArray) {
923			var checkPanel = globalPanelArray[i];
924			if (checkPanel.rootDiv.context.className.indexOf('overlay_panel_open') != -1 && checkPanel.header.context.
924id != event.data.scopeThis.header.context.id) {
925				checkPanel.togglePanel();
926			}
927		}
928	});
929
930	//détermination de l'ordre d'apparition des div dans le panel
931	//et détermination de la direction du slide
932	switch(side) {
933		case "top":
934			this.cssDirection = "bottom";
935			this.topOffset = topControlsDiv.innerHeight()-1;
936			this.marginDirection = "left";
937			this.header.css("min-width",this.width);
938			this.header.css("height",headerThickness);
939			this.header.css(this.marginDirection,this.margin);
940			this.rootDiv.css("width",this.width);
941			this.rootDiv.css("height",this.height);
942			this.rootDiv.css(this.marginDirection, this.margin);
943			break;
944
945		case "bottom":
946			this.cssDirection = "top";
947			this.topOffset = topControlsDiv.innerHeight()-1;
948			this.marginDirection = "bottom";
949			this.header.css("min-width",this.width);
950			this.header.css("height",headerThickness);
951			this.header.css(this.marginDirection,this.margin);
952			this.rootDiv.css("width",this.width);
953			this.rootDiv.css("height",this.height);
954			this.rootDiv.css(this.marginDirection, this.margin);
955			break;
956
957		case "left":
958			this.cssDirection = "right";
959			this.marginDirection = "top";
960			this.header.css("min-width", headerThickness);
961			this.header.css("min-height",this.height);
962			this.header.css(this.marginDirection,this.margin);
963			this.rootDiv.css("width",this.width);
964			this.rootDiv.css("min-height",this.height);
965			this.rootDiv.css(this.marginDirection, 50);
966			break;
967
968		case "right":
969			this.cssDirection = "left";
970			this.marginDirection = "top";
971			// this.header.css("min-width",headerThickness);
972			// this.header.css("min-height",this.height);
973			// this.header.css(this.marginDirection,this.margin);
974			this.rootDiv.css("width",this.width);
975			this.rootDiv.css("min-height",this.height);
976			this.rootDiv.css(this.marginDirection, 50);
977			break;
978
979		default:
980			this.cssDirection = "top";
981			this.marginDirection = "left";
982			this.header.css("min-width",this.width);
983			this.header.css("min-height",headerThickness);
984			this.header.css(this.marginDirection,this.margin);
985			this.rootDiv.css("width",this.width);
986			this.rootDiv.css("min-height",this.height);
987			this.rootDiv.css(this.marginDirection, 50);
988	}
989
990	//actualise les valeurs utilisées pour le positionnement
991	this.refreshSizes = function(){
992
993		mapHeight = mapDiv.innerHeight();
994		mapWidth = mapDiv.innerWidth();
995
996		switch(side)
997		{
998			case "top":
999				this.topOffset = topControlsDiv.innerHeight()-2;
1000				this.mapSize = mapHeight;
1001				this.placingSize = this.height;
1002				break;
1003
1004			case "bottom":
1005				this.topOffset = topControlsDiv.innerHeight()-2;
1006				this.mapSize = mapHeight;
1007				this.placingSize = this.height;
1008				break;
1009
1010			case "left":
1011				this.mapSize = mapWidth;
1012				this.placingSize = this.width;
1013				break;
1014
1015			case "right":
1016				this.mapSize = mapWidth;
1017				this.placingSize = this.width;
1018				break;
1019
1020			default:
1021				this.mapSize = mapHeight;
1022				this.placingSize = this.height;
1023		}
1024	}
1025
1026	// anime les panels pour le toggle et le replace
1027	this.animatePanel = function() {
1028
1029		var positionFinale = this.mapSize - this.placingSize - this.topOffset - this.headerThickness;
1030		var positionFinaleHeader = this.mapSize - this.topOffset - this.headerThickness;
1031		var headerWidth = this.headerThickness;
1032
1033		if(this.rootDiv.hasClass('overlay_panel_closed')) {
1034
1035			positionFinale = this.mapSize-this.topOffset;
1036			headerWidth = headerThickness;
1037
1038			if (side == 'bottom' || side == 'top' ){
1039				var positionFinaleHeader = this.mapSize-this.topOffset;
1040			} else {
1041				var positionFinaleHeader = this.mapSize-this.topOffset-this.headerThickness;
1042			}
1043
1044		}
1045
1046		if (this.header.hasClass('overlay_panel_header_open') && moveHeaderWithPanel) {
1047
1048			if (side == 'bottom' || side == 'top' ){
1049				positionFinaleHeader = this.mapSize-this.headerThickness-this.height;
1050				positionFinale = this.mapSize-this.height;
1051			} else {
1052				positionFinaleHeader = this.mapSize-headerThickness-this.topOffset-this.width-this.headerThickness;
1053			}
1054
1055		}
1056
1057		var anim = {};
1058		var animHeader = {};
1059
1060		switch(side) {
1061			case "top":
1062			case "bottom":
1063				anim[this.cssDirection] = positionFinale;
1064				anim["height"] = this.height;
1065				animHeader[this.cssDirection] = positionFinaleHeader;
1066				break;
1067
1068			default:
1069				anim[this.cssDirection] = positionFinale;
1070				anim["min-height"] = (globalPanelArray.length)*100;
1071				animHeader[this.cssDirection] = positionFinaleHeader;
1072				animHeader['width'] = headerWidth;
1073		}
1074
1075		this.header.animate(animHeader, 300);
1076		this.rootDiv.animate(anim, 300);
1077	}
1078
1079	// repositionnement du panel
1080	this.replacePanel = function(){
1081
1082		this.refreshSizes();
1083		this.animatePanel();
1084		this.showOngletRefresh();
1085
1086	}
1087
1088	// ouverture/fermature du panel
1089	this.togglePanel = function(){
1090
1091		this.rootDiv.toggleClass('overlay_panel_closed');
1092		this.rootDiv.toggleClass('overlay_panel_open');
1093
1094		this.header.toggleClass('overlay_panel_header_closed');
1095		this.header.toggleClass('overlay_panel_header_open');
1096
1097/**
1098 * Afficher si panel vide
1099 */
1100		this.refreshSizes();
1101		this.animatePanel();
1102
1103	}
1104
1105	// initlialise les onglets a l'intérieur des panels
1106	this.initOnglet = function() {
1107
1108		this.header.html('');
1109		this.header.removeAttr('style');
1110		this.header.css('width', '100%');
1111
1112		this.rigthArrow = $(document.createElement('div')).addClass('overlay_panel_header_arrow overlay_panel_header_arrow_right').attr('id', 'arrowright-' + name);
1113		this.ongletsContainer = $(document.createElement('div')).addClass('overlay_panel_header_container overlay_panel_header_container').attr('id', 'ongletscontainer-' + name);
1114		this.leftArrow = $(document.createElement('div')).addClass('overlay_panel_header_arrow overlay_panel_header_arrow_left').attr('id', 'arrowleft-' + name);
1115		this.rootContentDiv = $(document.createElement('div')).addClass('root_div_content').attr('id', 'root_div_content-' + name);
1116
1117
1118		this.rigthArrow.css("height", this.headerThickness);
1119		this.leftArrow.css("height", this.headerThickness);
1120
1121		this.rigthArrow.css('float', 'right');
1122		this.leftArrow.css('float', 'left');
1123
1124		this.rigthArrow.css('display', 'none');
1125		this.leftArrow.css('display', 'none');
1126
1127		this.rigthArrow.html(">>");
1128		this.leftArrow.html("<<");
1129
1130		this.header.append(this.leftArrow);
1131		this.header.append(this.ongletsContainer);
1132		this.header.append(this.rigthArrow);
1133
1134		this.rootDiv.append(this.rootContentDiv);
1135
1136		this.rigthArrow.bind('click', {direction: 'next', me: this}, this.scrollOnglets);
1137		this.leftArrow.bind('click', {direction: 'prev', me: this}, this.scrollOnglets);
1138
1139	}
1140
1141	// scroll les onglets de gauche a droite et inversement
1142	this.scrollOnglets =  function(event) {
1143
1144		if (event.data.me.header.hasClass('overlay_panel_header_closed')) {
1145			event.data.me.togglePanel();
1146		}
1147
1148		switch (event.data.direction) {
1149			case 'next':
1150				var showinDirection = 'last';
1151				var hidinDirection = 'first';
1152				break;
1153			case 'prev':
1154				var showinDirection = 'first';
1155				var hidinDirection = 'last';
1156				break
1157		}
1158
1159		var currentOnglet = $('.focusedOngletMap');
1160
1161		if (!currentOnglet){
1162			if($('.overlay_panel_header_onglet').first()) {
1163				currentOnglet = $('.overlay_panel_header_onglet').first();
1164			} else {
1165				return false;
1166			}
1167
1168		}
1169
1170		if (currentOnglet[event.data.direction]()) {
1171
1172			var futurCurrentOnglet = currentOnglet[event.data.direction]()
1173			futurCurrentOnglet.find('.ongletMapContent').trigger('click');
1174
1175			if (futurCurrentOnglet.is('.ongletHide:'+hidinDirection)){
1176				futurCurrentOnglet.removeClass('ongletHide').addClass('ongletShow').show();
1177				$('.overlay_panel_header_onglet')[hidinDirection]().removeClass('ongletShow').addClass('ongletHide').hide();
1178			}
1179		}
1180
1181		return false;
1182
1183	}
1184
1185	// scrool jusqu'a l'onglet ouvert
1186	this.scrollToFocusedOnglet = function() {
1187
1188		// on utilise les index des tableaux pour connaitre le sens dans lequel scroller.
1189		// clickDirection
1190		var clickDirection = false;
1191		// définition des index
1192		var destination = 0;
1193		var steps = 0;
1194		var minCurrentOpenIndex = 0;
1195		var maxCurrentOpenIndex = 0;
1196		// définition des onglets
1197		var ongletArray = $('.overlay_panel_header_onglet');
1198		var minCurrentOpen = $('.ongletShow').first();
1199		var maxCurrentOpen = $('.ongletShow').last();
1200
1201		// recherche des index dans le tableau d'onglet
1202		var i = 1;
1203		$('.overlay_panel_header_onglet').each(function() {
1204
1205			if ($(this).hasClass('focusedOngletMap')){
1206				destination = i;
1207			}
1208			if ($(this).attr('id') == minCurrentOpen.attr('id')){
1209				minCurrentOpenIndex = i;
1210			}
1211			if ($(this).attr('id') == maxCurrentOpen.attr('id')){
1212				maxCurrentOpenIndex = i;
1213			}
1214			i++;
1215		});
1216
1217		// maintenant on va au current onglet
1218		if (destination > maxCurrentOpenIndex) {
1219			steps = destination - maxCurrentOpenIndex;
1220			for ( j = 0; j < steps; j++){
1221				$('.ongletShow').first().removeClass('ongletShow').addClass('ongletHide').hide();
1222				$('.ongletShow').last().next().removeClass('ongletHide').addClass('ongletShow').show();
1223			}
1224			this.rigthArrow.show();
1225			this.leftArrow.show();
1226		} else {
1227			steps = minCurrentOpenIndex - destination;
1228			for (j = 0; j < steps; j++){
1229				$('.ongletShow').last().removeClass('ongletShow').addClass('ongletHide').hide();
1230				$('.ongletShow').first().prev().removeClass('ongletHide').addClass('ongletShow').show();
1231			}
1232		}
1233		return false;
1234	}
1235
1236	this.ghostSlide = function(source, destination, params){
1237		var ghost = source.clone();
1238		ghost.attr('class', 'ghostSlide');
1239		ghost.css({
1240			position:'fixed',
1241			opacity:0.8,
1242			'z-index':10000,
1243			top:source.offset().top,
1244			left:source.offset().left
1245		});
1246		if(params.ghostCss){
1247			ghost.css(params.ghostCss);
1248		}
1249		$('#map_canvas').after(ghost);
1250
1251		var animateCss = {
1252			top:destination.offset().top,
1253			left:destination.offset().left
1254		};
1255
1256		if(typeof(params.animateCss) === 'object'){
1257			$.extend(animateCss, params.animateCss);
1258		}
1259
1260		ghost.animate(animateCss, 1000, function(){
1261			$(this).fadeOut(function(){
1262				$(this).remove()
1263			});
1264		});
1265	}
1266
1267	// rafraichie dur
1268	this.showOngletRefresh = function() {
1269
1270		// check sur les tailles des onglets et l'affichage de ceux-ci
1271		var ongletContainerWidth = $('#ongletscontainer-detail-fiches').width()-$('#arrowleft-detail-fiches').width()-$('#arrowright-detail-fiches').width();
1272		var totalOngletsWidth = 0;
1273
1274		$('.overlay_panel_header_onglet').each(function(event) {
1275			totalOngletsWidth += $(this).width() ;
1276		});
1277
1278		if (totalOngletsWidth > ongletContainerWidth) {
1279			var nbOngletsToDisplay = ongletContainerWidth/150;
1280		}
1281
1282		var cursor = 0;
1283		$('.overlay_panel_header_onglet').each(function(event) {
1284			if (cursor > nbOngletsToDisplay) {
1285				$(this).hide();
1286				$(this).addClass('ongletHide').removeClass('ongletShow');
1287			} else {
1288				$(this).show();
1289				$(this).addClass('ongletShow').removeClass('ongletHide');
1290			}
1291			cursor++;
1292		});
1293
1294		if ((typeof(this.leftArrow) != 'undefined') && (typeof(this.rigthArrow) != 'undefined')){
1295			this.rigthArrow.hide();
1296			this.leftArrow.hide();
1297		}
1298
1299		if (nbOngletsToDisplay){
1300			this.scrollToFocusedOnglet();
1301		}
1302		return nbOngletsToDisplay;
1303	}
1304
1305	/**
1306	 * Panel centré à l'écran
1307	 */
1308	this.slideMiddlePanel = function(content, params){
1309		$('#middlePanel').fadeOut(500, function(){
1310			$(this).remove();
1311		});
1312		var panelWidth = 910;
1313		var middlePanel = $('<div>');
1314		middlePanel.attr('id', 'middlePanel');
1315
1316		$(content).css({
1317			'width':'100%',
1318			'height': panelWidth - 50 + 'px',
1319			'top':'20px'
1320		});
1321
1322		initialPanelCss = {
1323			'width':params.sender.width(),
1324			'height':params.sender.height(),
1325			'top':params.sender.offset().top,
1326			'left':params.sender.offset().left,
1327			'opacity':0.5,
1328			'background-color':'white',
1329			'z-index':99999,
1330			'position':'fixed'
1331		};
1332
1333		var closeButton = $('<div>');
1334		closeButton.html('x');
1335		closeButton.attr({
1336			'id':'middlePanelClose',
1337			'class':'middlePanelButton'
1338		});
1339		closeButton.css({
1340			'cursor': 'pointer',
1341			'float': 'right',
1342			'font-size': '3em',
1343			'font-weight': 'bold',
1344			'margin': '-18px -8px'
1345		});
1346
1347		closeButton.click(function(){
1348			middlePanel.animate(initialPanelCss, 500, function(){
1349				$(this).remove();
1350			});
1351		});
1352
1353		middlePanel.css(initialPanelCss);
1354
1355		finalPanelCss = {
1356		   width: panelWidth + 'px',
1357		   height:$(window).height() * 0.9,
1358		   top:$(window).height() * 0.05,
1359		   left:($(window).width() - panelWidth) / 2,
1360		   opacity:1
1361		};
1362
1363		middlePanel.append(closeButton);
1364		middlePanel.append(content);
1365
1366		$('body').append(middlePanel);
1367
1368		middlePanel.animate(finalPanelCss, 500, function(){
1369			$(this).addClass('middlePanel-opened');
1370		});
1371	}
1372
1373	this.initOngletLeftToolbar = function() {
1374		me = this;
1375		$('.reserver-container > a').click(function(e){
1376			e.preventDefault();
1377			var frame = $('iframe');
1378			frame.attr('src', $(this).attr('href'));
1379			me.slideMiddlePanel(frame, {sender:$(this)});
1380		});
1381
1382		// Init du lightbox
1383		// if(typeof(Drupal.behaviors.initLightbox) === 'function'){
1384			// Drupal.behaviors.initLightbox();
1385		// }
1386
1387		$('.root_div_content .rootdiv-content-left-toolbar').children().click(function() {
1388			var currentLeftToolBarShow = $(this).attr('name');
1389			$('.root_div_content .rootdiv-content-left-toolbar .currentLeftToolBarShow').removeClass('currentLeftToolBarShow');
1390			$('.root_div_content .rootdiv-content-left-toolbar').find('div[name="'+currentLeftToolBarShow+'"]').addClass('currentLeftToolBarShow');
1391			$('.root_div_content .rootdiv-content-content').children().hide();
1392			$('.root_div_content .rootdiv-content-content').find('div[name="'+currentLeftToolBarShow+'"]').show();
1393		})
1394	};
1395
1396	// ajoute un onglet au header du panel
1397	this.addOnglet = function(idFiche, idPlaylist, name) {
1398
1399		// définition des paramètres de l'onglet
1400		var ongletName = 'onglet_' + idPlaylist + '_' + idFiche;
1401
1402		// si l'onglet existe deja il ne se pass rien
1403		if ($('#' + ongletName).length){
1404			$('#ongletMapContent_onglet_' + idPlaylist + '_' + idFiche).trigger('click');
1405			this.scrollToFocusedOnglet();
1406			return false;
1407			//
1408			$('.focusedOngletMap').toggleClass('focusedOngletMap');
1409			$('#' + ongletName).addClass('focusedOngletMap');
1410			this.scrollToFocusedOnglet();
1411			$('#ongletMapContent_onglet_' + idPlaylist + '_' + idFiche).trigger('click');
1412			return false;
1413		}
1414		// Animation ghost
1415		clicked = $('#infowindow_' + idPlaylist + '_' + idFiche).parent().parent().parent();
1416		destination = $('.overlay_panel_header_onglet').length > 0 ? $('.overlay_panel_header_onglet').last() : $('#headerdiv-detail-fiches');
1417		detailPanel.ghostSlide(clicked, destination, {
1418			ghostCss:{
1419				'background-color':'white'
1420			}
1421		});
1422
1423		this.onglet  = $(document.createElement('div')).addClass('overlay_panel_header_onglet').attr('id', ongletName);
1424
1425		this.onglet.content = $(document.createElement('div')).addClass('ongletMapContent').attr('id', 'ongletMapContent_' + ongletName);
1426		this.onglet.content.css({
1427			'float':'left',
1428			'text-align':'center',
1429			'width': '100%',
1430			'height': this.headerThickness
1431		});
1432		this.onglet.content.html(name);
1433
1434		this.onglet.picto = $(document.createElement('div')).addClass('ongletMapPicto').attr('id', 'ongletMapPicto_' + ongletName);
1435		this.onglet.picto.html('<img src="/' + module_base_path + '/ressources/isc/images/gmaps/'+ globalFacetteArray[idPlaylist].icone +'.png"/>');
1436		this.onglet.picto.css({
1437			'float':'left',
1438			'margin-top':'-35px'
1439		});
1440
1441		this.onglet.openner = $(document.createElement('div')).addClass('ongletMapOpenner').attr('id', 'ongletMapOpenner_' + ongletName);
1442		this.onglet.openner.html('Ajouter au sejour');
1443		this.onglet.openner.css({
1444			'display':'none',
1445			'background-color':'black',
1446			'font-size':'9px'
1447		});
1448
1449		this.onglet.htmlContent = $(document.createElement('div')).addClass('ongletMapHtmlContent').attr('id', 'ongletMapHtmlContent_' + ongletName);
1450		this.onglet.htmlContent.css('display', 'none');
1451
1452		this.onglet.close = $(document.createElement('div')).addClass('ongletMapContentClose').attr('id', 'ongletMapContentClose' + ongletName);
1453		this.onglet.close.css('float', 'right');
1454		this.onglet.close.html('x');
1455		this.onglet.close.hide();
1456
1457		this.onglet.append(this.onglet.picto);
1458		this.onglet.append(this.onglet.openner);
1459		this.onglet.append(this.onglet.content);
1460		this.onglet.append(this.onglet.htmlContent);
1461		this.onglet.append(this.onglet.close);
1462
1463		this.onglet.removeAttr('style');
1464		this.onglet.css({
1465			'float': 'left',
1466			// 'margin-left':'5px',
1467			// 'max-width': '150px',
1468			'width':this.ongletWidth,
1469			'height': this.headerThickness,
1470			'min-width': '100px'
1471		});
1472
1473		this.ongletsContainer.append(this.onglet);
1474
1475		this.showOngletRefresh();
1476
1477		// bind des évenement sur les onglets
1478		var me = this;
1479
1480		this.onglet.content.bind('click', {currOnglet: this.onglet}, function(event) {
1481			if(event.data.currOnglet.hasClass('focusedOngletMap')){
1482				// Centrer sur le marker
1483				return false;
1484			}
1485
1486			// on cache tout les onglets
1487			$('.ongletShow .ongletMapPicto').hide();
1488			$('.ongletMapContentClose').hide();
1489			$('.focusedOngletMap .ongletMapOpenner').animate({
1490				opacity: 0,
1491				marginTop: "0",
1492				marginBottom: "-14"
1493				}, 300, function(){
1494					$(this).hide().css('margin', 0);
1495			});
1496			$('.overlay_panel_header_onglet').removeClass('focusedOngletMap');
1497
1498			// on ouvre le bon
1499			event.data.currOnglet.addClass('focusedOngletMap');
1500			event.data.currOnglet.find('.ongletMapPicto').show();
1501			event.data.currOnglet.close.show();
1502			event.data.currOnglet.openner.show();
1503			event.data.currOnglet.openner.animate({
1504				opacity: 1,
1505				marginTop: '-13'
1506				}, 600, function() {
1507			});
1508
1509			// ajout du contenu du rootDiv (le détail de la fiche qu'il faudra récupérer via ajaxCall).
1510			var currentLeftToolBarShow = false;
1511			// on utilise une animation
1512			me.rootContentDiv.animate({
1513				opacity: 0.25,
1514				left: me.rootDiv.width()
1515				}, 150, function() {
1516					me.rootContentDiv.hide();
1517					if ($('.root_div_content .rootdiv-content-left-toolbar .currentLeftToolBarShow').length = 1){
1518						currentLeftToolBarShow = $('.root_div_content .rootdiv-content-left-toolbar .currentLeftToolBarShow').attr('name');
1519					}
1520			});
1521
1522			me.rootContentDiv.animate({
1523				opacity: 1,
1524				right: me.rootDiv.width()
1525				}, 150, function() {
1526					me.rootContentDiv.show();
1527					if (event.data.currOnglet.htmlContent.html() != '') {
1528						me.rootContentDiv.html(event.data.currOnglet.htmlContent.html());
1529						$('.root_div_content .rootdiv-content-left-toolbar .currentLeftToolBarShow').removeClass('currentLeftToolBarShow');
1530						$('.root_div_content .rootdiv-content-left-toolbar').find('div[name="'+currentLeftToolBarShow+'"]').addClass('currentLeftToolBarShow');
1531						$('.root_div_content .rootdiv-content-content').children().hide();
1532						$('.root_div_content .rootdiv-content-content').find('div[name="'+currentLeftToolBarShow+'"]').show();
1533						me.initOngletLeftToolbar();
1534					} else {
1535						me.showContentDivLoader(idFiche, true);
1536						$.get('/' + langContext + 'tourism/ajax/getDetail/Mapdetail?idPlaylist=' + idPlaylist + '&idFiche=' + idFiche, function(d){
1537							me.showContentDivLoader(idFiche, false);
1538							d = $.parseJSON(d);
1539							event.data.currOnglet.htmlContent.html(d);
1540							me.rootContentDiv.html(d);
1541
1542							if (!currentLeftToolBarShow) {
1543								$('.root_div_content .rootdiv-content-left-toolbar').children().first().addClass('currentLeftToolBarShow');
1544								var newCurrent = $('.root_div_content .rootdiv-content-left-toolbar').children().first().attr('name');
1545								$('.root_div_content .rootdiv-content-content').children().hide();
1546								$('.root_div_content .rootdiv-content-content').find('div[name="'+newCurrent+'"]').show();
1547							} else {
1548								$('.root_div_content .rootdiv-content-left-toolbar .currentLeftToolBarShow').removeClass('currentLeftToolBarShow');
1549								$('.root_div_content .rootdiv-content-left-toolbar').find('div[name="'+currentLeftToolBarShow+'"]').addClass('currentLeftToolBarShow');
1550								$('.root_div_content .rootdiv-content-content').children().hide();
1551								$('.root_div_content .rootdiv-content-content').find('div[name="'+currentLeftToolBarShow+'"]').show();
1552							}
1553							me.initOngletLeftToolbar();
1554						}) ;
1555					}
1556			});
1557
1558			if (me.header.hasClass('overlay_panel_header_closed')) {
1559				me.togglePanel();
1560			}
1561			return false;
1562		});
1563
1564		this.onglet.close.bind('click', {currOnglet: this.onglet}, function(event) {
1565			me.rootContentDiv.html('');
1566			me.showContentDivLoader(idFiche, false);
1567			event.data.currOnglet.remove();
1568			if ($('.overlay_panel_header_onglet').length == 0 && me.header.hasClass('overlay_panel_header_open')){
1569				me.header.trigger('click');
1570			}
1571			return false;
1572		});
1573
1574		this.onglet.content.trigger('click');
1575		this.scrollToFocusedOnglet();
1576	}
1577
1578	// BOOM
1579	this.destruct = function() {
1580		this.header.remove();
1581		this.rootDiv.remove();
1582		detailPanel = false;
1583		delete this;
1584	}
1585
1586	// Affichage du loader de chargement dans le panel
1587	this.showContentDivLoader = function(id, show){
1588		if(!show){
1589			$('#loader_panel_' + id).remove();
1590		} else {
1591			var loader = $('<div>')
1592				.attr({
1593					'id':'loader_panel_' + id,
1594					'class':'loader-panel'
1595				})
1596				.css({
1597					width : '100%',
1598					height : '100%',
1599					opacity:0.7,
1600					position:'absolute',
1601					'z-index':10,
1602					'background':'#000 url("/' + module_base_path + '/ressources/isc/images/ajax-big-loader.gif") no-repeat',
1603					'background-position':'center 50px'
1604			});
1605			$('#rootdiv-detail-fiches').prepend(loader);
1606		}
1607	}
1608
1609	//initialisation des valeurs de positionnement
1610	this.refreshSizes();
1611	//mise en place du panneau
1612	this.replacePanel();
1613
1614	mapDiv.append(this.rootDiv);
1615	mapDiv.append(this.header);
1616
1617	globalPanelArray.push(this);
1618
1619	return returnType == 'object' ? this : this.rootDiv;
1620}
1621
1622/**
1623*  @desc Control affichant la carte en plein écran
1624*  @param title Titre du bouton
1625*  @param controlDiv Div dans laquelle le bouton est placé
1626*  @param map Google Map relative au contrôle
1627*/
1628FullScreenControl = function(title,controlDiv, map) {
1629
1630	// Set CSS for the control border
1631	var controlUI = document.createElement('DIV');
1632	controlUI.className = "fullscreen_control_wrapper off";
1633	controlDiv.append(controlUI);
1634
1635	// Set CSS for the control interior
1636	var controlText = document.createElement('DIV');
1637	controlText.className = "fullscreen_control_text";
1638	controlText.innerHTML = title;
1639	controlUI.appendChild(controlText);
1640
1641	// Setup the click event listeners: simply set the map to Chicago
1642	L.DomEvent.addListener(controlUI, 'click', function() {
1643		toggleFullScreen();
1644	});
1645}
1646
1647/**
1648*  @desc Sélecteur de MapType
1649*  @param parent Div dans laquelle le bouton est placé
1650*  @param map Google Map relative au contrôle
1651*/
1652MapTypeControl = function (parent, map){
1653
1654	// var mapTypeList = Array(
1655	// 	['Carte', google.maps.MapTypeId.ROADMAP],
1656	// 	// ['Mixte', google.maps.MapTypeId.HYBRID],
1657	// 	['Satellite', google.maps.MapTypeId.SATELLITE]
1658	// );
1659
1660	// var controlSelect = document.createElement('div');
1661	// controlSelect.className = 'control_type_map';
1662
1663	// for (var i in mapTypeList){
1664	// 	MapTypeOptionControl(controlSelect, map, mapTypeList[i][0], mapTypeList[i][1]);
1665	// }
1666
1667	// parent.append(controlSelect);
1668}
1669
1670/**
1671*  @desc Option de MapType
1672*  @param mapTxtId texte du selecteur
1673*  @param mapTypeId type de map correspondant
1674*  @param map Google Map relative au contrôle
1675*/
1676MapTypeOptionControl = function(selectTag, map, mapTxtId, mapTypeId) {
1677
1678	// this.controlOption = document.createElement('div');
1679	// this.controlOption.className = mapTxtId + ' passive';
1680	// this.controlOption.innerHTML = mapTxtId;
1681
1682	// google.maps.event.addDomListener(this.controlOption, 'click', function() {
1683	// 	map.setMapTypeId(mapTypeId);
1684	// 	$('.control_type_map').children().removeClass('active').addClass('passive');
1685	// 	this.className = mapTxtId + ' active';
1686	// });
1687
1688	// selectTag.appendChild(this.controlOption);
1689}
1690
1691/**
1692* @desc utiliser pour nettoyer la map de ces points
1693*/
1694clearMyMap = function(type, rebuild) {
1695
1696	// si TRUE permet de supprimer la totalité des marqueurs lors d'une requête
1697	var clearAll = false;
1698
1699	var splitArray = type.split("_");
1700	var categorie = splitArray[1];
1701	var type = splitArray[0];
1702
1703	if (typeof(markersFacette[categorie]) != "undefined" && !!map.getPanes().markerPane.childElementCount) {
1704		if (typeof(markersFacette[categorie][type]) != "undefined" ) {
1705			for (var j in markersFacette[categorie][type]){
1706				if ( markersLayer.hasLayer(markersFacette[categorie][type][j]) ) {
1707					map.removeLayer(markersFacette[categorie][type][j]);
1708				}
1709			}
1710			markersFacette[categorie][type].length = 0;
1711		}
1712	}
1713
1714	if (clearAll) {
1715		markersLayer.clearLayers();
1716		markersFacette = {};
1717	}
1718        // if(typeof(markerClusterer[categorie]) != "undefined"){
1719        // 	markerClusterer[categorie].clearMarkers();
1720        // 	markerClusterer[categorie].length = 0;
1721        // }
1722
1723	if (rebuild) {
1724		var tempArray = [];
1725		for (var w in markersFacette[categorie]) {
1726			tempArray = $.merge( tempArray, markersFacette[categorie][w]);
1727		}
1728		// markerClusterer[categorie] = new MarkerClusterer(map, tempArray, {
1729		// 	styles: GetClustersStyles(categorie, 40, 40, {opt_textColor: '#000'})
1730		// }, 1);
1731		[].forEach.call(tempArray, function(marker) {
1732			marker.addTo(markersLayer);
1733		});
1734	}
1735}
1736
1737/**
1738 * @desc Initialise le comportement clavier
1739 * @param mode <String> Mode pour lequel binder les events
1740 */
1741keyboardBehaviourHandler = function(action, mode)
1742{
1743	this.init(action, mode);
1744	return this;
1745};
1746
1747keyboardBehaviourHandler.prototype.init = function(action, mode)
1748{
1749	switch(action){
1750		case 'reset':
1751			$(document).unbind('keydown');
1752			break;
1753		case 'init':
1754			if(typeof(this[mode + 'KeyboardBehaviour']) === 'function'){
1755				initHandlerFunction = mode + 'KeyboardBehaviour';
1756				this[initHandlerFunction]();
1757				// A revoir avec un mappage event => 'Touche appuyée' => 'Evenement'
1758				// Mémoriser les listeners pour les enlever
1759			}
1760			break;
1761	}
1762};
1763
1764keyboardBehaviourHandler.prototype.listKeyboardBehaviour = function()
1765{
1766	$(document).keydown(function(event){
1767		switch(event.keyCode){
1768			case 39:
1769				$('#paginator_top .pager-current').next().find('a').trigger('click');
1770				break;
1771
1772			case 37:
1773				$('#paginator_top .pager-current').prev().find('a').trigger('click');
1774				break;
1775		}
1776	});
1777	return this;
1778}
1779
1780keyboardBehaviourHandler.prototype.mapKeyboardBehaviour = function()
1781{
1782	handler = this;
1783	$(document).keydown(function(event){
1784		switch(event.keyCode){
1785			case 27:
1786				toggleFullScreen();
1787				handler.init('reset');
1788				break;
1789		}
1790	});
1791	return this;
1792}
1793
1794/**
1795*  @desc Active ou désactive le mode Plein écran
1796*/
1797toggleFullScreen = function(){
1798	var center = map.getCenter();
1799	var isFullscreen = $('.fullscreen_control_wrapper').hasClass('off');
1800
1801	if(isFullscreen){
1802		if(typeof(keyboardBehaviourHandler) === 'function'){
1803			keyboardHandler = new keyboardBehaviourHandler('init', 'map');
1804		}
1805		fullScreenDiv.append(mapDiv);
1806		$('body').append(fullScreenDiv).css('overflow', 'hidden');
1807		fullScreenDiv.addClass('fullscreenDiv');
1808		mapDiv.addClass('fullscreenMapDiv');
1809
1810	} else {
1811		fullScreenDiv.removeClass('fullscreenDiv');
1812		mapParent.append(mapDiv);
1813		$('body').css('overflow', 'auto');
1814		mapDiv.removeClass('fullscreenMapDiv');
1815		if (detailPanel){
1816			detailPanel.destruct(); // BOOM
1817		}
1818	}
1819
1820	/* A modifier pour les facettes*/
1821	if(isFullscreen){
1822		fromCol = $('.mode_actif').find('span');
1823		$('.content-panel').show().css('opacity', '100');
1824		fullScreenDiv.append(mapDiv);
1825		oldScroll = $(document).scrollTop();
1826		$(document).scrollTop(0);
1827
1828		// blocDateSelection
1829		var myDivDate = OverlayDiv("blocdate", "top", 650,40,100);
1830		myDivDate.append($('#blockDateSelectionMain'));
1831
1832		// panelSearchEngine
1833		var startPanelMargin = 50;
1834		var defaultPanelHeight = 130;
1835		var defaultPanelWidth = 200;
1836		var panelSide = overlayPanelSettings.panelSide;
1837
1838		var classCpt = 0;
1839		// panel searchEngine map
1840		$("div[name^='panel-']").each(function (event) {
1841			var marginForCurrentPanel = startPanelMargin;
1842			if (globalPanelArray.length > 0 ) {
1843				for (var i in globalPanelArray) {
1844					if (globalPanelArray[i].cssDirection == "left") {
1845						marginForCurrentPanel += 1 + globalPanelArray[i]['height'] + parseInt(globalPanelArray[i]['header'].css('padding-top')) + parseInt(globalPanelArray[i]['header'].css('padding-bottom'));
1846					}
1847				}
1848			}
1849			var panelName = $(this).attr('rel').substr(6);
1850			var panelClass = $(this).attr('name').substr(6);
1851			var myPanel = new OverlayPanel(panelName, panelClass, panelSide, defaultPanelWidth, defaultPanelHeight, marginForCurrentPanel, 40);
1852			var cls = 'tourism-facette-' + classCpt++;
1853			myPanel.addClass(cls);
1854			$('#headerdiv-' + panelClass).addClass(cls);
1855			myPanel.append($(this));
1856		});
1857
1858		var headerWrapper = $(document.createElement('div'));
1859		headerWrapper.addClass('overlay_panel_headers_wrapper');
1860		headerWrapper.append($('.overlay_panel_header'));
1861		mapDiv.append(headerWrapper);
1862
1863		var headerWrapperCss = {};
1864		switch(panelSide){
1865			case 'right':
1866				headerWrapperCss = {
1867					'top':50,
1868					'right':0
1869				};
1870				break;
1871			default:
1872				break;
1873		}
1874		headerWrapper.css(headerWrapperCss);
1875
1876		// on toggle le panel ouvert en mode non fullscreen
1877		var panelToToggle = $(".deplier").closest("div[name^='panel-']").attr('name');
1878		if (typeof(panelToToggle) != 'undefined') {
1879			var classToFind = panelToToggle.substr(6);
1880			$("#headerdiv-"+classToFind).trigger('click');
1881		};
1882
1883		$('.fullscreen_control_wrapper').addClass('on').removeClass('off');
1884		$('.content-facette').css('max-height', $('.fullscreenMapDiv').height()-100);
1885
1886	// passage en mode normal
1887	} else {
1888		$(document).scrollTop(oldScroll);
1889
1890		var currentPanelPl = $('#idPl_'+currentPl).next().find('form');
1891		currentPanelPl.hide();
1892
1893		$('#block-tourism_raccourci-tourism_search_engine .content').html(currentPanelPl);
1894
1895		$("div[name^='panel-']").each(function(event){
1896			var closerPanel = $(this).closest('.overlay_panel');
1897			var closerPanelHeader = closerPanel.next();
1898			$('#block-tourism_raccourci-tourism_search_map_engine .result-facette').find('.panel-container').filter('.'+$(this).attr('name')).append($(this));
1899			closerPanel.remove();
1900			closerPanelHeader.remove();
1901			for (j in globalPanelArray) {
1902				var panelForTest = globalPanelArray[j];
1903				if(typeof(panelForTest.header) != 'undefined'){
1904					if (typeof(panelForTest.header.context) != 'undefined'){
1905						if (panelForTest.header.context.id == closerPanelHeader.attr('id')) {
1906							globalPanelArray.splice(j, 1);
1907						}
1908					}
1909				}
1910			}
1911		});
1912
1913		var closerDiv = $('#blockDateSelectionMain').closest('.overlay_div');
1914		$('#block-tourism_raccourci-tourism_date_selection .content').html($('#blockDateSelectionMain'));
1915		closerDiv.remove();
1916
1917		$('.fullscreen_control_wrapper').addClass('off').removeClass('on');
1918
1919		$('.entete-panel').removeClass('deplier').addClass('plier');
1920		$('.entete-panel').filter('.plier').next().hide();
1921		var currentPanel = $('.entete-facette').filter('.deplier').closest('.panel-container').find('.entete-panel');
1922		currentPanel.trigger('click');
1923
1924		$('.overlay_panel_headers_wrapper').remove();
1925		$('.entete-facette')
1926			.unbind('click')
1927			.click({parent : 'entete-facette'}, slideMe);
1928
1929		$('.entete-panel')
1930			.unbind('click')
1931			.click({parent : 'entete-panel'}, slideMe);
1932
1933		fromCol.trigger('click');
1934		scrollToTop();
1935	}
1936
1937	window.dispatchEvent(createNewEvent('resize'));
1938	resizeMap(center);
1939}
1940
1941/**
1942 *  debounce: Prevent a function to be launch too many times
1943 */
1944function debounce(func, wait, immediate) {
1945	var timeout;
1946	return function() {
1947		var context = this, args = arguments;
1948		var later = function() {
1949			timeout = null;
1950			if (!immediate) func.apply(context, args);
1951		};
1952		var callNow = immediate && !timeout;
1953		clearTimeout(timeout);
1954		timeout = setTimeout(later, wait);
1955		if (callNow) func.apply(context, args);
1956	};
1957}
1958
1959/**
1960*  @desc Active ou désactive le mode Plein écran
1961*/
1962resizeMap = function (center){
1963	debounce(function () {
1964		window.dispatchEvent(createNewEvent('resize'));
1965	}, 100)
1966
1967	if (typeof(center) != "undefined"){
1968		map.setView(center, map.getZoom());
1969	} else {
1970		map.setZoom(map.getZoom());
1971	}
1972
1973	mapHeight = mapDiv.innerHeight();
1974	updatePanelPositions();
1975}
1976
1977/**
1978*  @desc Active ou désactive le mode Plein écran
1979*/
1980updatePanelPositions = function()
1981{
1982	for(var i in globalPanelArray){
1983		globalPanelArray[i].replacePanel();
1984	}
1985	for(var i in globalDivArray){
1986		globalDivArray[i].replacePanel();
1987	}
1988}
1989
1990/**
1991*  @desc Window pour afficher les informations d'une fiche
1992*/
1993makeWindow = function(marker, map, content)
1994{
1995	marker.on('click', function() {
1996		infobox = new L.Popup({
1997            offset: [0, -30],
1998            maxWidth : 300,
1999        });
2000        infobox.setContent(content);
2001        infobox.setLatLng(marker.getLatLng());
2002        map.openPopup(infobox);
2003
2004		$(infobox).ready(function() {
2005			initMapInfoWindowBehaviour();
2006		});
2007    });
2008}
2009
2010addToTravelCart = function(ids)
2011{
2012	$.get('/travelcart/ajax/add/' + ids, function(data){
2013		// Changer le lien ajouter en supprimer
2014	});
2015}
2016
2017/**
2018* @desc : Crée le contenu d'un marker static
2019* @param idFiche : id de la fiche contenu par le marker
2020* @param fiche : contenu de la fiche qui va servir a faire l'infoWindows
2021*/
2022buildMapWindow = function(fiche)
2023{
2024	var content = '';
2025	content += '<div class="infowindow">';
2026	content += '<h3>' + fiche.raison_sociale + '</h3>';
2027	content += fiche.image || '';
2028	content += '<p>';
2029	content += '<b>Adresse</b> : ';
2030	content += fiche.adresse ? fiche.adresse + '<br />' : '';
2031	content += fiche.code_postal ? fiche.code_postal + ' - ' : '';
2032	content += fiche.commune ? fiche.commune + '<br/>' : '';
2033	content += fiche.telephone ? '<b>Téléphone</b> : ' + fiche.telephone + '<br />' : '';
2034	content += fiche.telephone2 ? '<b>Téléphone</b> : ' + fiche.telephone2 : '';
2035	content += fiche.telephone_fax ? '<b>Téléphone</b> : ' + fiche.telephone_fax : '';
2036	content += '</p>';
2037	// content += fiche.urlDetail ? '<p><b><a href="' + fiche.urlDetail +'#contact" target="_blank"> Contact</a></b></p>' : '';
2038	content += fiche.site_web ? '<p><a href="' + fiche.site_web + '" target="_blank">Site internet</a></p>' : '';
2039	content += fiche.urlDetail ? '<p><a class="infowindow-opendetail" id="detail_' + fiche.idFiche + '">  En savoir plus </a></p>' : '';
2040	content += '</div>';
2041
2042	return content;
2043}
2044
2045/**
2046 * @desc Créer un marker, son infobulle et les evenements
2047 */
2048makeMarkerWithContent = function(idFiche, fiche, icone)
2049{
2050	if (!icone || typeof(icone) == "undefined"){
2051		icone = 'default/marker_generic';
2052	}
2053
2054	var latlng = [fiche.gps_lat, fiche.gps_lng];
2055	var icon = L.icon({
2056		iconUrl : '/'+module_base_path+'/ressources/isc/images/gmaps/'+icone+'.png',
2057		iconAnchor: [17, 36],
2058		iconSize: [35, 36]
2059	});
2060	var marker = L.marker( latlng, {
2061		draggable: false,
2062		clickable: true,
2063		icon: icon
2064	});
2065    marker.position = latlng;
2066    marker.title =  fiche.raison_sociale;
2067    marker.fiche = fiche;
2068
2069	var content;
2070
2071	if(typeof(use_ajax_infowindow) != 'undefined' && use_ajax_infowindow){
2072		var displayInfowindowAjaxResult = function(infobox, data, map){
2073			infobox.setContent(data);
2074			infobox.openOn(map);
2075		}
2076
2077		marker.on('click', function(){
2078			if(infobox){
2079				map.closePopup();
2080			}
2081			$.get('/tourism/ajax/getWindow/Mapdetail', {
2082				idFiche:fiche.idFiche,
2083				idPlaylist:fiche.idPlaylist
2084			}, function(data){
2085				data = $.parseJSON(data);
2086				imgs = $(data).find('img');
2087				if(imgs.exists()){
2088					imgs.load(function(){
2089						displayInfowindowAjaxResult(infobox, data, map, marker);
2090					});
2091				} else {
2092					displayInfowindowAjaxResult(infobox, data, map, marker);
2093				}
2094				initMapInfoWindowBehaviour();
2095			});
2096		});
2097		content = '<div id="infowindow-fiche-' + fiche.idFiche + '" class="loader-infowindow" style="text-align:center"><img src="/' + module_base_path + '/ressources/isc/images/ajax-loader.gif"/></div>';
2098	} else {
2099		content = buildMapWindow(fiche);
2100	}
2101
2102    marker.content = content;
2103	marker.addTo(markersLayer);
2104    makeWindow(marker, map, content);
2105
2106	return marker;
2107}
2108
2109// redirige vers le mode detail d'une fiche OU ALORS vers l'onglet du mode détail de la fiche quand nous sommes en fullScreen.
2110showFicheDetail = function(idFiche)
2111{
2112	var fiche = listFiches[idFiche];
2113	detailPanel ? detailPanel.addOnglet(fiche.idFiche, fiche.idPlaylist, fiche.raison_sociale) : window.open(fiche.urlDetail);
2114}
2115
2116/**
2117 * @desc Initialise le comportement JS de l'infobulle Leaflet Map
2118 */
2119initMapInfoWindowBehaviour = function()
2120{
2121	$('.infowindow-opendetail').unbind('click').click(function(event){
2122		event.preventDefault();
2123		showFicheDetail($(this).attr('id').replace('detail_', ''));
2124	});
2125}
2126
2127// La suite du code ne concerne que les itinéraires
2128/**
2129*  @desc Composition pour ajouter des informations au marker
2130*/
2131POIMarker = function() {
2132
2133	this.gmarker;//marker Gmaps
2134	this.urlDetail;//url pour les POI fiche
2135	this.pinImg;//image du marker
2136	this.name;//nom du POI
2137	this.position;//position dans l'itinéraire
2138	//this.iDPOIMultimedia;
2139	this.indexInPOIArray;
2140	this.type;
2141
2142}
2143
2144/**
2145*  @desc initialise une map pour un itinéraire en mode liste
2146*  @param jSON de la fiche itinéraire
2147*  @param idMapDiv id de la div dans laquelle sera affichée la map
2148*/
2149initItinerairePreview = function(itineraire, idMapDiv)
2150{
2151	// Europe bbox
2152	var topLeftCorner = L.latLng(51.83, -5.53),
2153		bottomRightCorner = L.latLng(41.1, 9.96),
2154		maxBounds = L.latLngBounds(topLeftCorner, bottomRightCorner),
2155		minZoom = 5,
2156		maxZoom = 20;
2157
2158	var myOptions = {
2159		zoom: 12,
2160		zoomControl: false,
2161		maxBounds: maxBounds,
2162		minZoom: minZoom,
2163		maxZoom: maxZoom
2164	};
2165
2166	// init map
2167	map = L.map(document.getElementById(idMapDiv),myOptions);
2168	map.setView([defaultLat, defaultLng], map.getZoom(), {reset: false});
2169
2170	//console.warn(map.getZoom(), [defaultLat, defaultLng]);
2171	var initLeafletTilesTest = initLeafletTiles(map, false);
2172	if (!initLeafletTilesTest) return;
2173
2174	var nbPoints = itineraire.tabPoints.length,
2175		point1 = L.Point(0, 0),
2176		point2 = L.Point(10, 20),
2177		size1 = L.Point(36, 37),
2178		size2 = L.Point(20, 20),
2179		bounds = new L.LatLngBounds(),
2180		location,
2181		poly = [];
2182
2183	// boucle sur les points du tracé
2184	for (var i = 0; i < nbPoints; i++) {
2185		location = new L.latLng(itineraire.tabPoints[i].lat, itineraire.tabPoints[i].lng);
2186		if (i == 0 || i == (nbPoints - 1)) {
2187			var pin = i == 0 ? pinDep  : pinArr;
2188			var icon = L.icon({
2189				iconUrl : pin,
2190				iconAnchor: [10, 24],
2191				iconSize: [20, 24]
2192			});
2193			L.marker(location, {
2194				position: location,
2195				icon: icon,
2196				clickable: false
2197			}).addTo(markersLayer);
2198		}
2199
2200		poly.push(location);
2201		bounds.extend(location);
2202	}
2203
2204	// crée le tracé à partir du tableau de point
2205	var flightPath = L.polyline(poly ,{
2206		color: "#F08A04",
2207		opacity: 1,
2208		weight: 3
2209	});
2210
2211	//affiche le tracé
2212	flightPath.addTo(map);
2213
2214	// recadre la map autour du tracé
2215	map.fitBounds(bounds);
2216	previewMaps.push(map);
2217}
2218
2219/**
2220*  @desc initialise la map pour un itinéraire
2221*  @param jSON traité par tourismXSLTools::remakeJsonItineraire
2222*/
2223initItineraire = function (itineraire, opts){
2224	opts = opts || {};
2225
2226	// Europe bbox
2227	var topLeftCorner = L.latLng(51.83, -5.53),
2228		bottomRightCorner = L.latLng(41.1, 9.96),
2229		maxBounds = L.latLngBounds(topLeftCorner, bottomRightCorner),
2230		minZoom = 5,
2231		maxZoom = 20;
2232
2233	var myOptions = $.extend({}, {
2234		zoom: 12,
2235		zoomControl: false,
2236		maxBounds: maxBounds,
2237		minZoom: minZoom,
2238		maxZoom: maxZoom
2239	}, opts);
2240
2241
2242
2243	// init map
2244	map = L.map(document.getElementById("map_canvas_itineraire"), myOptions);
2245	map.setView([defaultLat, defaultLng], map.getZoom(), {reset: false});
2246
2247	var initLeafletTilesTest = initLeafletTiles(map);
2248
2249	//initialisations pour le FullScreen
2250	if(!opts.avoidFullscreen){
2251		mapDiv = $("#map_canvas_itineraire");
2252		mapParent = mapDiv.parent();
2253		topControlsDiv = $(document.createElement("DIV")).css("z-index","999999999").css("position","absolute").css("top","10px!important").css("left","10px!important");
2254		topControlsDiv.addClass("top_control_wrapper");
2255		var fullscreenControl = new FullScreenControl("FULLSCREEN", topControlsDiv, map);
2256
2257		fullScreenDiv = $(document.createElement("DIV"));
2258		$(window).resize(function() {
2259			resizeMap();
2260		});
2261
2262		mapDiv.append(topControlsDiv);
2263	}
2264
2265	if (!initLeafletTilesTest) return;
2266
2267	//vars
2268	var nbPoints = itineraire.tabPoints.length;
2269	var bounds = new L.LatLngBounds();
2270	poly = [];
2271	markers = [];
2272
2273	//boucle sur les points du tracé
2274	for (var i = 0; i < nbPoints; i++) {
2275		var location = new L.latLng(itineraire.tabPoints[i].lat, itineraire.tabPoints[i].lng);
2276		poly.push(location);
2277		bounds.extend(location);
2278
2279		// Star & End point markers
2280		if (i == 0 || i == (nbPoints - 1)) {
2281			var pin = i == 0 ? pinDep  : pinArr;
2282			var icon = L.icon({
2283				iconUrl : pin,
2284				// iconSize: [36, 37],
2285				iconAnchor: [18, 37]
2286				// popupAnchor: [-3, -76],
2287			});
2288			L.marker(location, { icon: icon, clickable: true }).addTo(markersLayer);
2289		}
2290	}
2291
2292	//concaténation des POI fiche et multimedia
2293	var POIs = itineraire.poiMultimedia.concat(itineraire.poiFiche);
2294
2295	//fonction de tri de POI par position
2296	function sortPOI(a,b) {	return a.pos - b.pos; }
2297	//tri des POIs
2298	POIs.sort(sortPOI);
2299
2300	//parcours les POI et crée les POIMarkers
2301	for (var i = 0; i < POIs.length; i++) {
2302
2303		var location;
2304
2305		if ( POIs[i] ) {
2306			if( 'gpsLat' in POIs[i]){
2307				location = new L.latLng(POIs[i].gpsLat, POIs[i].gpsLng);
2308			} else {
2309				location = new L.latLng(POIs[i].lat, POIs[i].lng);
2310			}
2311
2312			var pin = POIs[i].pinImg;
2313			var icon = L.icon({
2314				iconUrl: pin,
2315				iconAnchor: [15, 30]
2316				// iconSize: [35, 36],
2317				// popupAnchor: [-3, -76],
2318			});
2319			var marker = L.marker(location, {
2320				icon: icon,
2321				clickable: true
2322			}).addTo(markersLayer);
2323
2324			var poiMarker = new POIMarker();
2325			poiMarker.indexInPOIArray = i;
2326			poiMarker.gmarker = marker;
2327			poiMarker.name = POIs[i].name;
2328			poiMarker.position = POIs[i].pos;
2329			poiMarker.type = POIs[i].type;
2330			markers.push(poiMarker);
2331			listenerMarker(poiMarker);
2332			bounds.extend(location);
2333		}
2334
2335	}
2336
2337	//crée le tracé à partir du tableau de point
2338	var flightPath = L.polyline(poly, {
2339		color: "#F08A04",
2340		opacity: 1.0,
2341		weight: 3
2342	});
2343
2344	//affiche le tracé
2345	flightPath.addTo(map);
2346
2347	//recadre la map autour du tracé
2348	map.fitBounds(bounds);
2349
2350	//initialise le trim des description
2351	$(".poiMixte .descriptionPOI").each(function(){
2352		// trimDescription($(this));
2353
2354		$(this).children('.descriptionAddendum').hide();
2355		var linkmore = $(document.createElement('a')).attr('class','linkDescriptionAddendum linkMore').html('..More').appendTo($(this));
2356		var hoverContent = $(this).parent().find('.hiddenDescriptionMixte');
2357
2358		$(this).find('.linkMore').colorbox({width:"750px",
2359		height:'650px;',
2360		inline:true,
2361		href:'#'+hoverContent.attr('id'),
2362		onOpen : function(){
2363			hoverContent.show();
2364		},
2365		onCleanup : function(){
2366			hoverContent.hide();
2367		},
2368		returnFocus:false
2369		});
2370	});
2371
2372	//initialise le trim des description
2373	$(".poiSimple .descriptionPOI").each(function(){
2374		// trimDescription($(this));
2375
2376		$(this).children('.descriptionAddendum').hide();
2377		var linkmore = $(document.createElement('a')).attr('class','linkDescriptionAddendum linkMore').html('..More').appendTo($(this));
2378		var hoverContent = $(this).parent().find('.hiddenDescriptionSimple');
2379
2380		$(this).find('.linkMore').colorbox({width:"750px",
2381		height:'350px;',
2382		inline:true,
2383		href:'#'+hoverContent.attr('id'),
2384		onOpen : function(){
2385			hoverContent.show();
2386		},
2387		onCleanup : function(){
2388			hoverContent.hide();
2389		},
2390		returnFocus:false
2391		});
2392	});
2393
2394	$(".poiFiche .descriptionPOI").each(function(){
2395		var linkmore = $(document.createElement('a')).attr('class','linkDescriptionAddendum linkMore').html('..More').appendTo($(this));
2396		var hoverContent = $(this).parent().find('.hiddenDescriptionFiche');
2397
2398		$(this).find('.linkMore').colorbox({
2399			width:"390px",
2400			inline:true,
2401			href:'#'+hoverContent.attr('id'),
2402			onOpen : function(){
2403				hoverContent.show();
2404			},
2405			onCleanup : function(){
2406				hoverContent.hide();
2407			},
2408			returnFocus:false
2409		});
2410	});
2411
2412	$(".poiImage .linkMore").click(function(){
2413		$(this).prev('ul').children().first().find('a').trigger('click');
2414		return false;
2415	});
2416
2417	$(".poiImage").each(function(){
2418		$(this).find('.poi_content a[rel^=\'slideshow\']').colorbox({
2419			returnFocus: false,
2420			photo: true
2421		});
2422	});
2423
2424	// $(".poiFiche").each(function(){
2425	// $(this).find('.linkMore').colorbox({width:'50%', height:'90%', returnFocus:false});
2426	// });
2427
2428	$(".poiAudio").each(function(){
2429		$(this).find('.linkMore').hide().colorbox({	width:'230px',
2430		height:'135px',
2431		inline:true,
2432		href:'#'+$(this).find('.linkMore').prev('div').attr('id'),
2433		returnFocus:false
2434		});
2435	});
2436
2437	//initialisation des boutons Suivant/Précédent
2438	// var nextButton = $(document.createElement('span')).addClass('nextPoiButton').html("Next POI");
2439	// nextButton.click(function(){
2440	// nextPOI();
2441	// });
2442	// var prevButton = $(document.createElement('span')).addClass('previousPoiButton').html("Previous POI");
2443	// prevButton.click(function(){
2444	// prevPOI();
2445	// });
2446	// var navigatorDiv = $(document.createElement('div')).addClass('navigationButtonsWrapper').append(prevButton).append(nextButton);
2447	// mapDiv.append(navigatorDiv);
2448
2449	$('.poi_name').click(function(){
2450		$(this).parent().find('.linkMore').trigger('click')
2451	});
2452}
2453
2454/**
2455*  @desc initialise la map pour un sejour
2456*/
2457initSejour = function(sejour){
2458
2459
2460	// Europe bbox
2461	var topLeftCorner = L.latLng(51.83, -5.53),
2462		bottomRightCorner = L.latLng(41.1, 9.96),
2463		maxBounds = L.latLngBounds(topLeftCorner, bottomRightCorner),
2464		minZoom = 5,
2465		maxZoom = 20;
2466
2467	var myOptions = {
2468		zoom: 12,
2469		zoomControl: false,
2470		maxBounds: maxBounds,
2471		minZoom: minZoom,
2472		maxZoom: maxZoom
2473	};
2474
2475	//vars
2476	var nbPoints = sejour.tabPoints.length;
2477		bounds = new L.LatLngBounds();
2478		poly = [];
2479		markers = [];
2480
2481	//init map
2482	map = L.map(document.getElementById('map_canvas_sejour'), myOptions);
2483	map.setView([defaultLat, defaultLng], map.getZoom(), {reset: false});
2484
2485	var initLeafletTilesTest = initLeafletTiles(map, true);
2486
2487	//initialisations pour le FullScreen
2488	mapDiv = $("#map_canvas_sejour");
2489	mapParent = mapDiv.parent();
2490	topControlsDiv = $(document.createElement("DIV")).css("z-index","999999999").css("position","absolute").css("top","20px").css("right","20px");
2491	topControlsDiv.addClass("top_control_wrapper");
2492	var fullscreenControl = new FullScreenControl("FULLSCREEN",topControlsDiv, map);
2493	fullScreenDiv = $(document.createElement("DIV"));
2494	mapDiv.append(topControlsDiv);
2495
2496	if (!initLeafletTilesTest) return;
2497
2498	//boucle sur les points du tracé
2499	for (var i = 0; i < nbPoints; i++) {
2500		var location = new L.latLng(sejour.tabPoints[i].lat, sejour.tabPoints[i].lng);
2501		poly.push(location);
2502		bounds.extend(location);
2503
2504		if (i == 0 || i == (nbPoints - 1)) {
2505			var pin = i == 0 ? pinDep  : pinArr;
2506			var icon = L.icon({
2507				iconUrl : pin,
2508				iconAnchor: [18, 37]
2509				// iconSize: [36, 37],
2510				// popupAnchor: [-3, -76],
2511			});
2512
2513			var marker = L.marker(location, {
2514				icon: icon,
2515				clickable: true
2516			}).addTo(markersLayer);
2517		}
2518	}
2519
2520	//concaténation des POI fiche et multimedia
2521	var POIs = sejour.poiMultimedia.concat(sejour.poiFiche);
2522
2523	//fonction de tri de POI par position
2524	function sortPOI(a,b)
2525	{
2526		return a.pos - b.pos;
2527	}
2528	//tri des POIs
2529	POIs.sort(sortPOI);
2530
2531	//parcours les POI et crée les POIMarkers
2532	for (var i = 0; i < POIs.length; i++) {
2533
2534		var location;
2535		if ( POIs[i] ) {
2536			if( 'gpsLat' in POIs[i]){
2537				location = new L.latLng(POIs[i].gpsLat, POIs[i].gpsLng);
2538			} else {
2539				location = new L.latLng(POIs[i].lat, POIs[i].lng);
2540			}
2541
2542			var pin = POIs[i].pinImg;
2543			var icon = L.icon({
2544				iconUrl : pin,
2545				iconAnchor: [15, 30],
2546				iconSize: [30, 30]
2547			});
2548			var marker = L.marker(location, {
2549				icon: icon,
2550				clickable: true
2551			}).addTo(markersLayer);
2552
2553			var poiMarker = new POIMarker();
2554			poiMarker.indexInPOIArray = i;
2555			poiMarker.gmarker = marker;
2556			poiMarker.name = POIs[i].name;
2557			poiMarker.position = POIs[i].pos;
2558			poiMarker.type = POIs[i].type;
2559			markers.push(poiMarker);
2560			listenerMarker(poiMarker);
2561			bounds.extend(location);
2562		}
2563	}
2564
2565	//crée le tracé à partir du tableau de point
2566	var flightPath = L.polyline(poly, {
2567		color: "#F08A04",
2568		opacity: 1.0,
2569		weight: 3
2570	});
2571
2572	//affiche le tracé
2573	flightPath.addTo(map);
2574
2575	//recadre la map autour du tracé
2576	map.fitBounds(bounds);
2577
2578	$(window).resize(function() {
2579		resizeMap();
2580	});
2581
2582	//initialise le trim des description
2583	$(".poiSimple .descriptionPOI").each(function(){
2584		// trimDescription($(this));
2585
2586		$(this).children('.descriptionAddendum').hide();
2587		var linkmore = $(document.createElement('a')).attr('class','linkDescriptionAddendum linkMore').html('..More').appendTo($(this));
2588		var hoverContent = $(this).parent().find('.hiddenDescriptionSimple');
2589
2590		$(this).find('.linkMore').colorbox({width:"750px",
2591		height:'350px;',
2592		inline:true,
2593		href:'#'+hoverContent.attr('id'),
2594		onOpen : function(){
2595			hoverContent.show();
2596		},
2597		onCleanup : function(){
2598			hoverContent.hide();
2599		},
2600		returnFocus:false
2601		});
2602	});
2603
2604	$(".poiFiche .descriptionPOI").each(function(){
2605		var linkmore = $(document.createElement('a')).attr('class','linkDescriptionAddendum linkMore').html('..More').appendTo($(this));
2606		var hoverContent = $(this).parent().find('.hiddenDescriptionFiche');
2607
2608		$(this).find('.linkMore').colorbox({
2609			width:"390px",
2610			//innerHeight:'20%',
2611			inline:true,
2612			href:'#'+hoverContent.attr('id'),
2613			onOpen : function(){
2614				hoverContent.show();
2615			},
2616			onCleanup : function(){
2617				hoverContent.hide();
2618			},
2619			returnFocus:false
2620		});
2621	});
2622
2623	//initialise le trim des description
2624	$(".poiMixte .descriptionPOI").each(function(){
2625		// trimDescription($(this));
2626
2627		$(this).children('.descriptionAddendum').hide();
2628		var linkmore = $(document.createElement('a')).attr('class','linkDescriptionAddendum linkMore').html('..More').appendTo($(this));
2629		var hoverContent = $(this).parent().find('.hiddenDescriptionMixte');
2630
2631		$(this).find('.linkMore').colorbox({width:"750px",
2632		height:'600px;',
2633		inline:true,
2634		href:'#'+hoverContent.attr('id'),
2635		onOpen : function(){
2636			hoverContent.show();
2637		},
2638		onCleanup : function(){
2639			hoverContent.hide();
2640		},
2641		returnFocus:false
2642		});
2643	});
2644
2645	$(".poiImage .linkMore").click(function(){
2646		$(this).prev('ul').children().first().find('a').trigger('click');
2647		return false;
2648	});
2649
2650	$(".poiImage").each(function(){
2651		$(this).find('a[rel^=\'slideshow\']').colorbox({returnFocus:false});
2652	});
2653
2654	// $(".poiFiche").each(function(){
2655	// $(this).find('.linkMore').colorbox({width:'50%', height:'90%', returnFocus:false});
2656	// });
2657
2658	$(".poiAudio").each(function(){
2659		$(this).find('.linkMore').hide().colorbox({	width:'230px',
2660		height:'135px',
2661		inline:true,
2662		href:'#'+$(this).find('.linkMore').prev('div').attr('id'),
2663		returnFocus:false
2664		});
2665	});
2666
2667	//initialisation des boutons Suivant/Précédent
2668	// var nextButton = $(document.createElement('span')).addClass('nextPoiButton').html("Next POI");
2669	// nextButton.click(function(){
2670	// nextPOI();
2671	// });
2672	// var prevButton = $(document.createElement('span')).addClass('previousPoiButton').html("Previous POI");
2673	// prevButton.click(function(){
2674	// prevPOI();
2675	// });
2676	// var navigatorDiv = $(document.createElement('div')).addClass('navigationButtonsWrapper').append(prevButton).append(nextButton);
2677	// mapDiv.append(navigatorDiv);
2678
2679	$('.poi_name').click(function(){
2680		$(this).parent().find('.linkMore').trigger('click')
2681	});
2682}
2683
2684/**
2685*  @desc crée un overlay sur la map pour afficher les détails d'un POI Multimédia
2686*  @param content
2687*/
2688makeMapInfoOverlay = function(mapDiv, content) {
2689
2690	$('#map_overlay_info').remove();
2691	var overlayMap = $(document.createElement('div'));
2692
2693	var overlayContentWrapper = $(document.createElement('div'));
2694
2695	overlayMap.attr('id','map_overlay_info');
2696	overlayMap.css('z-index','99999');
2697	// overlayMap.css('width','300px');
2698	// overlayMap.css('height','300px');
2699	overlayMap.css('background','#ccc');
2700	overlayMap.css('position','absolute');
2701	overlayMap.css('bottom','0');
2702	overlayMap.css('left','200');
2703	overlayContentWrapper.append(content);
2704	overlayMap.append(overlayContentWrapper);
2705
2706	var overlayCloser = $(document.createElement('span'));
2707	overlayCloser.html('Close');
2708	overlayCloser.css('background','#222');
2709	overlayCloser.attr('id','map_overlay_info_closer');
2710
2711	overlayMap.append(overlayCloser);
2712
2713	overlayCloser.click(function(){
2714		$('#map_overlay_info').remove();
2715	});
2716
2717	mapDiv.append(overlayMap);
2718}
2719
2720/**
2721*  @desc initialise les listeners sur les marker pour l'affichage des InfoBox
2722*  @param markerPOI
2723*/
2724listenerMarker = function(marker) {
2725	marker.gmarker.on('click', function (e) {
2726		makeBox(marker);
2727	});
2728};
2729
2730/**
2731*  @desc crée la fenetre d'info du POI
2732*  @param markerPOI
2733*/
2734makeBox = function(marker) {
2735	$('#map_overlay_info').remove();
2736	if (typeof(infobox) == 'object') {
2737		map.closePopup();
2738	}
2739	currentPOI = marker.indexInPOIArray;
2740	var marker = marker;
2741	var box = document.createElement("div");
2742
2743	var boxhtml = document.createElement("div");
2744	boxhtml.setAttribute('id','fiche_pin');
2745
2746	var boxTitle = document.createElement("span");
2747	boxTitle.setAttribute('id','InfoBoxTitle');
2748	boxTitle.innerHTML = marker.name;
2749
2750	box.appendChild(boxhtml);
2751	boxhtml.appendChild(boxTitle);
2752
2753	var lienMore = document.createElement('a');
2754	lienMore.setAttribute('id','boxShowMore');
2755	lienMore.setAttribute('href','#');
2756
2757	boxhtml.innerHTML += $('#poi_'+marker.position+' .hiddenInfoBoxContent').clone().show().html();
2758
2759	switch (marker.type) {
2760		case 'Fiche':
2761			lienMore.innerHTML = 'Afficher les détails';
2762			boxhtml.setAttribute('class','box_fiche');
2763			boxhtml.appendChild(lienMore);
2764			break;
2765		case 'Simple':
2766			lienMore.innerHTML = 'Description complète';
2767			boxhtml.setAttribute('class','box_simple');
2768			boxhtml.appendChild(lienMore);
2769			break;
2770		case 'Image':
2771			lienMore.innerHTML = 'Voir les images';
2772			boxhtml.setAttribute('class','box_image');
2773			boxhtml.appendChild(lienMore);
2774			break;
2775		case 'Audio':
2776			lienMore.innerHTML = 'Jouer le fichier Audio';
2777			boxhtml.setAttribute('class','box_audio');
2778			boxhtml.appendChild(lienMore);
2779			break;
2780		case 'Video':
2781			break;
2782		case 'Mixte':
2783			lienMore.innerHTML = 'Description complète';
2784			boxhtml.setAttribute('class','box_mixte');
2785			boxhtml.appendChild(lienMore);
2786			break;
2787	}
2788
2789	// lien pour passer au POI précédent
2790	var lienPrevious = document.createElement('a');
2791	lienPrevious.setAttribute('id','PrevPOI');
2792	lienPrevious.setAttribute('href','#');
2793	lienPrevious.innerHTML = '<<';
2794	boxhtml.appendChild(lienPrevious);
2795
2796	//lien pour passer au POI suivant
2797	var lienNext = document.createElement('a');
2798	lienNext.setAttribute('id','NextPOI');
2799	lienNext.setAttribute('href','#');
2800	lienNext.innerHTML = '>>';
2801	boxhtml.appendChild(lienNext);
2802
2803	// var myOptions = {
2804	// 	alignBottom: false,
2805	// 	content: box.innerHTML,
2806	// 	disableAutoPan: false,
2807	// 	width: 500,
2808	// 	zIndex: 30,
2809	// 	closeBoxURL: '/'+module_base_path+'/ressources/isc/images/gmaps/close_infowindow_button.png',
2810	// 	infoBoxClearance: L.size(1, 1),
2811	// 	isHidden: false,
2812	// 	pane: "floatPane",
2813	// 	enableEventPropagation: false
2814	// };
2815
2816    // infobox = new InfoBox(myOptions);
2817    infobox = new L.Popup({
2818        offset: [0, -30],
2819        maxWidth : 500,
2820    });
2821	infobox.setContent(box.innerHTML);
2822    infobox.setLatLng(marker.gmarker.getLatLng());
2823    map.openPopup(infobox);
2824
2825
2826	L.DomEvent.addListener(document.getElementById('boxShowMore'),'click',function(event){
2827		event.preventDefault();
2828		$('#poi_'+marker.position+' .poi_name').trigger('click');
2829	});
2830	if(marker.type == 'Image' && $('#linkImgBox').length > 0){
2831		L.DomEvent.addListener(document.getElementById('linkImgBox'),'click',function(event){
2832			event.preventDefault();
2833			$('#poi_'+marker.position+' .poi_name').trigger('click');
2834		});
2835	}
2836
2837	//Listener Previous
2838	L.DomEvent.addListener(document.getElementById('PrevPOI'),'click',function(event){
2839		event.preventDefault();
2840		prevPOI();
2841	});
2842	//Listener Next
2843	L.DomEvent.addListener(document.getElementById('NextPOI'),'click',function(event){
2844		event.preventDefault();
2845		nextPOI();
2846	});
2847
2848}
2849
2850nextPOI = function() {
2851	if(typeof(currentPOI) == 'undefined'){makeBox(markers[0]);return;}
2852	indexNextMarker = currentPOI+1;
2853	if(currentPOI >= markers.length-1){
2854		indexNextMarker = 0;
2855	}
2856	makeBox(markers[indexNextMarker]);
2857}
2858
2859prevPOI = function() {
2860	if(typeof(currentPOI) == 'undefined'){makeBox(markers[0]);return;}
2861	indexPreviousMarker = currentPOI-1;
2862	if(currentPOI <= 0){
2863		indexPreviousMarker = markers.length-1;
2864	}
2865	makeBox(markers[indexPreviousMarker]);
2866}
2867
2868GetClustersStyles = function(type, width, height, opts)
2869{
2870	var iconName = type ? type + '_cluster.png' : 'cluster.png';
2871	cWidth = width || 32;
2872	cHeight = width || 32;
2873	opts = opts || {};
2874
2875	var styleObj = {
2876		url: '/' + module_base_path + '/ressources/isc/images/gmaps/clusters/' + iconName,
2877		height: cWidth,
2878		width: cHeight,
2879		opt_textColor: '#fff',
2880		opt_textSize: 10
2881	};
2882
2883	$.extend(styleObj, opts);
2884
2885	return [styleObj, styleObj, styleObj];
2886}
2887
2888/*
2889*
2890*/
2891bindWithArgs = function(objet, methode) {
2892	var myArgs = arguments;
2893	return function()
2894	{
2895		var args = [];
2896		for (var i in myArgs)
2897		{
2898			if (i > 1)
2899			{
2900				args.push(myArgs[i]);
2901			}
2902		}
2903		for (var i in arguments)
2904		{
2905			args.push(arguments[i]);
2906		}
2907		return methode.apply(objet, args);
2908	}
2909};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.