PageSourceSearch

https://www.gites-de-france-22-35-56.fr/lib_2/js/pagesWeb/general.js?t=1774865238

js gites-de-france-22-35-56.fr collected 2026-10-07 13:37:47 UTC 105,596 bytes, 2,947 lines download raw bytes

1var urlCptClient = '/lib_2/ajax/gereCptClient.php';
2
3$(document).ready(function () {
4    // on peut pas enlever les scripts ici car l'html est appelé dans les looks des sites
5    if ($('.owl-carousel, .iteaV5_ul_galerieImage, .iteaV5_ul_galerieImageAvecLegende').length > 0) {
6        $('.scripts.apis_externes').append('<script src="/api_externe/owlCarousel-2.2.1/owl.carousel.min.js"></script>');
7        $('.scripts.apis_externes').append('<link href="/api_externe/owlCarousel-2.2.1/owl.carousel.css" rel="stylesheet" media="screen" type="text/css" />');
8    }
9    if ($('#dateRangePicker').length > 0) {
10        if (typeof dateRangePicker_setRegional != 'function') {
11			$('.scripts.apis_externes').append('<script src="/api_externe/dateRangePicker_v2.0/drp-fr-FR.js"></script>');
12		}
13        $('.scripts.apis_externes').append('<script src="/api_externe/dateRangePicker_v2.0/DateRangePicker.min.js"></script>');
14    }
15
16    // diverses fonctions d'initialisation globales
17    init_moteur_selectOnChange();
18    init_moteur_imitecheckbox();
19    init_moteur_imiteCheckBoxPasLien();
20    init_moteur_imiteCheckBoxPasLienX();
21    initClicBody();
22    initAlerteGeneral();
23    initCalendrierDisposGP();
24    initClicOut();
25    setActionSurDiaporama();
26    initialiseToutesDivQtip();
27    initCarteSitesTouristiques();
28    trackPdfGoogleAnalytics();
29
30    // fonctions qu'on peut appeler dans les looks
31    if (window.oninit) { oninit(); }
32    if (window.oninit1) { oninit1(); }
33    if (window.oninit2) { oninit2(); }
34    if (window.oninit3) { oninit3(); }
35});
36
37function chargeScript(urlScript, fonctionCallback) {
38    var script = document.createElement('script');
39    script.src = urlScript;
40    if(typeof fonctionCallback === 'function'){
41        script.addEventListener('load', function () {
42            fonctionCallback();
43        }, false);
44    }
45    document.getElementsByTagName('head')[0].appendChild(script);
46}
47
48function affMsgAttenteParDessusInDiv(nomDiv,suffixe,txt,forcerSansoffset){
49	var elem=$('#' + nomDiv);
50	if (!suffixe)suffixe="";
51	if (!txt)txt="";
52    if(!forcerSansoffset) forcerSansoffset = false;
53	if ($(elem).length > 0){
54		var style = 'position:absolute;';
55        style += 'z-index:9999;';
56        style += 'width:' + elem.outerWidth() + 'px;';
57		if (elem.offsetHeight>0) {
58            style += 'height:' + elem.outerHeight() + 'px;';
59        } else {
60            style += 'height:100%;';
61        }
62        style += 'top:' + elem.offset().top + 'px;';
63        style += 'left:' + elem.offset().left + 'px;';
64        style += 'opacity:0.6;';
65        style += 'background:#FFFFFF;';
66
67        getNewDivChild(elem, 'divChargementParDessus' + suffixe, 'chargement', style);
68
69        if(forcerSansoffset){
70            //dans le cas ou la div parente est mise en position relative en js, on ne le sais pas ==> on force (ie gmap)
71			$(divCharg).css('top','0px');
72			$(divCharg).css('left','0px');
73        }
74        else if (elem.positionedOffset){
75			var pos=elem.positionedOffset();
76			$(divCharg).css('top',pos.top + 'px');
77			$(divCharg).css('left',pos.left + 'px');
78		}
79
80		if(!txt) {
81            txt = '<img id="imgRechargement" style="margin:auto;" width="16" height="16" src="/config_v3/imgs_defaut/loading/roue16x16.gif" />';
82        }
83		$('#divChargementParDessus' + suffixe).append('<div id="divRechargementParDessus' + suffixe + '"><table class="table_transparence" width="100%" height="100%"><tr valign="middle"><td align="center"><div id="divChargementParDessusMsg">' + txt + '</div></td></tr></table></div>');
84	
85		return $('#divChargementParDessusMsg');
86	}
87	return null;
88}
89
90function getNewDivChild(objParent,ident,classe,style){
91	var newdiv = '<div id="' + ident + '" class="' + classe + '" style="' + style + '"></div>';
92    objParent.append(newdiv);
93	return newdiv;
94}
95
96function moteur_affMessageLoadingMoteur(){
97    if($("#bodyPage")){        
98        var txt = '<div class="loaderMoteur"><div><div class="cp-spinnerLoader cp-ballsLoader"></div></div></div>';        
99        // attribuer la classe "hideMeWhenReload" pour masquer une ou plusieurs zones à recharger
100        if($(".hideMeWhenReload").length>0){
101            $.each($(".hideMeWhenReload"), function() {                
102                affMsgAttenteParDessusInDiv($(this).attr('id'),"moteur",txt);            
103            });
104        } else {
105            affMsgAttenteParDessusInDiv("bodyPage","moteur",txt);
106        }        
107    }
108}
109
110function init_moteur_selectOnChange(){
111    $(".moteur_selectOnChange").bind('change selectmenuchange',function() {
112        var cgi = $(this).attr("name");
113        var value = this.value;
114        var url = document.location.href;
115        if(window.initClicMoteur_selectOnChange){ // fonction à définir dans look
116            initClicMoteur_selectOnChange($(this));
117        }
118        if($("#moteur_inptUrlListe") && $("#moteur_inptUrlListe").val()){
119            //moteur_inptUrlListe permet de définir une autre page que la page en cour.
120            //moteur_inptUrlListe_supprimerCGI permet de ne pas garder les cgis en cours
121            var urlSeule = url.substring( 0 ,url.lastIndexOf( "/" ) );
122            var autresCGI = url.substring( url.lastIndexOf( "?" )+1, url.length );
123            if($("#moteur_inptUrlListe_supprimerCGI") && $("#moteur_inptUrlListe_supprimerCGI").val() == '1'){
124                autresCGI = '';
125            }
126            url = urlSeule+'/'+$("#moteur_inptUrlListe").val()+'?'+autresCGI;
127        } 
128        if($("#"+$(this).attr("id")+" option:selected").attr("data-url") != undefined && $("#"+$(this).attr("id")+" option:selected").attr("data-url").length>0){
129            url = $("#"+$(this).attr("id")+" option:selected").attr("data-url");
130        } 
131        url = getUrlWithLstParam(url, cgi, value);
132        
133        // 322629
134        if (cgi === 'lieu'){
135            url = removeParamGoogleMaps(url);
136            url = supprimeCgisDansUrl(url, ['lieucgi']);
137        } else {
138            url = getUrlAvecLstParamsGoogleMaps(url);
139        }
140
141        if (cgi === 'order_by') {
142            var ordre = $(this).find('option:selected').attr('data-ordre');
143            url = getUrlWithLstParam(url, 'order_by_tri', ordre);
144        }
145        
146        if($(this).hasClass('moteur_selectEnregistreCritere')){
147            setCookieEnregistreCritere(cgi,value)
148        }
149        if($(this).hasClass('moteur_selectLieuEnregistreCritere')){
150            setCookieEnregistreCritere(cgi,value)
151        }
152        
153        if (estMoteurSansLien()) {
154            refreshListeWithCgi(url + '&' + $('#itea_page_contentListe').attr('data-cgi'));
155        } else {
156            document.location.href = url;
157            moteur_affMessageLoadingMoteur();
158        }
159    });
160}
161
162function supprimeCgisDansUrl(url, tabCgisASupprimer) {
163    // on recup la partie avant et après le ?
164    var urlSeule = url.substring(0, url.indexOf("?"));
165    var cgi = url.substring(url.indexOf("?") + 1, url.length);
166
167    // j'ai un tableau de retour pour ne pas perturber l'ordre du for
168    var tabCgi = cgi.split('&');
169    var tabCgiRetour = [];
170
171    for (var i = 0; i < tabCgi.length; i++) {
172        var infosCgi = tabCgi[i].split('=');
173        // si la clé du cgi n'est pas trouvé avec le indexOf, on garde le cgi
174        if (tabCgisASupprimer.indexOf(infosCgi[0]) === -1) {
175            tabCgiRetour.push(tabCgi[i]);
176        }
177    }
178    return urlSeule + '?' + tabCgiRetour.join('&');
179}
180
181function setCookieEnregistreCritere(cgi,value){
182    var date = new OBJDate();
183    date.ajoutJour(30);
184    var dateExpire = new Date(date.getAnnee(),date.getMois() - 1, date.getJour());
185    var cookie = "critereEnregistre_"+cgi;
186    setCookie(cookie.toUpperCase(),value.toUpperCase(),dateExpire);
187}
188
189function setCookie(name, value, expires, path, domain, secure) {
190    document.cookie = name + '=' + escape(value) +
191            ((expires) ? '; expires=' + expires.toGMTString() : '') +
192            ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
193}
194
195function init_moteur_imitecheckbox() {
196    /***** Permet d'afficher "Loading" et masque sur la page, quand clic sur un lien simulant un checkbox *****/
197    $(".moteur_imitecheckbox, .moteur_ulSimuleListe a").click(function(){
198        moteur_affMessageLoadingMoteur();
199    });
200}
201
202function init_moteur_imiteCheckBoxPasLien() {
203    /***** Les liens qui ne sont pas des liens, au click, on change la classe *****/
204    // on a déja prévu une action quand c'est une date
205    $('.moteur_imiteCheckBoxPasLien:not(#moteur_imiteCheckBoxPasDate)').click(function(){
206        $(this).toggleClass('moteur_imitecheckbox_off');
207        $(this).toggleClass('moteur_imitecheckbox_on');
208    });
209    
210}
211
212function init_moteur_imiteCheckBoxPasLienX() {
213    /** les liens qui ne sont pas des liens et qui permettent la recherche du type - on modifie le input hidden associé **/
214    $('.moteur_imiteCheckBoxPasLienType, .moteur_imiteCheckBoxPasLienChangeValue').click(function(){
215        var inputHidden = $('#' + $(this).attr('data-alt'));
216        var valueok = $(this).attr('data-valueok');
217        if(!valueok) {
218            valueok = 'o';
219        }
220        if (inputHidden.val() == valueok){
221            inputHidden.val('n');
222            $(this).find('.sp_nbResult[data-cgi="' + inputHidden.attr('name') + '"]').attr('data-valeur', 'n');
223        } else{
224            inputHidden.val(valueok);
225            $(this).find('.sp_nbResult[data-cgi="' + inputHidden.attr('name') + '"]').attr('data-valeur', valueok);
226        }
227        inputHidden.change();
228    });	
229}
230
231function initClicBody() {
232    var zone = "init";//init: on initialise OU on est dans la div
233    var detectTap = false;
234    $(document).on('touchstart', function () {
235        detectTap = true; //detects all touch events
236    });
237    $(document).on('touchmove', function () {
238        detectTap = false; //Excludes the scroll events from touch events
239    });
240
241    $(".ITEA_clicOutBody").each(function () {
242        $(this).click(function () {
243            zone = "init";
244        });
245        $(this).bind("touchend", function () {
246            zone = "init";
247        });
248    });
249
250    $("body").click(function () {
251        if (zone != "init") {
252            $(".ITEA_clicOutBody").each(function () {
253                if ($(this).is(":visible")) {
254                    $(this).css("display", "none").removeClass("open");
255                    zone = "init";
256                }
257            });
258        }
259        else {
260            zone = "out";
261        }
262    });
263
264    $("body").bind("touchend", function () {
265        if (detectTap) {
266            if (zone != "init") {
267                $(".ITEA_clicOutBody").each(function () {
268                    if ($(this).is(":visible")) {
269                        $(this).css("display", "none").removeClass("open");
270                        $("input:focus").blur();
271                        zone = "init";
272                    }
273                });
274            }
275            else {
276                zone = "out";
277            }
278        }
279    });
280    // Mettre sur l'élément qui permet d'afficher la div masqué au départ un e.stopPropagation();
281    // exemple dans cptGDF_initActionsDetailResas()
282    $('.onClickOutHideBlind').each(function () {
283        $(this).onclickout(function () {
284            if ($(this).is(":visible")) {
285                $(this).hide("blind")
286            }
287        });
288    });
289}
290
291function checkForm(frm,funcQdFini,funcQdEchec){
292    var tabChkInput = getTabChmpForm($(frm));
293    var id = ''; var validate; var mode;
294    var tabAValider = [];
295    console.log(frm.length);
296    
297    for(var i = 0; i < $(tabChkInput).length; i++){
298        id = $(tabChkInput[i]).attr('id');
299        if ($(tabChkInput[i]).attr('modecheck')!=undefined) {
300            mode = $(tabChkInput[i]).attr('modecheck');
301            validate = new LiveValidation(id, {validMessage: "Ok", onlyOnSubmit: true});
302            if (mode=='checkChpObligatoire') {
303                validate.add(Validate.Presence, {failureMessage: "Champ obligatoire"});
304            } else if (mode=='checkMailObligatoire') {
305                validate.add(Validate.Presence, {failureMessage: "Champ obligatoire"});
306                validate.add(Validate.Email, {failureMessage: "Adresse mail non valide"});
307            } else if (mode=='checkMail') {
308                validate.add(Validate.Email, {failureMessage: "Adresse mail non valide"});
309            } else if (mode=='checkChampInteger') {
310                validate.add(Validate.Numericality, {onlyInteger: true, notANumberMessage: "Code postal incorrect"});
311                validate.add(Validate.Length, {is: 5, wrongLengthMessage: "Code postal incorrect"});
312            } else if (mode=='checkChampDieseInterdit') {
313                validate.add(Validate.Format, {pattern: /#/, failureMessage: "Caractere # interdit"});
314            } else if (mode=='checkCaptcha') {
315                validate.add(Validate.Custom, {against: function(value, args
315){
316                    // TODO : à écrire
317                    var succes = true;
318                    var tabRep = $.ajax({
319                        url : 'lib_2/ajax/infosDist.php',
320                        data : {
321                            info : 'checkCodeSecu',
322                            val : value
323                        },
324                        async : false
325                    }).responseText;
326                    eval("var tabRetour="+tabRep);
327                    if (tabRetour.code.toUpperCase()=='ERR'){
328                        succes = false;
329                    }
330
331                    return succes;
332                }, failureMessage: "Verification non valide"});
333            }else if (mode=='checkChampTelephone') {
334                validate.add(Validate.Format, {pattern: /(^0[1-9][\s]?([0-9]{2}[\s]?){3}[0-9]{2}$|^00[0-9,\s]+[0-9]$)/, failureMessage: "Téléphone incorrect"});
335                validate.add(Validate.Length, {minimum: 6, tooShortMessage:  "Téléphone incorrect"});
336                validate.add(Validate.Length, {maximum: 20, tooLongMessage:  "Téléphone incorrect"});
337            } else {
338                debugLogJS('checkForm, cas non géré : '+mode);
339            }
340            tabAValider.push(validate);
341        }
342    }
343    
344    if (LiveValidation.massValidate(tabAValider)) {
345        funcQdFini();
346    } else if (funcQdEchec) {
347        funcQdEchec();
348    }
349}
350
351function getTabChmpForm(obj){
352	var childs=$(obj).children();
353	var tabOut=new Array();
354	var tabFils=new Array();
355	for (var i=0;i<$(childs).length;i++){
356		var child=childs[i];
357		if (	(child.tagName=="INPUT" && child.type=="text")
358			||  (child.tagName=="INPUT" && child.type=="checkbox")
359            ||  (child.tagName=="INPUT" && child.type=="email")
360            ||  (child.tagName=="INPUT" && child.type=="tel")
361            ||  (child.tagName=="INPUT" && child.type=="date")
362            ||  (child.tagName=="INPUT" && child.type=="number")
363			||	(child.tagName=="TEXTAREA")	
364			||	(child.tagName=="SELECT")	
365		){
366			tabOut.push(child);	
367		}	
368		if ($(child).children().length>0 ){
369            tabFils = $.merge(tabFils,getTabChmpForm(child));
370		}
371	}
372	if (tabFils.length>0){
373        tabOut = $.merge(tabOut,tabFils);
374    }
375	return tabOut;
376}
377
378function envoiMailByAjaxByForm(nomIdForm, nomIdRetourMsg, transformFormulaire) {
379    //213658 remplacement de envoiMailByAjaxByForm qui utilisait la lib
380    if (!nomIdRetourMsg) {
381        nomIdRetourMsg = nomIdForm;
382    }
383    //remplacer le nom par envoiMailByAjaxByForm() une fois OK
384    var adr = '/lib_2/ajax/envoiMail.php';
385    var sending = 'typeMail=mailContact_DPT';//????
386    var form = document.getElementById(nomIdForm);
387    if ($('#' + nomIdForm).length > 0) {
388        //suprpimer les 'ok'
389        $('#' + nomIdForm).find('.LV_validation_message,.LV_valid').remove()
390        if ($('#' + nomIdForm + ' input[name=destinataire]').length > 0) {
391            sending += '&destinataire=' + $('#' + nomIdForm + ' input[name=destinataire]').val();
392            sending += '&email=' + $('#' + nomIdForm + ' input[name=mail]').val();
393        }
394        if ($('#' + nomIdForm + ' input[name=expediteur]').length > 0) {
395            sending += '&expediteur=' + $('#' + nomIdForm + ' input[name=expediteur]').val();
396        }
397        if ($('#' + nomIdForm + ' input[name=sujet]').length > 0) {
398            sending += '&sujet=' + $('#' + nomIdForm + ' input[name=sujet]').val();
399            sending += '&typeDemande=' + $('#' + nomIdForm + ' input[name=sujet]').val();
400        }
401        if ($('#' + nomIdForm + ' input[name=enteteMessage]').length > 0) {
402            sending += '&enteteMessage=' + $('#' + nomIdForm + ' input[name=enteteMessage]').val();
403        }
404        if ($('#' + nomIdForm + ' input[name=numeroResa]').length > 0) {
405            sending += '&numeroResa=' + $('#' + nomIdForm + ' input[name=numeroResa]').val();
406        }
407        if ($('#' + nomIdForm + ' input[name=piedMessage]').length > 0) {
408            sending += '&piedMessage=' + $('#' + nomIdForm + ' input[name=piedMessage]').val();
409        }
410        if ($('#' + nomIdForm + ' input[name=msgEnvoiOK]').length > 0) {
411            sending += '&msgEnvoiOK=' + $('#' + nomIdForm + ' input[name=msgEnvoiOK]').val();
412        }
413        if ($('#' + nomIdForm + ' input[name=msgEnvoiKO]').length > 0) {
414            sending += '&msgEnvoiKO=' + $('#' + nomIdForm + ' input[name=msgEnvoiKO]').val();
415        }
416        if ($('#' + nomIdForm + ' input[name=gestionBR]').length > 0) {
417            sending += '&gestionBR=1'
418        }
419        if ($('#' + nomIdForm + ' input[name=telephone]').length > 0) {
420            sending += '&telephone=' + $('#' + nomIdForm + ' input[name=telephone]').val();
421        }
422        if ($('#' + nomIdForm + ' input[name=siteSource]').length > 0) {
423            sending += '&siteSource=' + $('#' + nomIdForm + ' input[name=siteSource]').val();
424        }
425        sending += "&urlCurr=" + document.location;
426        if (transformFormulaire) {
427            message = getHtmlMessageFromForm(form);
428            sending += '&gestionBR=1';
429        } else {
430            if (form.message) {
431                message = form.message.value;
432            }
433            if (form.messages) {
434                for (var i = 0; i < form.messages.length; i++) {
435                    message += form.messages[i].value;
436                }
437            }
438        }
439        sending += "&message=" + message;
440        var msgOK = $('#' + nomIdForm + ' input[name=msgEnvoiOK]').val();
441        var msgKO = $('#' + nomIdForm + ' input[name=msgEnvoiKO]').val();
442        $('#' + nomIdRetourMsg).html("<div id='divMsgEnvoiRetour'></div>");
443
444        var xhr_local = creeObjHttpRequest();
445        xhr_local.onreadystatechange = function () {
446            if (xhr_local.readyState == 4 && xhr_local.status == 200) {
447                var reponse = xhr_local.responseText;
448                if (reponse == 'OK') {
449                    $('#' + nomIdRetourMsg).addClass("messageAffiche").find('#divMsgEnvoiRetour').html(msgOK)
450                } else {
451                    $('#' + nomIdRetourMsg).addClass("messageAffiche messageErreur").find('#divMsgEnvoiRetour').html(msgKO)
452                }
453                if ($('#' + nomIdRetourMsg).length > 0) {
454                    $.scrollTo($('#' + nomIdRetourMsg), 500, {offset: -100});
455                }
456                $('#' + nomIdForm + ' *').attr("disabled", "disabled");
457            }
458        }
459
460        xhr_local.open("POST", adr, true);
461        xhr_local.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
462        xhr_local.send(sending);
463    }
464}
465
466function getHtmlMessageFromForm(formToTransform) {
467    var form = formToTransform.cloneNode(true);
468    form = transformChmpFormToSpan(form);
469    return form.innerHTML;
470}
471
472function transformChmpFormToSpan(obj){
473	var childs=obj.childNodes;
474	
475	for (var i=0;i<childs.length;i++){
476		var child=childs[i];
477		var id;
478				
479		if (	(child.tagName=='INPUT' && (child.type=='text' || child.type=='number' || child.type=='tel'))
480			||	(child.tagName=='TEXTAREA')	
481		){
482			var valeur="";
483			if (child.tagName=="TEXTAREA"){
484				var idObj=child.id;
485				valeur=$(idObj).value;
486				if (!valeur)valeur=child.innerHTML;
487				if (!valeur)valeur=child.value;
488			}else valeur=child.value;
489			var newElem=document.createElement("SPAN");
490			newElem.innerHTML="<strong>"+valeur+"</strong>";
491			obj.replaceChild(newElem,child);
492		}	
493		
494		if (child.tagName=="INPUT" && (child.type=="checkbox" || child.type=="radio")){
495			if (child.checked || $(child).checked || (child.id && $(child.id).checked))child.setAttribute("checked","checked");
496			//else obj.removeChild(child); //Fiche 143367
497		}
498		
499		if (child.tagName=="SELECT"){
500			if (child.id){
501				var newElem=document.createElement("SPAN");
502				newElem.innerHTML="<strong>"+$(child.id).options[$(child.id).selectedIndex].value+"</strong>";
503				obj.replaceChild(newElem,child);
504			}else obj.removeChild(child);
505		}
506		
507		if ( child.childNodes.length>0 )child=transformChmpFormToSpan(child)
508	}
509	return obj;
510}
511
512function creeObjHttpRequest(){
513	var xhr_local=null;
514	if(window.XMLHttpRequest) // Firefox et autres
515   		xhr_local = new XMLHttpRequest();
516	else if(window.ActiveXObject){ // Internet Explorer
517	   try {
518			xhr_local = new ActiveXObject("Msxml2.XMLHTTP");
519		}catch(e){
520			xhr_local = new ActiveXObject("Microsoft.XMLHTTP");
521		}
522	}
523	return xhr_local;
524}
525
526function initAlerteGeneral(){
527    if($('#div_massageAlerteGeneral').length > 0){
528        if(!getCookie('POPIN_MESSAGE_GENERAL')){            
529            $('#div_massageAlerteGeneral').dialog({
530                maxWidth: 650,
531                modal: true,
532                width: 600
533            });                
534            if(!estModeAdmin()){
535                setCookie('POPIN_MESSAGE_GENERAL','ouvert');
536            }
537        }
538    }
539}
540
541function estModeAdmin(){
542    if($('.div_adminV5modificationPage').length>0){
543        return true;
544    }
545    return false;
546}
547
548function is_array(input) {
549    return (typeof (input) == 'object' && (input instanceof Array));
550}
551
552function array_push(array, vars) {
553    if (!is_array(array))
554        array = new Array();
555    var length = array.length;
556    array[length] = vars;
557    return array;
558}
559
560function addValidateOnLiveValidationEmail(objLiveValidation, langue, obligatoire, failureMessage, info, domaine) {
561    if (obligatoire === undefined) {
562        obligatoire = false;
563    }
564    var message_obligatoire;
565    var message_email_invalide;
566    if (langue === 'FRANCAIS') {
567        message_obligatoire = 'Champ obligatoire';
568        message_email_invalide = 'Adresse mail non valide';
569    } else {
570        message_obligatoire = 'Required field';
571        message_email_invalide = 'Invalid email';
572    }
573    if(failureMessage !== undefined && failureMessage.length > 0){
574        message_obligatoire = failureMessage;
575        message_email_invalide = failureMessage;
576    }
577    if (obligatoire) {
578        objLiveValidation.add(Validate.Presence, {failureMessage: message_obligatoire});
579    }
580    var args = {};
581    if(info) {
582        args.info = info;
583    }
584    if(domaine) {
585        args.domaine = domaine;
586    }
587    objLiveValidation.add(Validate.Email, {failureMessage: message_email_invalide});
588    objLiveValidation.add(Validate.Custom, {
589        against: function (value, args) {
590            return checkEmailIteaPourValidate(value, args);
591        },
592        args:args,
593        failureMessage: message_email_invalide
594    });
595}
596
597function checkEmailIteaPourValidate(value, args) {
598    var check = true;
599    var info = args.info || 'checkEmail';
600    var domaine = args.domaine || '';
601    var request = $.ajax({
602        type: 'POST',
603        url: domaine + '/lib_2/ajax/infosDist.php',
604        async: false,
605        dataType : 'json',
606        data: {info: info, val: value}});
607    request.success(function (retour) {
608        if (retour.code !== 'OK') {
609            check = false;
610        }
611    });
612    request.error(function (xhr, status, thrown) {
613        console.log('checkEmailIteaPourValidatevalue appel ajax impossible');
614        //242059: si pas d'appel on renvoi true, ca evite de bloquer
615        check = true;
616    });
617    return check;
618}
619
620function traiteRetourVerifCaptcha(retour) {
621    try {
622        if (retour.code == 'OK' || retour.code == 'Ok') {
623            return true;
624        }
625        if (retour.reload) {
626            $('#sp_btnReload').trigger('click');
627        }
628    }
629    catch (e) {
630        // problème : on va renvoyer false
631    }
632    return false;
633}
634
635function getInfosClientPourMiniCata() {
636    var tabInfos = {};
637    tabInfos.civilite = $('#div_saisieInfosClientPourMiniCata select.civilite').val();
638    tabInfos.nom = $('#div_saisieInfosClientPourMiniCata input.nom').val();
639    tabInfos.mdp = $('#div_saisieInfosClientPourMiniCata input.mdp').val();
640    tabInfos.prenom = $('#div_saisieInfosClientPourMiniCata input.prenom').val();
641    tabInfos.adresse1 = $('#div_saisieInfosClientPourMiniCata input.adresse1').val();
642    tabInfos.adresse2 = $('#div_saisieInfosClientPourMiniCata input.adresse2').val();
643    tabInfos.code_postal = $('#div_saisieInfosClientPourMiniCata input.cp').val();
644    tabInfos.ville = $('#div_saisieInfosClientPourMiniCata input.ville').val();
645    tabInfos.pays = $('#div_saisieInfosClientPourMiniCata input.pays').val();
646    tabInfos.tel1 = $('#div_saisieInfosClientPourMiniCata input.teldom').val();
647    tabInfos.tel2 = $('#div_saisieInfosClientPourMiniCata input.telbur').val();
648    return tabInfos;
649}
650
651function afficheDivAvecTransparence(html,w,h,suffixe='',titreDiv){
652    var hW=getHauteurWindow();
653    var lW=getLargeurWindow();
654    if(hW<40) hW=40;
655    if(lW<40) lW=40;
656    if (h>hW)h=hW-40;
657    if (w>lW)w=lW-40;
658
659    if ($('#divGraph_affFenetre'+suffixe).length == 0) {
660        getNewDivToBody('divGraph_affFenetre'+suffixe,'divGraph'+suffixe);
661    }
662    var divGene = $('#divGraph_affFenetre'+suffixe);
663    divGene.css('position','fixed');
664    divGene.css('zIndex','900000');
665    divGene.css('left','0px');
666    divGene.css('top','0px');
667    divGene.css('width','100%');
668    divGene.css('height','100%');
669    divGene.css('opacity','0.2');
670    divGene.css('backgroundColor','#000000');
671    divGene.css('display','block');
672
673    if ($('#divGraph_fermeFenetre'+suffixe).length == 0) {
674        getNewDivToBody("divGraph_fermeFenetre"+suffixe,"divGraphFerme"+suffixe);
675    }
676    var divFerme = $('#divGraph_fermeFenetre'+suffixe);
677    divFerme.css('position','fixed');
678    divFerme.css('zIndex','900001');
679    divFerme.css('right','10px');
680    divFerme.css('top','10px');
681    divFerme.css('display','block');
682    divFerme.html('<div class="divGraph_fermeFenetreContent" onclick="effaceDivAvecTransparence();"><a href="javascript:void(0);" style="text-decoration:none;"></a></div>');
683
684    
685    if ($('#divGraph_fenetre'+suffixe).length == 0) {
686        getNewDivToBody('divGraph_fenetre'+suffixe,'divGraph'+suffixe);
687    }
688    var divMsg = $('#divGraph_fenetre'+suffixe);
689    divMsg.css('position','fixed');
690    divMsg.css('zIndex','1000000');
691    divMsg.css('backgroundColor','#FFFFFF');
692    divMsg.css('width',w+'px');
693    divMsg.css('height',h+'px');
694    divMsg.css('opacity','1');
695    divMsg.css('marginLeft','-'+(w/2)+'px');
696    divMsg.css('top','50%');
697    divMsg.css('left','50%');
698    divMsg.css('marginTop','-'+(h/2)+'px');
699    divMsg.css('display','block');
700
701    if(titreDiv) {
702        html = "<div id='div_btnCloseFrmResa' class='div_headPopin'><p><span class='sp_titrePopin'>" + titreDiv + "</span><a href='#ferme' onClick='effaceDivAvecTransparence();' class='a_fermePopin' title='fermer'><img src='/config_v3/imgs_defaut/v5/fermer-popin.gif' alt='fermer'/></a></p></div>" + html;
703    }
704
705    divMsg.html(html);
706
707    if (window.Effect) {
708        new Effect.Opacity(
709            divGene, {
710                from: 0.2, to: 0.7
711            }
712        );
713    }
714
715    //gestion de la pression d'une touche d'échapement (ESCAP)
716    $(document).off('keyup');
717    $(document).on('keyup', function(event){
718        if(event.keyCode == 27){
719            effaceDivAvecTransparence(suffixe);
720            $(document).off('keyup');
721        }
722    });
723}
724
725function getLargeurWindow(){
726	return parseInt(window.innerWidth);
727}
728
729function getHauteurWindow(){
730	return parseInt(window.innerHeight);
731}
732
733function getNewDivToBody(ident,classe){
734	return getNewDivChild($('body'),ident,classe);
735}
736
737function effaceDivAvecTransparence(suffixe=''){
738	$('#divGraph_affFenetre'+suffixe).hide();
739	$('#divGraph_fenetre'+suffixe).hide();
740    $('#divGraph_fermeFenetre'+suffixe).hide();
741}
742
743function appelAjaxXMLToFunc(url,query_string,foncQdFini){
744	var xhr_local=creeObjHttpRequest();
745	xhr_local.onreadystatechange = function(){
746		if(xhr_local.readyState == 4 && xhr_local.status == 200){
747			var contenu=clean(xhr_local.responseXML.documentElement);
748			if (foncQdFini)foncQdFini(contenu);
749		}
750	}
751	xhr_local.open("POST",url,true);
752	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
753	xhr_local.send(query_string);
754}
755
756function clean(d){
757	var bal=d.getElementsByTagName("*");
758	for(i=0;i<bal.length;i++){
759		a=bal[i].previousSibling;
760		if(a && a.nodeType==3) {
761            go(a);
762        }
763		b=bal[i].nextSibling;
764		if(b && b.nodeType==3) {
765            go(b);
766        }
767	}
768	return d;
769}
770
771function go(c){
772	if(!c.data.replace(/\s/g,"")) {
773        c.parentNode.removeChild(c);
774    }		
775}
776
777function initPageStorage(tabJson) {
778    if (tabJson) {
779        var value;
780        var body = $('body')[0];
781        for (var key in tabJson) {
782            value = tabJson[key];
783            $.data(body, key, value)
784        }
785    }
786}
787
788function XMLToArray(xmlDoc, numericalKeyName) {
789    var nameNumeric = numericalKeyName || 'item';
790    var thisArray = new Array();
791    if ($(xmlDoc).children().length > 0) {
792        $(xmlDoc).children().each(function () {
793            var nameOfTheNode = this.nodeName;
794            if (this.nodeName == nameNumeric) {
795                nameOfTheNode = $(this).attr('tag');
796            }
797            if ($(this).children().length > 0) {
798                var NextNode = $(this);
799                thisArray[nameOfTheNode] = XMLToArray(NextNode, nameNumeric);
800            } else {
801                thisArray[nameOfTheNode] = $(this).text();
802            }
803        });
804    }
805    // on teste si le premier enregistrement est la balise root du fichier xml, dans ce cas on renvoie cette balise
806    if (thisArray['ROOT'] != undefined) {
807        return thisArray['ROOT'];
808    }
809    return thisArray;
810}
811
812function autocompleteurCpVille(inputCp, inputVille, domaine) {
813    // permet de mettre en place un autocompleteur sur le code postal permettant de remplir le code postal et la ville
814    var nomDomaine = domaine || '';
815    $(inputCp).autocomplete({
816        source: function (request, response) {
817            var params = {
818                url: nomDomaine + '/lib_2/ajax/infosDist.php',
819                dataType: "json",
820                type: 'POST',
821                data: {
822                    cp: request.term,
823                    info: 'getVilleByCP',
824                    allfields: '1',
825                    like: 1,
826                    limit: 46
827                },
828                success: function (data) {
829                    response($.map(data, function (item) {
830                        var commune = item.commune;
831                        commune = commune.trim();
832                        return {
833                            label: item.code_postal + ", " + item.commune,
834                            value: commune,
835                            code: item.code_postal
836                        };
837                    }));
838                }
839            };
840            if (nomDomaine) {
841                params.dataType = 'jsonp';
842            }
843            $.ajax(params);
844        },
845        minLength: 2,
846        select: function (event, ui) {
847            event.preventDefault();
848            var val = ui.item.value;
849            $(inputVille).val(val);
850            $(inputCp).val(ui.item.code);
851        },
852        open: function () {
853            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
854        },
855        close: function () {
856            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
857        }
858    });
859}
860
861function initChangementMotDePassePV() {
862    $('.btnChangeMDPPV').click(function () {
863        $.ajax({
864            url: '/lib_2/ajax/contenuFenetre.php',
865            type: 'POST',
866            dataType: 'xml',
867            data: 'element=pv&typeInfo=displayChangePass',
868            success: function (data) {
869                var xml = XMLToArray(data);
870                var html = xml.html;
871                var titre = xml.titre;
872                var textAnnuler = xml.annuler;
873                $('<div id="popinPV">').dialog({
874                    height: 300,
875                    width: 730,
876                    buttons: [{
877                            text: "Ok", click: function () {
878                                $('#popinPV form').submit();
879                            }},
880                        {
881                            text: textAnnuler, click: function () {
882                                $(this).dialog('close');
883                                $('#popinPV').remove();
884                            }
885                        }
886                    ],
887                    title: titre
888                }).html(html);
889                var fonctionValid = function () {
890                    var vars = $('#formChangementPassPV').serialize();
891                    $('#popinPV .erreurChangementMDPPV').remove();
892                    $('#qtipPV').remove();
893                    $.ajax({
894                        url: '/lib_2/ajax/contenuFenetre.php',
895                        type: 'POST',
896                        dataType: 'xml',
897                        data: 'element=pv&typeInfo=changePass&' + vars,
898                        success: function (data) {
899                            var xml = XMLToArray(data);
900                            if (xml.code == 'OK') {
901                                $('#popinPV').dialog('destroy');
902                                $('#popinPV').remove();
903
904                                $('#changePassCE').qtip({content: {
905                                        text: xml.message // Use each elements title attribute
906                                    },
907                                    style: {
908                                        classes: 'jgrowl ui-tooltip-blue ui-tooltip-rounded' // Some nice visual classes
909                                    },
910                                    position: {
911                                        my: 'top right'
912                                    },
913                                    show: {
914                                        event: false, // Don't show it on a regular event
915                                        ready: true, // Show it when ready (rendered)
916                                        effect: function () {
917                                            $(this).stop(0, 1).fadeIn(400);
918                                        }, // Matches the hide effect
919                                        delay: 0 // Needed to prevent positioning issues
920                                    },
921                                    hide: {
922                                        effect: function () {
923                                            $(this).slideUp();
924                                        }
925                                    }
926                                });
927                                setTimeout(function () {
928                                    $('#changePassCE').qtip('hide');
929                                }, 3000);
930                            }
931                            else {
932                                $('#popinPV').append('<p class="erreurChangementMDPPV" style="display:none;"><span class="ui-icon ui-icon-alert"></span>&nbsp;<span>' + xml.message + '</span></p>');
933                                $('.erreurChangementMDPPV').slideDown('fast');
934                            }
935                        }
936                    });
937                };
938                initValidationFormulaires(fonctionValid, function () {
939
940                });
941            }
942        });
943    });
944}
945
946function initValidationFormulaires(fonctionSiOk, fonctionSiErr){
947    //initialisation du validator
948    $.validator.setDefaults({
949        debug : false
950    });
951
952    //Personnalisation des messages d'erreur
953    $.extend($.validator.messages, {
954        required: $('#inpt_validate_obligatoire').val(),
955        email: $('#inpt_validate_verifMail').val(),
956        url: $('#inpt_validate_verifUrl').val(),
957        date: $('#inpt_validate_verifDate').val(),
958        number: $('#inpt_validate_verifNombre').val(),
959        telephone: $('#inpt_validate_verifTel').val(),
960        equalTo: $('#inpt_validate_verifEgalA').val(),
961        egalA: $('#inpt_validate_verifEgalA').val(),
962        listeDefautInterdit: $('#inpt_validate_listeDefautInterdit').val(),
963        captcha: $('#inpt_validate_verifCaptcha').val(),
964        maxlength: $.validator.format("Taille maxi : {0} caractères."),
965        minlength: $.validator.format("Taille mini : {0} caractères.")
966    });
967
968    //Création de méthodes spécifiques
969    $.validator.addMethod(
970            "telephone", 
971        function(value, element){
972            return this.optional(element) || (value.length == 10 && !isNaN(value));
973        }
974    );
975
976    $.validator.addMethod(
977            "listeDefautInterdit", 
978        function(value, element){
979            if ($(element).is('select')) {
980                var defaut = $(element).children(':first').val();
981
982                return value!==defaut;
983            } else {
984                return true;
985            }
986        }
987    );
988
989    $.validator.addMethod(
990            "egalA", 
991        function(value, element){
992            var elemComparaison = $(element).attr('data-egalA');
993            if($('#'+elemComparaison).length >0){
994                return ($('#'+elemComparaison).val() == value);
995            }
996        }
997    );
998
999    $.validator.addMethod(
1000            "captcha", 
1001        function(value, element){
1002            var succes = true;
1003            var tabRep = $.ajax({
1004                url : 'lib_2/ajax/infosDist.php',
1005                data : {
1006                    info : 'checkCodeSecu',
1007                    val : value
1008                },
1009                async : false
1010            }).responseText;
1011            eval("var tabRetour="+tabRep);
1012            if (tabRetour.code.toUpperCase()=='ERR'){
1013                succes = false;
1014            }
1015
1016            return succes;
1017        }
1018    );
1019
1020    //Personnalisation des classes de validation à ajouter dans le HTML
1021    $.validator.addClassRules({
1022        obligatoire:{
1023            required: true 
1024        },
1025        verifNom:{
1026            maxlength:50,
1027            number : false
1028        },
1029        verifMail:{
1030            email: true
1031        }, 
1032        verifTel : {
1033            telephone: true
1034        },      
1035        verifUrl:{
1036            url:true
1037        },
1038        verifCP:{
1039            number: true,
1040            minlength: 5,
1041            maxlength: 5
1042        },
1043        verifCaptcha:{
1044            captcha: true
1045        },
1046        listeDefautInterdit:{
1047            listeDefautInterdit: true
1048        }
1049    });
1050
1051    $('form.form_validate').each(function(){                
1052        $(this).validate({
1053            onkeyup: false,
1054            errorPlacement: function(error, element) {
1055                $(element).siblings('.LV_validation_message').remove();
1056                var spanError = '<span class="LV_validation_message LV_invalid">'+error.html()+'</span>';
1057                $(element).after(spanError);
1058            },
1059            success: function(error, element) {
1060                var msgOk = $('#inpt_validate_OK').val();
1061                $(element).siblings('.LV_validation_message').remove();
1062                var spanOk = '<span class="LV_validation_message LV_valid">'+msgOk+'</span>';
1063                $(element).after(spanOk);
1064            },
1065            submitHandler: function(){
1066                $(this).find('submit').hide();
1067                if(typeof(fonctionSiErr) == 'function'){
1068                    fonctionSiOk();
1069                }
1070            },
1071            invalidHandler: function(){
1072                if(typeof(fonctionSiErr) == 'function'){
1073                    fonctionSiErr();
1074                }
1075            }
1076        });
1077    });
1078}
1079
1080function debugLogJS(nomFonction) {
1081    // Fonction permettant de faire un debugLog en PHP grâce à un appel AJAX <br />
1082    // Attention à ne pas utiliser cette fonction dans une boucle ou sur un évènement souvent appelé
1083    $.ajax({
1084        url: '/lib_2/ajax/infosDist.php',
1085        type: 'POST',
1086        data: {
1087            'info': 'debugLogJS',
1088            'nomFonction': nomFonction
1089        }
1090    });
1091}
1092
1093function errLogJS(nomFonction, infosJS) {
1094    // Fonction permettant de faire un debugLog en PHP grâce à un appel AJAX <br />
1095    // Attention à ne pas utiliser cette fonction dans une boucle ou sur un évènement souvent appelé
1096    $.ajax({
1097        url: '/lib_2/ajax/infosDist.php',
1098        type: 'POST',
1099        data: {
1100            'info': 'errLogJS',
1101            'nomFonction': nomFonction,
1102            infosJS: infosJS
1103        }
1104    });
1105}
1106
1107function errlog(log) {
1108    console.log('errlog log:', log);
1109    $.ajax({
1110        url: '/lib_2/ajax/infosDist.php',
1111        type: 'POST',
1112        data: {
1113            'info': 'errlog',
1114            'log': log,
1115        }
1116    });
1117}
1118
1119function initFicheVisitee(ref) {
1120    var data = 'action=ADD_FICHE_VISITEE';
1121    data += '&ref=' + ref;
1122    $.ajax({
1123        type: 'POST',
1124        url: urlCptClient,
1125        data: data
1126    });
1127}
1128
1129function getVarsFromUrl() {
1130    var out = {};
1131    var params = location.search.substring(1).split('&');
1132    $(params).each(function (val) {
1133        var tab = this.split('=');
1134        out[tab[0]] = tab[1];
1135    });
1136    return out;
1137}
1138
1139function getEcartAnneeEntreObjsDates(dateRecente, DateAncienne) {
1140    var ynew = dateRecente.getFullYear();
1141    var mnew = dateRecente.getMonth();
1142    var dnew = dateRecente.getDate();
1143    var yold = DateAncienne.getFullYear();
1144    var mold = DateAncienne.getMonth();
1145    var dold = DateAncienne.getDate();
1146    var diff = ynew - yold;
1147    if (mold > mnew) {
1148        diff--;
1149    } else {
1150        if (mold == mnew) {
1151            if (dold > dnew) {
1152                diff--;
1153            }   
1154        }
1155    }
1156    return diff;
1157}
1158
1159function estSurBureauITEA() {
1160    // fichier appelé uniquement sur les sites web
1161    return false;
1162}
1163
1164function estSurBureauProprietaire() {
1165    // fichier appelé uniquement sur les sites web
1166    return false;
1167}
1168
1169function estSurBureauPropOuITEA(){
1170    return (estSurBureauITEA() || estSurBureauProprietaire());
1171}
1172
1173function estSurResa() {
1174    // fichier appelé uniquement sur les sites web
1175    return false;
1176}
1177
1178function yaDateAGererBureauITEA() {
1179    if (!estSurBureauITEA()) {
1180        return false;
1181    }
1182    return false;
1183}
1184
1185function yaInseeAGererBureauITEA() {
1186    if (!estSurBureauITEA()) {
1187        return false;
1188    }
1189    return false;
1190}
1191
1192function fillInfosClientMiniCata(element) {
1193    var civilite = $(element).attr('data-civilite');
1194    var nom = $(element).attr('data-nom');
1195    var prenom = $(element).attr('data-prenom');
1196    var adresse1 = $(element).attr('data-adresse1');
1197    var adresse2 = $(element).attr('data-adresse2');
1198    var cp = $(element).attr('data-cp');
1199    var ville = $(element).attr('data-ville');
1200    var pays = $(element).attr('data-pays');
1201    var teldom = $(element).attr('data-teldom');
1202    var telbur = $(element).attr('data-telbur');
1203    $('.civilite').val(decodeURIComponent(civilite.replace(/\+/g, ' ')));
1204    $('.nom').val(decodeURIComponent(nom.replace(/\+/g, ' ')));
1205    $('.prenom').val(decodeURIComponent(prenom.replace(/\+/g, ' ')));
1206    $('.adresse1').val(decodeURIComponent(adresse1.replace(/\+/g, ' ')));
1207    $('.adresse2').val(decodeURIComponent(adresse2.replace(/\+/g, ' ')));
1208    $('.cp').val(decodeURIComponent(cp.replace(/\+/g, ' ')));
1209    $('.ville').val(decodeURIComponent(ville.replace(/\+/g, ' ')));
1210    $('.pays').val(decodeURIComponent(pays.replace(/\+/g, ' ')));
1211    $('.teldom').val(decodeURIComponent(teldom.replace(/\+/g, ' ')));
1212    $('.telbur').val(decodeURIComponent(telbur.replace(/\+/g, ' ')));
1213}
1214
1215function setInfosClientMiniCataPourPrint() {
1216    var civilite = $('#div_saisieInfosClientPourMiniCata .civilite').val();
1217    var nom = $('#div_saisieInfosClientPourMiniCata .nom').val() || "";
1218    var prenom = $('#div_saisieInfosClientPourMiniCata .prenom').val() || "";
1219    var adresse1 = $('#div_saisieInfosClientPourMiniCata .adresse1').val() || "";
1220    var adresse2 = $('#div_saisieInfosClientPourMiniCata .adresse2').val() || "";
1221    var cp = $('#div_saisieInfosClientPourMiniCata .cp').val() || "";
1222    var ville = $('#div_saisieInfosClientPourMiniCata .ville').val() || "";
1223    var pays = $('#div_saisieInfosClientPourMiniCata .pays').val() || "";
1224    var teldom = $('#div_saisieInfosClientPourMiniCata .teldom').val() || "";
1225    var telbur = $('#div_saisieInfosClientPourMiniCata .telbur').val() || "";
1226
1227    $.ajax({
1228        url: '/lib_2/ajax/gerePanier.php',
1229        type: 'POST',
1230        data: {
1231            action: 'setObjClientPanierPourPrint',
1232            cv: civilite,
1233            nom: nom,
1234            prenom: prenom,
1235            adresse1: adresse1,
1236            adresse2: adresse2,
1237            cp: cp,
1238            ville: ville,
1239            pays: pays,
1240            teldom: teldom,
1241            telbur: telbur
1242        },
1243        beforeSend: function (xhr) {
1244            afficheLoaderGlobal_site();
1245        },
1246        success: function (data, textStatus, jqXHR) {
1247            effaceDivAvecTransparence();
1248            window.open('?TO_PDF=1', '_blank');
1249        },
1250        complete: function (jqXHR, textStatus) {
1251            effaceLoaderGlobal_site();
1252        }
1253    });
1254}
1255
1256function afficheLoaderGlobal_site(){
1257    if ($('#div_loaderUnload').length===0) {
1258        $('body').prepend('<div id="div_loaderUnload" style="display:none;"><div class="div_loaderCSS"></div></div>');
1259    }
1260    $('#div_loaderUnload').show();
1261}
1262
1263function effaceLoaderGlobal_site(){
1264    if ($('#div_loaderUnload').length===0) {
1265        $('body').prepend('<div id="div_loaderUnload" style="display:none;"><div class="div_loaderCSS"></div></div>');
1266    }
1267    $('#div_loaderUnload').hide();
1268}
1269
1270function initModalTaxeSejour(){
1271    if($('#div_popinTaxeSejourDetail').length > 0){
1272        $('#div_massageAlerteGeneral').dialog({
1273            modal: true,
1274            width: 800
1275        });
1276        $('.infoTaxeSejour').click(function(){
1277            $('#lienModalInfosTaxeSejour').click();
1278        });
1279        
1280        if ($('#lienModalInfosTaxeSejour') && $('#lienModalInfosTaxeSejour').attr('data-autoclick') && $('#lienModalInfosTaxeSejour').attr('data-autoclick').length > 0){
1281            $('#lienModalInfosTaxeSejour').click();
1282        }
1283    }
1284}
1285
1286function isNullOrUndefined(variable) {
1287    if (typeof variable === 'undefined' || variable === null) {
1288        return true;
1289    }
1290    return false;
1291}
1292
1293function isNullOrUndefinedOrEmpty(variable) {
1294    if (isNullOrUndefined(variable) || variable === '') {
1295        return true;
1296    }
1297    return false;
1298}
1299
1300function initAncienneVersionJQuery() {
1301    return;
1302}
1303
1304function switchPolitiqueConfidentialite(selecteurHtmlAToggle = '') {
1305    if (selecteurHtmlAToggle === undefined) {
1306        selecteurHtmlAToggle = '';
1307    }
1308    if(selecteurHtmlAToggle !== '') {
1309        $(selecteurHtmlAToggle).toggleClass('disabled');
1310    }
1311}
1312
1313function removeParamGoogleMaps(url) {
1314    // Enlève les paramètres de la carte google map d'une url (322629)
1315
1316    // on recup la partie avant et après le ?
1317    var urlSeule = url.substring(0, url.indexOf("?"));
1318    var cgi = url.substring(url.indexOf("?") + 1, url.length);
1319    
1320    // tab des CGI google map à enlever
1321    var tabCgiGM = ['zoom', 'centrex', 'centrey', 'minlat', 'maxlat', 'minlng', 'maxlng'];
1322    
1323    // j'ai un tableau de retour pour ne pas perturber l'ordre du for
1324    var tabCgi = cgi.split('&');
1325    var tabCgiRetour = [];
1326    
1327    for (var i = 0; i < tabCgi.length; i++) {
1328        var infosCgi = tabCgi[i].split('=');
1329        // si la clé du cgi n'est pas trouvé avec le indexOf, on garde le cgi
1330        if (tabCgiGM.indexOf(infosCgi[0]) === -1) {
1331            tabCgiRetour.push(tabCgi[i]);
1332        }
1333    }
1334    return urlSeule + '?' + tabCgiRetour.join('&');
1335}
1336
1337function lancementStat() {
1338    $("[class*='iteaStatMe_']").click(setStatToElement);
1339}
1340
1341function setStatToElement(elem) {
1342    elem = elem.currentTarget;
1343    var classes = $(elem).attr('class');
1344    var tabClass = classes.split(' ');
1345    var typeStat = '';
1346    for (var i = 0; i < tabClass.length; i++) {
1347        if (tabClass[i].substring(0, 11) == 'iteaStatMe_') {
1348            typeStat = tabClass[i].substring(11);
1349        }
1350    }
1351    var ident = $(elem).attr('data-ident');
1352    if (ident != undefined && ident.length > 0 && typeStat.length > 0) {
1353        trackMe(ident, typeStat, '1');
1354    }
1355}
1356
1357function trackMe(ident,idpage,nouvelleVersion){
1358	var adr="/lib_2/ajax/gereTracker.php";
1359	var sending=getInfoSession()+"&ident="+ident+"&idpage="+idpage+"&nouvelleVersion="+nouvelleVersion    
1360    $.ajax({type: "POST",url: adr,data: sending});    
1361}
1362
1363function getInfoSession(nomvar) {
1364    var vars = '';
1365    if (nomvar === undefined) {
1366        nomvar = 'PHPSESSID';
1367    }
1368    var sess = getQueryStringVal('PHPSESSID');
1369    tabSess = sess.split('#');
1370    sess = tabSess[0];
1371    if (!sess) {
1372        var body = document.getElementsByTagName('body')[0];
1373        if(typeof body === 'object'){
1374            sess = body.getAttribute('data-iditea')
1375        }
1376    }
1377    if (sess) {
1378        vars += '&' + nomvar + '=' + sess;
1379    }
1380    return vars;
1381
1382}
1383
1384function getQueryStringVal(lQuery) {
1385    var lDoc = String(document.location);
1386    var lSignet = "";
1387    var n1 = lDoc.indexOf("?");
1388    if (n1 > 0) {
1389        var n2 = lDoc.indexOf("?" + lQuery + "=", n1);
1390        if (n2 < n1)
1391            n2 = lDoc.indexOf("&" + lQuery + "=", n1);
1392        if (n2 >= n1) {
1393            n2 = n2 + ("?" + lQuery + "=").length;
1394            var n3 = lDoc.indexOf("&", n2 + 1);
1395            if (n3 > n2)
1396                lSignet = lDoc.substring(n2, n3);
1397            else
1398                lSignet = lDoc.substring(n2);
1399        }
1400    }
1401    return lSignet;
1402}
1403
1404function addEventGa(category,action,label){    
1405    var typeGa = $("#bodyPage").attr("data-ga-type");
1406    if(typeGa==''){
1407        return;
1408    }
1409    if(typeGa=="UA"){
1410        if (typeof ga == 'function'){
1411            ga('send','event',category,action,label);
1412        }            
1413    }
1414    else{
1415        var _gaq = _gaq || [];
1416        _gaq.push(['_trackEvent',category,action,label]);
1417    }
1418}
1419
1420function alertAMalibu(msg,foncQdFini){
1421	msg = unescape(msg);
1422	var html = "<div id='div_msgErr'>";
1423	html+= "<span id='span_msgErr'>"+msg+"</span>";
1424	html+= "<span id='span_btnRetour'>OK</span>";
1425	html+= "</div>";
1426
1427	afficheDivAvecTransparence(html,"250","100");
1428
1429	$("#div_msgErr").style.fontFamily = "Arial";
1430	$("#div_msgErr").style.fontSize = "11px";
1431	$("#div_msgErr").style.margin = "10px";
1432	$("#span_msgErr").style.display = "block";
1433	$("#span_msgErr").style.paddingBottom = "20px";
1434	$("#span_btnRetour").style.display = "block";
1435	$("#span_btnRetour").style.textAlign = "center";
1436	$("#span_btnRetour").style.fontWeight = "bold";
1437	$("#span_btnRetour").style.color = "white";
1438	$("#span_btnRetour").style.cursor = "pointer";
1439	$("#span_btnRetour").style.margin = "auto";
1440	$("#span_btnRetour").style.width = "42px";
1441	$("#span_btnRetour").style.lineHeight = "21px";
1442	$("#span_btnRetour").style.backgroundImage = "url(/config_v3/imgs_defaut/bt_ok.gif)";
1443	$("#span_btnRetour").style.backgroundRepeat = "no-repeat";
1444	$("#span_btnRetour").onclick=function (evt){
1445		effaceDivAvecTransparence();
1446		//if(window.foncQdFini)foncQdFini();
1447		if(foncQdFini)foncQdFini();
1448	}
1449}
1450
1451function alertAJquery(msg,foncQdFini){
1452    msg = unescape(msg);
1453    $("<div id='div_msgErr'>").html("<span id='span_msgErr'>"+msg+"</span>").dialog({
1454        modal:true,
1455        close:function(){
1456            if(foncQdFini){
1457                foncQdFini();
1458            }
1459        }
1460    });
1461}
1462
1463function affMsgAttenteInDiv(nomDiv){
1464	var elem=$('#'+nomDiv);
1465	if (elem){
1466		elem.innerHTML+="<div id=divChargement><table class='table_transparence' id=tabRechargement width=100%><tr><td align=center id=tdChargement><img id=imgRechargement style='margin:auto' width=16 height=16 src=/config_v3/imgs_defaut/loading/roue16x16.gif /></td></tr></table></div>";
1467		var divCharg=$("#divChargement");
1468
1469		divCharg.style.position="relative";
1470		divCharg.style.width=elem.offsetWidth+"px";
1471		divCharg.style.height=elem.offsetHeight+"px";
1472		//divCharg.style.top=elem.offsetTop+"px";
1473		//divCharg.style.left=elem.offsetLeft+"px";
1474		divCharg.style.top="0px";
1475		divCharg.style.left="0px";
1476
1477		if (elem.positionedOffset){
1478			var pos=elem.positionedOffset();
1479			divCharg.style.top=pos.top;
1480			divCharg.style.left=pos.left;
1481		}
1482		divCharg.style.opacity=0.6;
1483		divCharg.style.filter="alpha(opacity=60)";
1484		divCharg.style.KhtmlOpacity=0.6;
1485		divCharg.style.background="#FFFFFF";
1486	}
1487}
1488
1489function attenteInDiv(element,position){
1490	var position = position || 'relative';
1491	if ($(element).length>0){
1492        var width = $(element).outerWidth();
1493        var height = $(element).outerHeight();
1494		$(element).append("<div id='divChargement'><table class='table_transparence' id='tabRechargement'><tr><td align=center id=tdChargement><img id=imgRechargement style='margin:auto' width=16 height=16 src='/config_v3/imgs_defaut/loading/roue16x16.gif' /></td></tr></table></div>");
1495		var divCharg=$("#divChargement");
1496        var offset = $(element).offset();
1497        $( divCharg ).offset({ top: offset.top, left:offset.left });
1498		$( divCharg ).css({
1499            width:width,
1500            height :height,
1501            opacity:0.6,
1502            filter:"alpha(opacity=60)",
1503            KhtmlOpacity:0.6,
1504            "background-color":'#FFFFFF',
1505            position:position
1506        });
1507
1508	}
1509}
1510
1511function effaceAttenteInDiv(){
1512    $('#divChargement').remove();
1513}
1514
1515function effaceMsgAttenteParDessus(suffixe){
1516	if (!suffixe) {
1517        suffixe = "";
1518    }    
1519	var elem = $("#divChargementParDessus" + suffixe);
1520	if ($(elem)) {
1521        $(elem).remove();
1522    };
1523}
1524
1525function afficheBulle(evt,txt,largMax){
1526	var bulle=$("#divInfoBulle");
1527	if (!bulle)bulle=getNewDivToBody("divInfoBulle","divInfoBulle");
1528
1529	bulle.style.backgroundColor="#FFFFFF";
1530	bulle.style.border="1px solid #000000";
1531	bulle.style.padding="3px";
1532
1533	bulle.style.position="absolute";
1534	bulle.style.color="#000000";
1535	bulle.style.zIndex="10000001";
1536
1537	bulle.innerHTML=unescape(txt);
1538	bulle.style.visibility="visible";
1539	setPositionObjBySouris(evt,bulle,15,25);
1540}
1541
1542function setPositionObjBySouris(evt,obj,decalX,decalY){
1543    var xMouse,yMouse,x,y;
1544	if (!decalX){
1545        decalX=0;
1546    }
1547	if (!decalY){
1548        decalY=0;
1549    }
1550    var de = document.documentElement;
1551    var b = document.body;
1552    xMouse = evt.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
1553    yMouse = evt.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
1554    var ww = b.clientWidth;
1555    var wh = b.clientHeight;
1556
1557    var yMax=wh-obj.offsetHeight;
1558    if (yMouse>yMax){
1559        y=yMouse-obj.offsetHeight;
1560    } else {
1561        y=yMouse;
1562    }
1563
1564    var xMax=ww-obj.offsetWidth;
1565    if (xMouse>xMax){
1566        x=xMouse-obj.offsetWidth;
1567    } else {
1568        x=xMouse;
1569    } 
1570
1571    obj.style.left = (x+decalX) + "px";
1572    obj.style.top = (y+decalY) + "px";
1573}
1574
1575function effaceBulle(evt){
1576	var bulle=$("#divInfoBulle");
1577	if (bulle) {
1578        bulle.style.visibility="hidden";
1579    }
1580}
1581
1582function checkByInput(chpInput,mode,chpInputControl,funcQdFini,nbVerifAFaire,funcQdEchec){
1583}
1584
1585function viderChp(chpInput){
1586    if ($(chpInput).hasClass("chpInptErreurDetecte")) {
1587        $(chpInput).removeClassName("chpInptErreurDetecte");
1588        $(chpInput).removeClassName("chpInptAucuneErreur");
1589        var msg = chpInput.value.substring(2);
1590        var idx_debmsg=msg.indexOf("--");
1591        if (idx_debmsg>0){
1592            var reste = msg.substring(idx_debmsg+2);
1593            chpInput.value = reste;
1594        }
1595        else if($(chpInput).attr("data-defaut") && $(chpInput).attr("data-defaut")==$(chpInput).value){
1596            chpInput.value = "";
1597        }
1598    }
1599    else if($(chpInput).attr("data-defaut") && $(chpInput).attr("data-defaut")==$(chpInput).value){
1600        chpInput.value = "";
1601    }
1602}
1603
1604function checkCodeSecu(value, args){
1605    var check = true;    
1606    $.ajax({
1607        type: 'POST',
1608        // fiche 243540 : si on est sur une page de type www.nomdedomaine/repertoire/mapage.html on aura une 404 
1609        // donc on passera pas par success et on validera automatiquement!
1610        url: '/lib_2/ajax/infosDist.php', 
1611        async: false,
1612        data: {info: 'checkCodeSecu', val: value},
1613        dataType: 'json',
1614        success: function(retour){
1615            if (retour.code !== 'Ok') {
1616                check = false;
1617            }
1618        }
1619    });    
1620    return check;
1621}
1622
1623function getLiveValidationCaptcha(){
1624    var langue = $("body").attr("data-langue");
1625    var tabMessages = getTabMessagesValidationFormulaireByLangue(langue);
1626    var codeSecu = new LiveValidation("captcha", {validMessage: tabMessages.valid, onlyOnSubmit: true});
1627    codeSecu.add(Validate.Presence, {failureMessage: tabMessages.obligatoire});
1628    codeSecu.add(Validate.Custom, {
1629        against: function (value, args) {
1630            return checkCodeSecu(value, args);
1631        },
1632        failureMessage: tabMessages.captcha
1633    });
1634    
1635    return codeSecu;
1636}
1637
1638function getTabMessagesValidationFormulaireByLangue(langue) {
1639    var tabMessages = {};
1640
1641    // C'est international "Ok"
1642    tabMessages.valid = 'Ok';
1643
1644    if (langue == 'FRANCAIS') {
1645        tabMessages.obligatoire = 'Champ obligatoire';
1646        tabMessages.email = 'Adresse mail non valide';
1647        tabMessages.dates = 'Veuillez saisir une date au format jj/mm/aaaa';
1648        tabMessages.captcha = 'Code incorrect';
1649        tabMessages.tel = '6 chiffres minimum';
1650    } else {
1651        tabMessages.obligatoire = 'Required field';
1652        tabMessages.email = 'Invalid email';
1653        tabMessages.dates = 'Please enter a date in the format dd/mm/yyyy';
1654        tabMessages.captcha = 'Incorrect code';
1655        tabMessages.tel = '6 numbers minimum';
1656    }
1657
1658    return tabMessages;
1659}
1660
1661function affUrlInDiv(nomDiv,url,vars,msgAttente,foncQdFini){
1662	var idx=url.indexOf("?");
1663	if (idx>0){
1664		vars += url.substr(idx+1);
1665		url = url.substr(0,idx);
1666	}
1667	vars+=getInfoSession("PHPSESSID");
1668
1669	var xhr_local=creeObjHttpRequest();
1670	xhr_local.onreadystatechange = function(){
1671		if(xhr_local.readyState == 4 && xhr_local.status == 200){
1672
1673			var reponse = xhr_local.responseText;
1674			var elem=$(nomDiv);
1675			if (elem) elem.innerHTML=reponse;
1676			if (foncQdFini)foncQdFini(elem);
1677		}
1678		if(xhr_local.readyState == 4 && xhr_local.status!=200){
1679			if (foncQdFini)foncQdFini(elem);
1680		}
1681	}
1682
1683	if (msgAttente!="aucun"){
1684		var elem=document.getElementById(nomDiv);
1685		if (elem && msgAttente)elem.innerHTML=msgAttente;
1686		else affMsgAttenteInDiv(nomDiv);
1687	}
1688
1689	xhr_local.open("POST",url,true);
1690	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
1691	xhr_local.send(vars);
1692}
1693
1694function appelAjaxToFunc(url,query_string,foncQdFini){
1695	var xhr_local=creeObjHttpRequest();
1696	xhr_local.onreadystatechange = function(){
1697		if(xhr_local.readyState == 4 && xhr_local.status == 200){
1698			var contenu=xhr_local.responseText;
1699			if (foncQdFini)foncQdFini(contenu);
1700		}
1701	}
1702	xhr_local.open("POST",url,true);
1703	xhr_local.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
1704	xhr_local.send(query_string);
1705}
1706
1707function getCookie(name) {
1708    if (document.cookie.length > 0) {
1709        var deb = document.cookie.indexOf(name + '=');
1710        if (deb != -1) {
1711            deb = deb + name.length + 1;
1712            var fin = document.cookie.indexOf(';', deb);
1713            if (fin == -1)
1714                fin = document.cookie.length;
1715            return unescape(document.cookie.substring(deb, fin));
1716        }
1717    }
1718    return '';
1719}
1720
1721function getQueryString() {
1722    var lDoc = String(document.location);
1723    var n1 = lDoc.indexOf("?");
1724    if (n1 <= 0)
1725        return "";
1726    var n2 = lDoc.indexOf("#");
1727    if (n2 <= 0)
1728        n2 = lDoc.length;
1729    var qs = lDoc.substring(n1 + 1, n2);
1730    return qs;
1731}
1732
1733function setClassForObj(obj, classe) {
1734    if (obj) {
1735        obj.setAttribute("class", classe);
1736        obj.setAttribute("className", classe);
1737    }
1738}
1739
1740function initCalendrierDisposGP() {
1741    if ($('.div_disposProd').length > 0) {
1742        initSliderCalendrier();
1743        if ($('.div_disposProd').length > 0) {
1744            $('.div_disposProd table.tableDisposProdOneMonth').each(function () {
1745                $('.spanCalendJourGP_libreArriveePossible, .spanDateSejourDevisArriveePossible', this).click(function () {
1746                    var lien = $(this).attr('data-lienResa');
1747                    if (lien.length > 0) {
1748                        window.open(lien, "blank");
1749                    }
1750                });
1751            });
1752        }
1753    }
1754}
1755
1756function initSliderCalendrier() {
1757    if ($('.div_disposProd').length > 0) {
1758        $('.div_disposProd').each(function () {
1759            var nombreDeSlidesADecaler = 1;
1760            if ($(this).attr('data-nombreDeSlidesADecaler')) {
1761                nombreDeSlidesADecaler = $(this).attr('data-nombreDeSlidesADecaler');
1762            }
1763            $(this).sudoSlider({
1764                customLink: $('.btnDispoProdMoisSuivPrec'),
1765                prevNext: false,
1766                speed: 0,
1767                moveCount: nombreDeSlidesADecaler
1768            });
1769        });
1770    }
1771}
1772
1773function traitePanierGestprod() {
1774    if ($('#div_liste_panierBasNonDate').length > 0) {
1775        $.ajax({
1776            type: "POST",
1777            url: "/resaGp/contenuPanierBoutique.php",
1778            data: {target: "_blank"},
1779            beforeSend: function () {
1780            },
1781            success: function (result) {
1782                $("#div_liste_panierBasNonDate").html(result);
1783            }
1784        });
1785    }
1786
1787    if ($("#div_liste_panierHautNonDate").length > 0) {
1788        $.ajax({
1789            type: "POST",
1790            url: "/resaGp/contenuPanierBoutique.php",
1791            data: {target: "_blank"},
1792            beforeSend: function () {
1793            },
1794            success: function (result) {
1795                $("#div_liste_panierHautNonDate").html(result);
1796            }
1797        });
1798    }
1799}
1800
1801function ajoutPanierGestprod(no_id_tarif, borne_maxi) {
1802    var quantite = $("#sp_qte_" + no_id_tarif).attr("valeur");
1803    var nouvelle_quantite = parseInt(quantite) + 1;
1804    if (nouvelle_quantite <= borne_maxi) {
1805        if (nouvelle_quantite < 10) {
1806            $("#sp_qte_" + no_id_tarif).html("0" + nouvelle_quantite);
1807        }
1808        else {
1809            $("#sp_qte_" + no_id_tarif).html(nouvelle_quantite);
1810        }
1811        $("#sp_qte_" + no_id_tarif).attr("valeur", nouvelle_quantite);
1812        $("#nbprod_" + no_id_tarif).attr("value", nouvelle_quantite);
1813    }
1814}
1815
1816function retirePanierGestprod(no_id_tarif) {
1817    var quantite = $("#sp_qte_" + no_id_tarif).attr("valeur");
1818    var nouvelle_quantite = parseInt(quantite) - 1;
1819    if (nouvelle_quantite >= 0) {
1820        if (nouvelle_quantite < 10) {
1821            $("#sp_qte_" + no_id_tarif).html("0" + nouvelle_quantite);
1822        }
1823        else {
1824            $("#sp_qte_" + no_id_tarif).html(nouvelle_quantite);
1825        }
1826        $("#sp_qte_" + no_id_tarif).attr("valeur", nouvelle_quantite);
1827        $("#nbprod_" + no_id_tarif).attr("value", nouvelle_quantite);
1828    }
1829}
1830
1831function sendThisToFriend(cmd, w, h, titreDiv, objet, url, lien, message, lstRef) {
1832    if (!w || !h) {
1833        w = parseInt(window.innerWidth) * 0.9;
1834        h = parseInt(window.innerHeight) * 0.9;        
1835        if (!w) {
1836            w = 800;
1837        }            
1838        if (!h) {
1839            h = 600;
1840        }            
1841    }
1842
1843    var adr = "/lib_2/ajax/contenuFenetre.php";
1844    var xhr_local = creeObjHttpRequest();
1845
1846    var html_init = "<div id='div_sendMailToFriend'><img src=/config_v3/imgs_defaut/loading/roue16x16.gif /><br /></div>";
1847
1848    afficheDivAvecTransparence(html_init, w, h, '', titreDiv);
1849
1850    var sending = getInfoSession() + "&element=" + cmd + "&motClesObjetMail=" + escape(objet) + "&URL=" + url + "&motClesLien=" + escape(lien) + "&motClesMessage=" + escape(message) + "&lstReference=" + lstRef;
1851    xhr_local.onreadystatechange = function () {
1852        if (xhr_local && xhr_local.readyState == 4) {
1853            var html = xhr_local.responseText;
1854            if ($('#div_sendMailToFriend')) {
1855                $('#div_sendMailToFriend').html(html);
1856            }
1857            if ($('#inputDateFinEnvoiAmi').length > 0) {
1858                $('#inputDateDebEnvoiAmi').datepicker({
1859                    minDate: 0,
1860                    onSelect: function (date) {
1861                        $('#inputDateFinEnvoiAmi').datepicker({
1862                            minDate: date
1863
1864                        });
1865                    }
1866                });
1867            }
1868
1869            if ($('#select_typeCentrale').length > 0) {
1870                $('#select_typeCentrale').change(function () {
1871                    var mail = $(this).find('option:selected').attr('data-mail');
1872                    $('#emailDeLaPart').val(mail);
1873                });
1874            }
1875
1876            if ($('#div_envoiAmisInfosMiniCata').length > 0) {
1877                $('#div_envoiAmisInfosMiniCata').click(function () {
1878                    if ($('#div_saisieInfosClientPourMiniCata').is(':visible')) {
1879                        $('#div_saisieInfosClientPourMiniCata').hide();
1880                    } else {
1881                        $('#div_saisieInfosClientPourMiniCata').show();
1882                    }
1883                });
1884            }
1885            initActionBtnReloadCaptcha();
1886        }
1887    }
1888    xhr_local.open("POST", adr, true);
1889    xhr_local.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
1890    xhr_local.send(sending);
1891}
1892
1893function envoiMailAmiByAjaxByForm() {
1894    var adr = "/lib_2/ajax/envoiMail.php";
1895    var typeMail = "AMI";
1896    var prenom_expediteur = $('#prenomDeLaPart').val();
1897    var email_expediteur = $('#emailDeLaPart').val();
1898    var sujet_mail = $('#emailObjet').val();
1899    var message_mail = $('#emailMessage').val();
1900    var ami1_mail = $('#email1').val();
1901    var ami2_mail = $('#email2').val();
1902    var ami3_mail = $('#email3').val();
1903    var urlPageCurr = $('#div_urlPageCourante').html();
1904    var motcleLien = $('#div_messageAvantLien').html();
1905    var msgEnvoiOK = $('#div_messageEnvoiOK').html();
1906    var msgEnvoiKO = $('#div_messageEnvoiKO').html();
1907    if ($('#div_listeReferenceSelection')) {
1908        var lstRefs = $('#div_listeReferenceSelection').html();
1909    }
1910
1911    if (ami1_mail.length > 0) {
1912        var sending = "&typeMail=" + typeMail;
1913        sending += "&prenomExpediteur=" + prenom_expediteur;
1914        sending += "&expediteur=" + email_expediteur;
1915        sending += "&sujet=" + sujet_mail;
1916        sending += "&messageMail=" + message_mail;
1917        sending += "&emailDest1=" + ami1_mail;
1918        sending += "&emailDest2=" + ami2_mail;
1919        sending += "&emailDest3=" + ami3_mail;
1920        sending += "&urlCurr=" + urlPageCurr;
1921        sending += "&motcleLien=" + motcleLien;
1922        sending += "&msgEnvoiOK=" + msgEnvoiOK;
1923        sending += "&msgEnvoiKO=" + msgEnvoiKO;
1924        if (lstRefs) {
1925            sending += "&lstRefs=" + lstRefs;
1926        }
1927        if ($('#inputDateDebEnvoiAmi').length > 0) {
1928            sending += "&dateDeb=" + $('#inputDateDebEnvoiAmi').val();
1929            sending += "&dateFin=" + $('#inputDateFinEnvoiAmi').val();
1930        }
1931        if ($('#select_typeCentrale').length > 0) {
1932            sending += "&typeCentrale=" + $('#select_typeCentrale').val();
1933        }
1934        if ($('#div_saisieInfosClientPourMiniCata').length > 0) {
1935            var tabInfosClient = getInfosClientPourMiniCata();
1936            if ($('#email1').length === 1) {
1937                tabInfosClient.e_mail = $('#email1').val();
1938            }
1939            sending += "&tabInfosClient=" + JSON.stringify(tabInfosClient);
1940        }
1941        var code = $('#captcha').val();
1942        sending += '&codeSecu=' + code;
1943        $.ajax({
1944            url: adr,
1945            type: 'POST',
1946            data: sending,
1947            dataType: 'json',
1948            success: function (json) {
1949                traiteRetourVerifCaptcha(json);
1950                $('#div_messageEnvoiMail').html(json.msg).addClass('messageAffiche');
1951                if ($('#div_messageEnvoiMailRetour')) {
1952                    $('#div_messageEnvoiMailRetour').show();
1953                    $.scrollTo($("#div_messageEnvoiMailRetour"), 500, {offset: -100});
1954                }
1955                $("#div_sendMailToFriend form *").attr("disabled", "disabled");
1956                $("#div_envoiAmiSubmit").hide();
1957                $("#div_envoiAmiContent").hide();
1958                $(".div_messageIntroForm").hide();
1959            }
1960        });
1961    }
1962}
1963
1964function verifEtEnvoiMailAmi() {
1965    var i = 0;
1966	var langue = $('body').attr('data-langue');
1967	// Yoann 01/04 : on utilise plus checkForm ou checkByInput, à la place je met le plug-in LiveValidator
1968	var mailClient = new LiveValidation("emailDeLaPart", {validMessage: "Ok", onlyOnSubmit: true});
1969	addValidateOnLiveValidationEmail(mailClient, langue, true);
1970	var mailAmi1 = new LiveValidation("email1", {validMessage: "Ok", onlyOnSubmit: true});
1971	addValidateOnLiveValidationEmail(mailAmi1, langue, true);
1972	var mailAmi2 = new LiveValidation("email2", {validMessage: "Ok", onlyOnSubmit: true});
1973	addValidateOnLiveValidationEmail(mailAmi2, langue, false);
1974	var mailAmi3 = new LiveValidation("email3", {validMessage: "Ok", onlyOnSubmit: true});
1975	addValidateOnLiveValidationEmail(mailAmi3, langue, false);
1976	var codeSecu = new LiveValidation("captcha", {validMessage: "Ok", onlyOnSubmit: true});
1977	var messErrorCodeSecu = 'Code incorrect';
1978
1979	if (langue == "FRANCAIS") {
1980		if (!$('#prenomDeLaPart').hasClass('optionnel')) {
1981			var prenomClient = new LiveValidation("prenomDeLaPart", {validMessage: "Ok", onlyOnSubmit: true});
1982			prenomClient.add(Validate.Presence, {failureMessage: "Champ obligatoire"});
1983		}
1984		var message = new LiveValidation("emailMessage", {validMessage: "Ok", onlyOnSubmit: true});
1985		message.add(Validate.Presence, {failureMessage: "Champ obligatoire"});
1986		codeSecu.add(Validate.Presence, {failureMessage: "Champ obligatoire"});
1987	} else {
1988		if (!$('#prenomDeLaPart').hasClass('optionnel')) {
1989			var prenomClient = new LiveValidation("prenomDeLaPart", {validMessage: "Ok", onlyOnSubmit: true});
1990			prenomClient.add(Validate.Presence, {failureMessage: "Required field"});
1991		}
1992		var message = new LiveValidation("emailMessage", {validMessage: "Ok", onlyOnSubmit: true});
1993		message.add(Validate.Presence, {failureMessage: "Required field"});
1994		codeSecu.add(Validate.Presence, {failureMessage: "Required field"});
1995		messErrorCodeSecu = 'Incorrect code';
1996	}
1997
1998	codeSecu.add(Validate.Custom, {against: function (value) {
1999		var check = true;
2000		$.ajax({
2001			type: 'POST',
2002			url: '/lib_2/ajax/infosDist.php',
2003			async: false,
2004			data: {info: 'checkCodeSecu', val: value},
2005			dataType: 'json',
2006			success: function (retour) {
2007				check = traiteRetourVerifCaptcha(retour);
2008			}
2009		});
2010		return check;
2011	}, failureMessage: messErrorCodeSecu});
2012
2013	var tabAValider = new Array(mailClient, mailAmi1, mailAmi2, mailAmi3, message, codeSecu);
2014	if (!$('#prenomDeLaPart').hasClass('optionnel')) {
2015		tabAValider.push(prenomClient);
2016	}
2017	LiveValidation.massValidate(tabAValider);
2018
2019	if ($(".LV_invalid").length == 0) {
2020		envoiMailAmiByAjaxByForm();
2021	}
2022}
2023
2024function initActionBtnReloadCaptcha() {
2025    $('#sp_btnReload').click(function () {
2026        var date = new Date();
2027        var time = date.getTime();
2028        var srcCaptcha = $('#span_captchaImg img').attr('src');
2029        var pos = srcCaptcha.indexOf('?time');
2030        if (pos != -1) {
2031            srcCaptcha = srcCaptcha.substr(0, pos);
2032        }
2033        srcCaptcha += '?time=' + time;
2034        $('#span_captchaImg img').attr('src', srcCaptcha);
2035    });
2036}
2037
2038function verifEtEnvoiMailContactProp_2() {
2039    // La première fois qu'on passe dans cette fonction aucun message n'est affiché
2040    // On va donc gérer les évènements sur les listes déroulantes et le code de sécu
2041    // Pour effacer les messages d'erreur/validation au focus
2042    $("#form_envoiMailProp select").focus(function () {
2043        $(this).siblings(".LV_validation_message").remove();
2044    });
2045
2046    var tel = $('#inpt_formPropmailTel').val();
2047    $('#inpt_formPropmailTel').val(tel.replace(/ /g, '')); // sinon avec les espaces la validation n'est pas bonne.
2048
2049    var langue = $("body").attr("data-langue");
2050    var tabMessages = getTabMessagesValidationFormulaireByLangue(langue);
2051    var email = new LiveValidation("inpt_formPropmailFrom", {validMessage: tabMessages.valid, onlyOnSubmit: true});
2052    addValidateOnLiveValidationEmail(email, langue, true);
2053
2054    var tel = new LiveValidation("inpt_formPropmailTel", {validMessage: tabMessages.valid, onlyOnSubmit: true});
2055    tel.add(Validate.Format, {pattern: /^[0-9]{6,}$/, failureMessage: tabMessages.tel});
2056
2057    var msg = new LiveValidation("textarea_formPropMessage", {validMessage: tabMessages.valid, onlyOnSubmit: true});
2058    msg.add(Validate.Presence, {failureMessage: tabMessages.obligatoire});
2059
2060    var tabAValider = new Array(email, tel, msg);
2061
2062    if ($('#captcha').length > 0) {
2063        tabAValider.push(getLiveValidationCaptcha());
2064    }
2065
2066    LiveValidation.massValidate(tabAValider);
2067
2068    var xhtml = "";
2069    $("#div_pays span").remove(".LV_validation_message");
2070    if ($("#select_pays").val() != "0")
2071        xhtml = "<span class='LV_validation_message LV_valid'>Ok</span>";
2072    else {
2073        if (langue == "FRANCAIS")
2074            xhtml = "<span class='LV_validation_message LV_invalid'>Champ obligatoire</span>";
2075        else
2076            xhtml = "<span class='LV_validation_message LV_invalid'>Required field</span>";
2077    }
2078    $("#div_pays").append(xhtml);
2079    xhtml = "";
2080
2081    if ($("#select_dpt:visible").length > 0) {
2082        $("#div_dpt span").remove(".LV_validation_message");
2083        if ($("#select_dpt").val() != "0")
2084            xhtml = "<span class='LV_validation_message LV_valid'>Ok</span>";
2085        else {
2086            if (langue == "FRANCAIS")
2087                xhtml = "<span class='LV_validation_message LV_invalid'>Champ obligatoire</span>";
2088            else
2089                xhtml = "<span class='LV_validation_message LV_invalid'>Required field</span>";
2090        }
2091        $("#div_dpt").append(xhtml);
2092        xhtml = "";
2093    }
2094
2095    $("#div_nbPers span").remove(".LV_validation_message");
2096    if (($("#select_formPropmailPers").attr('data-obligatoire') === '0') || ($("#select_formPropmailPers").val() != "0" && $("#select_formPropmailPers").val() != "")) {
2097        xhtml = "<span class='LV_validation_message LV_valid'>Ok</span>";
2098    } else {
2099        if (langue == "FRANCAIS") {
2100            xhtml = "<span class='LV_validation_message LV_invalid'>Champ obligatoire</span>";
2101        } else {
2102            xhtml = "<span class='LV_validation_message LV_invalid'>Required field</span>";
2103        }
2104    }
2105    $("#div_nbPers").append(xhtml);
2106    xhtml = "";
2107
2108    if ($(".LV_invalid", '#form_envoiMailProp').length == 0) {
2109        envoiMailContactPropByAjaxByForm();
2110        if (window.foncQdFini_envoiFormContact) { // la function est dans le look si besoin de faire quelque chose à ce moment là spécifique au look
2111            foncQdFini_envoiFormContact();
2112        }
2113        if ($('#apresEnvoiMail_GAEVENT').length > 0) {
2114            $('#apresEnvoiMail_GAEVENT').trigger('click');
2115        }
2116        // Fiche 224450 si la div div_submitForm n'est plus visible et qu'il y a data-trackcategory data-trackaction data-tracklabel faire un ga_push event
2117
2118    } else {
2119        // Une erreur est survenu lors de la validation du formulaire, on envoit les données à  Google Tag Manager
2120        if (typeof (dataLayer) != 'undefined') {
2121
2122            dataLayer.push({
2123                'form_error': true,
2124                'event': 'form_error'
2125            });
2126            var champsInvalides = '';
2127            $('.LV_invalid_field').each(function () {
2128                champsInvalides += $(this).attr('name') + ', ';
2129            });
2130            // On enlève la dernière virgule et le dernier espace
2131            champsInvalides = champsInvalides.substring(0, champsInvalides.length - 2);
2132            dataLayer.push({
2133                'form_error_field': champsInvalides,
2134                'event': 'form_error'
2135            });
2136        }
2137    }
2138}
2139
2140function envoiMailContactPropByAjaxByForm() {
2141    if (typeof (appelApresContactProp) == 'function') {
2142        appelApresContactProp();
2143    }
2144    var adr = "/lib_2/ajax/envoiMail.php";
2145    var typeMail = "CONTACTPROP";
2146    var nomExpediteur = $('#inpt_formPropmailNom').val();
2147    var prenomExpediteur = $('#inpt_formPropmailPrenom').val();
2148    var email_expediteur = $('#inpt_formPropmailFrom').val();
2149    var telExpediteur = $('#inpt_formPropmailTel').val();
2150    var emailDest1 = '';
2151    var emailDest2 = '';
2152    var paysExpediteur = $('#select_pays').val() || ''; // ce champ n'est pas défini tout le temps fiche 257441
2153    if ($('#emailDest1').length > 0) {
2154        if ($('#emailDest1Condition').length > 0) {
2155            if ($('#emailDest1Condition').is(':checked')) {
2156                emailDest1 = $('#emailDest1').val();
2157            }
2158        } else {
2159            emailDest1 = $('#emailDest1').val();
2160        }
2161    }
2162    if ($('#emailDest2').length > 0) {
2163        emailDest2 = $('#emailDest2').val();
2164    }
2165    var sujet_mail = $('#emailObjet').val();
2166    var date_deb;
2167    var nb_participant;
2168    var nb_participant_enfant;
2169    if ($('#inpt_formPropmailDateDeb')) {
2170        date_deb = $('#inpt_formPropmailDateDeb').val();
2171        var date_fin = $('#inpt_formPropmailDateFin').val();
2172        nb_participant = $('#select_formPropmailPers').val();
2173        if ($('#select_formPropmailPersEnfant')) {
2174            nb_participant_enfant = $('#select_formPropmailPersEnfant').val();
2175        }
2176    }
2177    else {
2178        date_deb = $('#inpt_formPropmailDate').val();
2179        var duree_sej = $('#inpt_formPropmailDuree').val();
2180        nb_participant = $('#inpt_formPropmailPers').val();
2181        if ($('#select_formPropmailPersEnfant')) {
2182            nb_participant_enfant = $('#select_formPropmailPersEnfant').val();
2183        }
2184    }
2185    var message_mail = $('#textarea_formPropMessage').val();
2186    var destinataire = $('#div_infosEnvoiMail #destinataire').val();
2187    var infoProd = $('#div_infosSuppStructure').html();
2188    var numheb = '';
2189    if ($('#div_infosSuppStructure') && $('#div_infosSuppStructure').attr('data-numheb')) {
2190        numheb = $('#div_infosSuppStructure').attr('data-numHeb');
2191    }
2192    var msgEnvoiOK = $('#div_messageEnvoiOK').html();
2193    var msgEnvoiKO = $('#div_messageEnvoiKO').html();
2194
2195    if (email_expediteur.length > 0) {
2196        var sending = "&typeMail=" + typeMail;
2197        sending += "&prenomExpediteur=" + prenomExpediteur;
2198        sending += "&nomExpediteur=" + nomExpediteur;
2199        sending += "&expediteur=" + email_expediteur;
2200        sending += "&sujet=" + sujet_mail;
2201        sending += "&dateDeb=" + date_deb;
2202        if (date_fin) {//224551
2203            sending += "&dateFin=" + date_fin;
2204        }
2205        if (duree_sej) {
2206            sending += "&dureeSej=" + duree_sej;
2207        }
2208        sending += "&telExpediteur=" + telExpediteur;
2209        //sending += "&communeExpediteur=" + escape(communeExpediteur);
2210        sending += "&nbParticipant=" + nb_participant;
2211        sending += "&nbParticipantEnfant=" + nb_participant_enfant;
2212        sending += "&destinataire=" + destinataire;
2213        if ($('#inpt_formSendItToMe')[0].checked){
2214            sending += "&copie=" + email_expediteur;
2215        }
2216        sending += "&messageMail=" + message_mail;
2217        sending += "&infoProd=" + infoProd;
2218        sending += "&msgEnvoiOK=" + msgEnvoiOK;
2219        sending += "&msgEnvoiKO=" + msgEnvoiKO;
2220        if (emailDest1.length > 0) {
2221            sending += "&emailDest1=" + emailDest1;
2222        }
2223        if (emailDest2.length > 0) {
2224            sending += "&emailDest2=" + emailDest2;
2225        }
2226        if (numheb) {
2227            sending += "&numheb=" + numheb;
2228        }
2229        if (paysExpediteur.length > 0) {
2230            sending += "&paysExpediteur=" + paysExpediteur;
2231        }
2232
2233        if ($('#inputNomStatTracking').length > 0) {
2234            var stat = $('#inputNomStatTracking').val() || '';
2235            if (stat) {
2236                sending += "&statTracking=" + stat + '&ident=' + $('#inputIdentPourStat').val();
2237            }
2238        }
2239        var code = $('#captcha').val();
2240        sending += '&codeSecu=' + code;
2241        $.ajax({
2242            url: adr,
2243            type: 'POST',
2244            data: sending,
2245            dataType: 'json',
2246            success: function (json) {
2247                traiteRetourVerifCaptcha(json);
2248                if ($('#div_submitForm').data('trackcategory')) {
2249                    if ($('#div_submitForm').data('datalayer')) {
2250                        dataLayer.push({'Label_Event': $('#div_submitForm').data('tracklabel'), 'Categorie_Event': $('#div_submitForm').data('trackcategory'), 'event': $('#div_submitForm').data('trackaction')});
2251                    } else {
2252                        var _gaq = _gaq || [];
2253                        try {
2254                            _gaq.push(['wa._trackEvent', $('#div_submitForm').data('trackcategory'), $('#div_submitForm').data('trackaction'), $('#div_submitForm').data('tracklabel')]);
2255                        } catch (e) {
2256                            console.log('erreur gaq.push :' + e);
2257                        }
2258                    }
2259                }
2260                $('#div_messageEnvoiMail').html(unescape(json.msg)).addClass('messageAffiche');
2261                if ($('#div_messageEnvoiMailRetour')) {
2262                    $('#div_messageEnvoiMailRetour').show();
2263                    $.scrollTo($("#div_messageEnvoiMailRetour"), 500, {offset: -100});
2264                }
2265                $("#div_sendMailToProp form *").attr("disabled", "disabled");
2266                $(".div_messageIntroForm").hide();
2267                
2268                if (json.code == 'OK') {
2269                    $("#div_infosObligatoires").hide();
2270                    $("#div_obligatoire").hide();
2271                    $(".div_formContactPropContent").hide();
2272                    $("#div_message").hide();
2273                    $("#div_sentItToMe").hide();
2274                }
2275            }
2276        });
2277
2278        //on efface le bouton pour l'envoi du mail
2279        $('#div_submitForm').hide();
2280    }
2281}
2282
2283function autocompleteur(elemInput, elemARemplirQuandSelection, url, tabParamsRequeteAjax, minLength, callback, champLibelleDansReponse, fonctionSurReponseAjax) {
2284    // permet de récupérer une liste pour un autocompleteur: la réponse ajax doit être en json et de type {1:{label:"le texte à afficher",value:"la valeur à récupérer au select"}}
2285    /**
2286     * 
2287     * @param {type} elemInput // l'input de saisie. C'est un element du dom
2288     * @param {type} elemARemplirQuandSelection  (facultatif)
2289     * @param {type} url // url à interroger lors de l'appel ajax
2290     * @param {type} tabParamsRequeteAjax // paramètres à envoyer pour la requete ajax
2291     * @param {type} minLength // longueur minimale de déclenchement
2292     * @param {type} callback // fonction à exécuter lors de la sélection 
2293     * @param {type} champLibelleDansReponse // le nom du champ dans le tableau de réponse ajax que l'on affichera dans l'autocompleteur (si null on prend le premier)
2294     * @param {type} fonctionSurReponseAjax // fonction qui sera appelée dès qu'une requete ajax est envoyée. on passe en paramètre la réponse ajax
2295     * @returns {undefined}
2296     */
2297
2298    var minLengthParam = minLength || 2;
2299    var elemDestination = elemARemplirQuandSelection || null;
2300 
2301    $(elemInput).autocomplete({
2302        source: function (request, response) {
2303            var params = tabParamsRequeteAjax || {};
2304            params.value = request.term;
2305            params.returnJson = true; // permet notamment de se servir de LISTALLREF dans infosCGI.php
2306            $.ajax({
2307                url: url,
2308                dataType: 'jsonp',
2309                data: params,
2310                success: function (data) {
2311                    var fonctionRemplissage = fonctionSurReponseAjax || null;
2312                    if (fonctionRemplissage && typeof window[fonctionRemplissage] == 'function') {
2313                        window[fonctionRemplissage](data);
2314                    }
2315                    response($.map(data, function (item) {
2316                        var champ = champLibelleDansReponse || null;
2317                        var label;
2318                        if (champ) {
2319                            label = item[champ];
2320                        }
2321                        else {// si pas de champLibelleDansReponse, on prend le premier
2322                            var tabKeys = Object.keys(item);
2323                            label = item[tabKeys[0]];
2324                        }
2325                        return {
2326                            label: label,
2327                            value: JSON.stringify(item)
2328                        };
2329                    }));
2330                }
2331            });
2332        },
2333        minLength: minLengthParam,
2334        select: function (event, ui) {
2335            var fonction = callback || false;
2336            event.preventDefault();
2337            if (fonction) {
2338                try {
2339                    window[fonction](ui.item);
2340                }
2341                catch (e) {
2342                    // oups petit problème peut être que la fonction de callback n'est pas définie.
2343                }
2344            }
2345            else {
2346                var val = ui.item.value;
2347                if (elemDestination) {
2348                    $(elemDestination).val(val);
2349                }
2350                $(elemInput).val(ui.item.label);
2351            }
2352        },
2353        focus: function (event, ui) {
2354            event.preventDefault();
2355            var val = ui.item.value;
2356            if (elemDestination) {
2357                $(elemDestination).val(val);
2358            }
2359        },
2360        open: function () {
2361            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
2362        },
2363        close: function () {
2364            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
2365        }
2366    });
2367}
2368
2369function initClicOut(){
2370    $.fn.onclickout = function (callback) {
2371        var elm = this;
2372        $(document).bind("click", function (evt) {
2373            if ($(evt.target).closest(elm).size() === 0) {
2374                callback.call(elm, evt);
2375            }
2376        });
2377        return elm;
2378    };
2379}
2380
2381function estMoteurSansLien() {
2382    if ($('#itea_page_contentListe') && $('#itea_page_contentListe').attr('data-post') === 'true') {
2383        return true;
2384    }
2385    return false;
2386}
2387
2388function setActionSurDiaporama(){
2389    if($(".iteaV5_responsiveSlides").length>0){
2390        setTimeout(function(){
2391            $('.iteaV5_responsiveSlides li img').each(function(){
2392                if($(this).data('srcfullquality')){
2393                    $(this).attr('src',$(this).data('srcfullquality'));
2394                }
2395            });
2396        },5000);
2397
2398        $(".iteaV5_responsiveSlides").each(function(){
2399            var time = 1000 * $(this).attr("data-temps"); // temps d'affichage de la diapo
2400            var speed = $(this).attr("data-speed");//durée de la transition. 500ms pour tous, 1000 pour fédé
2401            var nav = false;//afficher/masquer les boutons de navigation            
2402            var auto = true;
2403            if($(this).attr("data-auto")=="false"){
2404                var auto = false;
2405            }
2406            
2407            if($(this).attr("data-nav") == '1'){
2408                nav  = true;
2409            }
2410            if(!speed){
2411                speed = 500;
2412            }
2413            $(this).responsiveSlides({
2414                timeout: time,          // Integer: Time between slide transitions, in milliseconds
2415                speed: speed,
2416                nav : nav,
2417                pager: nav,
2418                prevText:"",
2419                nextText:"",  
2420                auto:auto
2421            });  
2422        });        
2423        
2424        iteaV5_responsiveSlidesLoadFondLi();
2425        $(window).resize(function(){
2426            setTimeout(function(){
2427                iteaV5_responsiveSlidesLoadFondLi();
2428            },500);
2429            
2430        });
2431	}
2432}
2433
2434function iteaV5_responsiveSlidesLoadFondLi(){
2435    $('li[data-diaporamasrcli]').each(function(){
2436        $(this).css('background-image','url('+$(this).data('diaporamasrcli')+'?width='+$(this).width()+'&height='+$(this).height()+')'); 
2437    });
2438}
2439
2440function loadScriptCss(href) {
2441    var list = document.getElementsByTagName('link');
2442    var i = list.length;
2443    while (i--) {
2444        if (list[i].href === href) {
2445            return;
2446        }
2447    }
2448    $('<link>').appendTo('.scripts.specifiquesPagesActuelles').attr({type: 'text/css', rel: 'stylesheet', href: href});
2449}
2450
2451function loadScriptJs(src, callback) {
2452    var list = document.getElementsByTagName('script');
2453    var i = list.length;
2454    while (i--) {
2455        if (list[i].src === src) {
2456            if (typeof callback === 'function') {
2457                callback();
2458            }
2459            return;
2460        }
2461    }
2462    $.ajax({url: src, dataType: 'script', cache: true, success: function () {
2463        if (typeof callback === 'function') {
2464            callback();
2465        }
2466    }});
2467}
2468
2469function ajouterAuPanier(ident, indiceListe, dansFiche, callback) {
2470	$.ajax({
2471		type: "POST",
2472		dataType: 'xml',
2473		url: "/lib_2/ajax/gerePanier.php",
2474		data: "action=ajoutPanier&ident=" + ident + '&indiceListe=' + indiceListe + '&dansFiche=' + dansFiche,
2475		success: function (result) {
2476			var code = $(result).find('CODEERR').text();
2477			if (code == 'OK') {
2478				var date = new OBJDate();
2479				date.ajoutJour(30);
2480				var dateExpire = new Date(date.getAnnee(), date.getMois() - 1, date.getJour());
2481				setCookie('AJOUTPANIERACTIVE', 'O', dateExpire);
2482				if (typeof window[callback] == 'function') {
2483					window[callback](result);
2484				}
2485			} else {
2486				$('<div class="divInfos">Une erreur est survenue, veuillez rafraichir la page</div>').dialog({
2487					modal: true
2488				});
2489			}
2490		}
2491	});
2492}
2493
2494function afficheRetourAjaxPanier(tabInfosXml){
2495    try{
2496        var html = "<div id='divChargementAjx'>"+$(tabInfosXml).find('HTML').text()+'</div>';
2497        $('body').append(html);
2498        $('#divChargementAjx').dialog({
2499            modal: true
2500        });
2501    }
2502    catch(e){
2503        return;
2504    }
2505}
2506
2507function ajouterClassePanier(numHeb){
2508    if(numHeb){
2509        $('.li_elemListe[data-numheber="'+numHeb+'"]').addClass('li_elemListe_dansPanier');
2510        $('.a_ajoutPanier[data-numheber="'+numHeb+'"]').addClass('a_dansPanier');
2511        $('.a_retirePanier[data-numheber="'+numHeb+'"]').addClass('a_dansPanier');
2512    }
2513}
2514
2515function supprimerClassePanier(numHeb){
2516    if(numHeb){
2517        $('.li_elemListe[data-numheber="'+numHeb+'"]').removeClass('li_elemListe_dansPanier');
2518        $('.a_ajoutPanier[data-numheber="'+numHeb+'"]').removeClass('a_dansPanier');
2519        $('.a_retirePanier[data-numheber="'+numHeb+'"]').removeClass('a_dansPanier');
2520    }
2521}
2522
2523function suppSelectionPanier(ident,nothide){
2524    var adr = "/lib_2/ajax/gerePanier.php";
2525    var sending = "action=supprPanier&ident=" + ident;
2526    appelAjaxXMLToFunc(adr, sending, function (response) {
2527        if (response) {
2528            var identToHide = $(response).find('ident').text();
2529            var ul = $('#ul_lst > li').get();
2530            var divToHide;
2531            $(ul).each(function () {
2532                var attr;
2533                // on va chercher un ident dans la balise li pour savoir si c'est bien la li qu'on cherche.
2534                for (i = 0; i < $('a', this).length; i++) {
2535                    attr = $($('a', this)[i]).attr('data-ident');
2536                    if (attr != undefined) {
2537                        break;
2538                    }
2539                }
2540                // si ça correspond avec l'ident de la réponse:
2541                if (attr == identToHide) {
2542                    divToHide = this;
2543                }
2544            });
2545            if (!nothide || nothide == undefined) {
2546                var tabDivs = $(response).find('divToChange');
2547                for (i = 0; i < tabDivs.length; i++) {
2548                    $('#' + $(tabDivs[i]).find('name').text()).html($(tabDivs[i]).find('content').text());
2549                }
2550                $(divToHide).hide('slow');
2551            }
2552            //supprimer ident dans lien "envoi a un ami"
2553            var elem = $("#a_fiche_envoi_ami");
2554            if(elem.length == 0){
2555                elem = $("#a_fiche_envoi_ami_txt");
2556            }
2557            if (elem.length > 0 && elem.attr("onclick")) {
2558                var onclick = elem.attr("onclick");
2559                onclick = onclick.replace(identToHide, "");
2560                onclick = onclick.replace("%2C%2C", "%2C");
2561                elem.attr("onclick", onclick);
2562            }
2563        }
2564    });
2565    var numHeb = '';
2566    var tabIdent = ident.split('.');
2567    numHeb = tabIdent[2];
2568    supprimerClassePanier(numHeb)
2569}
2570
2571function refreshPanier(){
2572
2573}
2574
2575function estResaAilleurs(){
2576    if($('#modeResaAilleurs').length>0){
2577        return true;
2578    }
2579    return false;
2580}
2581
2582function initialiseToutesDivQtip() {
2583    if ($('.viewWithQtip').length <= 0) {
2584        return;
2585    }
2586    chargeScript('/api_externe/qtip/jquery.qtip.min.js', initialiseQtipQuandLibrairiePrete);
2587    //$('.scripts.apis_externes').append('<script src="/api_externe/qtip/jquery.qtip.min.js" defer></script>');
2588    $('head').append('<link href="/api_externe/lib_2-dev/js/qtip/jquery.qtip.min.css?01/02/2023" rel="stylesheet" media="screen" type="text/css" />');
2589}
2590
2591function initialiseQtipQuandLibrairiePrete() {
2592    $('.viewWithQtipTohide').hide();
2593    $('.viewWithQtip').each(function () {
2594        if (!$(this).attr('data-qhelp') || !$("#" + $(this).attr('data-qhelp'))) {
2595            return;
2596        }
2597        $(this).qtip({
2598            style: {
2599                classes: $(this).attr('data-qclasses')
2600            },
2601            content:
2602            {
2603                text: $("#" + $(this).attr('data-qhelp')).html(),
2604                title: {
2605                    text: $(this).attr('data-qtitle')
2606                }
2607            },
2608            position: getQtipPosition($(this).attr('data-qposition')),
2609            show: 'mouseover',
2610            hide: 'mouseout',
2611        });        
2612    });
2613}
2614
2615function getQtipPosition(qposition) {
2616    switch (qposition) {//toutes les position sur qtip2.com/demos#positioning
2617        case 'hautgauche':
2618            return {
2619                my : 'bottom right',
2620                at : 'top left'
2621            }
2622        case 'hautdroite':
2623            return {
2624                my : 'bottom left',
2625                at : 'top right'
2626            }
2627        case 'bas':
2628            return {
2629                my : 'top center',
2630                at : 'bottom center'
2631            }
2632        case 'centredroite':
2633            return {
2634                my : 'center left',
2635                at : 'center right'
2636            }
2637        case 'centregauche':
2638            return {
2639                my : 'top right',
2640                at : 'center left'
2641            }
2642        default:
2643            return {
2644                my : 'top left',
2645                at : 'bottom right'
2646            }
2647    }
2648}
2649
2650function initCarteSitesTouristiques() {
2651    if ($('#divMapSitesTour').length === 0 ) {
2652        return;
2653    }
2654    leaflet_loadLeafletAssets('getParamsMapSitesTour', 'classique', $('#divMapSitesTour').attr('data-widget'));
2655}
2656
2657function initLangueForDatePicker() {
2658    var langueBody = $('body').attr('data-langue') || '';
2659    if (langueBody.length > 0 || $('#datalangue').length > 0) {
2660        if ($('#datalangue').length > 0) {
2661            lang = $('#datalangue').val();
2662        } else {
2663            lang = $("body").attr('data-langue');
2664        }
2665        switch (lang) {
2666            case 'ANGLAIS':
2667                return; // on reste en cas par défaut sans traduction
2668            case 'ALLEMAND':
2669                lang = 'de';
2670                break;
2671            case 'HOLLANDAIS':
2672            case 'NEERLANDAIS':
2673                lang = 'nl';
2674                break;
2675            case 'ITALIEN':
2676                lang = 'it';
2677                break;
2678            case 'ESPAGNOL':
2679                lang = 'es';
2680                break;
2681            case 'PORTUGAIS':
2682                lang = 'pt';
2683                break;
2684            default:
2685                lang = 'fr';
2686        }
2687    }
2688    else {
2689        lang = $('html').attr('lang');
2690    }
2691    if (lang == undefined) {
2692        // 199653 : sinon on est en chinois, ca craint!
2693        lang = 'fr';
2694    }
2695    return lang;
2696}
2697
2698function switchSliderMobile(button, direction) {
2699    var parentDiv = $(button).closest('.div_sliderMobile');
2700    var parentBtn = parentDiv.find('.divInfosSlideNextPrev');
2701    parentBtn.removeClass('iteaStatMe_ALBUM_PHOTO');
2702    var allLi = parentDiv.find('ul.infosSlide li');
2703
2704    var currentLi = allLi.filter('.active');
2705    var currentIndex = allLi.index(currentLi);
2706
2707    var nextIndex;
2708    if (direction === 'next') {
2709        nextIndex = currentIndex + 1;
2710    } else {
2711        nextIndex = currentIndex - 1;
2712    }
2713
2714    // Gérer les limites (bouclage)
2715    if (nextIndex < 0) {
2716        nextIndex = allLi.length - 1;
2717    }
2718    if (nextIndex >= allLi.length) {
2719        nextIndex = 0;
2720    }
2721
2722    // Mettre à jour les classes actives
2723    allLi.removeClass('active');
2724    var newLi = allLi.eq(nextIndex);
2725    newLi.addClass('active');
2726    var pos = newLi.attr('data-pos');
2727
2728    parentDiv.find('.div_sliderMobileContent img').hide();
2729
2730    var photoAmontrer = parentDiv.find('.div_sliderMobileContent img[data-pos="' + pos + '"]');
2731    if (photoAmontrer.length > 0) {
2732        photoAmontrer.attr('src', photoAmontrer.attr('data-original'));
2733        photoAmontrer.show();
2734
2735        setHtmlLegendePhotoSlider(photoAmontrer.data('ident'), photoAmontrer.attr('title'));
2736
2737        var nextImg = photoAmontrer.next('img');
2738        if (nextImg.length > 0) {
2739            nextImg.attr('src', nextImg.attr('data-original'));
2740        }
2741    }
2742}
2743
2744function loadImgSliderMobilePos2() {
2745    //fiche 251411
2746    $('.div_sliderMobile').each(function () {
2747        var parentDiv = $(this);
2748
2749        setTimeout(function () {
2750            parentDiv.find('img[data-pos="2"]').each(function () {
2751                $(this).attr('src', $(this).attr('data-original'));
2752            });
2753        }, 3000);
2754    });
2755}
2756
2757
2758function setHtmlLegendePhotoSlider(ident,txt){
2759    if(txt==undefined){
2760        txt='';
2761    }    
2762    if($('.div_sliderMobileLegende[data-ident="'+ident+'"]').length>0){
2763        if(txt.length>0){
2764            $('.div_sliderMobileLegende[data-ident="'+ident+'"]').html('<div class="div_sliderMobileLegendeContent">'+txt+'</div>');
2765        }
2766        else{
2767            $('.div_sliderMobileLegende[data-ident="'+ident+'"]').html('');
2768        }
2769    }
2770}
2771
2772function trackPdfGoogleAnalytics() {
2773    $('a[href*=".pdf"]').each(function () {
2774        $(this).click(function() {
2775            ga('send', {
2776                hitType: 'event',
2777                eventCategory: 'PDF',
2778                eventAction: 'consultation',
2779                eventLabel: $(this).attr('href'),
2780            });
2781        });
2782    });
2783}
2784
2785function initForPanier_v5(){
2786    $('.a_valideAjoutBoutiqueV5').off('click');
2787    $('.a_valideAjoutBoutiqueV5').click(function(){
2788        var params = {
2789            action: 'ajoutePanier_v5',
2790            panier_v5: '1'
2791        };
2792        params.codeProd = $(this).attr("data-codeprod");
2793        params.idTarif = $(this).attr("data-idtarif");
2794        params.qte = $("#nbprod_"+params.idTarif ).val();
2795        var bouton = $(this);
2796        params.reload = bouton.attr('data-reload');
2797        $.ajax({
2798            type: "POST",
2799            url: "/lib_2/ajax/gerePanier.php",
2800            async: false,
2801            data: params,
2802            beforeSend: function(){                    
2803                var reload = bouton.attr('data-reload');
2804                if(reload){
2805                    moteur_affMessageLoadingMoteur();
2806                }
2807                else{
2808                    attenteInDiv($('#div_liste_panierHautNonDate'));                        
2809                }
2810            },
2811            success: function(retour){
2812                if ($('input[name="accesResa"]').val()=='O') {
2813                    location.href = retour;
2814                } 
2815                else {
2816                    var reload = bouton.attr('data-reload');
2817                    if(reload){
2818                        location.reload();
2819                    }
2820                    else{
2821                        if($('#div_liste_panierHautNonDate').length>0){
2822                            $('#div_liste_panierHautNonDate').html(retour);
2823                        }
2824                        if(typeof foncQdClick_a_valideAjoutBoutiqueV5 === 'function'){
2825                            foncQdClick_a_valideAjoutBoutiqueV5();
2826                        }
2827                    }
2828                }
2829            }
2830        });
2831    });    
2832    $('body').delegate('.boutiqueFNGF','click',function(){
2833        var codeProd = $(this).attr('data-codeprod');
2834        var idTarif = $('[name="choixTarifProdBoutique_'+codeProd+'"]').val();
2835        if(!idTarif){
2836            return;
2837        }
2838        var qte=1;
2839        if($('form.formAjoutPanierComplet .select_compoNbPers[data-code="'+codeProd+'"][data-idtarif="'+idTarif+'"]:visible').length > 0){
2840            qte = $('form.formAjoutPanierComplet .select_compoNbPers[data-code="'+codeProd+'"][data-idtarif="'+idTarif+'"]:visible').val();
2841        }
2842        var objParams = {
2843            codeProd: codeProd,
2844            idTarif: idTarif,
2845            qte: qte
2846        };
2847        ajouterAuPanierBoutique(objParams,null,window.majAffichagePanier);
2848    });    
2849    // évenement sur les selects de la div du panier (liste des produits dans le panier)
2850    $('body').delegate('.panier_detailsProduit .select_compoNbPers','change',function(){
2851        var objParams = {
2852            codeProd: $(this).data('code'),
2853            idTarif: $(this).data('idtarif'),
2854            qte: $(this).val(),
2855            action : 'setQuantite'
2856        };
2857        // on reload car il y a plein de choses à recharger (on est potentiellement sur la page de panier)
2858        ajouterAuPanierBoutique(objParams,null,window.majAffichagePanier);
2859    });
2860    
2861    // évenement sur la sélection d'un tarif 
2862    $('body').delegate('.formAjoutPanierComplet .selectIdTarifPourPanier', 'change', function () {
2863            var idTarif = $(this).val();
2864            $('.stockUnTarif .divTarifSelectQuantite').hide();
2865            $('.stockUnTarif .divTarifSelectQuantite[data-tarif="' + idTarif + '"]').slideDown('fast');
2866        });
2867    
2868    $('.a_enleveProdPanierV5').click(function(){
2869        var codeProd = $(this).attr("data-codeprod");
2870        var idTarif = $(this).attr("data-idtarif");
2871        
2872        $.ajax({
2873            type: "POST",
2874            url: "/lib_2/ajax/gerePanier.php",
2875            async: false,
2876            data: {
2877                panier_v5: "1",
2878                action: "supprimePanier_v5",
2879                codeProd: codeProd,
2880                idTarif: idTarif
2881            },
2882            beforeSend: function(){
2883                // TODO : afficher un loader?
2884            },
2885            success: function(){
2886                location.reload();
2887            }
2888        });
2889    });
2890    $(document).ready(function(){
2891        $('.boutiqueFNGF').each(function(){
2892            var codeProd = $(this).data('codeprod');
2893            var idTarif = $('[name="choixTarifProdBoutique_'+codeProd+'"]').val();
2894            if(!idTarif){
2895                $(this).addClass('pasDeStock');
2896                return;
2897            }
2898        });
2899    });    
2900    initDivAjoutPanierComplet();
2901    if(typeof foncQdFini_initForPanier_v5 === 'function'){
2902        foncQdFini_initForPanier_v5();
2903    }
2904}
2905
2906function initDivAjoutPanierComplet() {
2907    $(document).ready(function () {
2908        // si on a pas la div, on va pas plus loin
2909        if($('.formAjoutPanierComplet').length === 0){
2910            return;
2911        }
2912        $('.formAjoutPanierComplet .selectIdTarifPourPanier').trigger('change');
2913        // on traite le cas où il n'y a qu'un tarif dispo, on doit faire apparaitre le select de quantité
2914        if($('.formAjoutPanierComplet .inputIdTarifPourPanier').length > 0){
2915            $('.stockUnTarif .select_compoNbPers').show('fast');
2916        }
2917        $('.stockUnTarif').show('fast');
2918    });
2919}
2920
2921$(document).ready(function () {
2922    if ($('#iframe_vueChatIReflet').attr('data-page') !== 'FICHE' && !localStorage.getItem('chatOuvertAuto')) {
2923        return;
2924    }    
2925    const $el = $('#iframe_vueChatIReflet');
2926    const email = $el.attr('data-email');
2927    const langueBrute = navigator.language || navigator.userLanguage || 'fr'; 
2928    const langue = langueBrute.split('-')[0];
2929    const instance = $el.attr('data-instance');
2930
2931    const url = new URL('/chat-ireflet/', window.location.origin);
2932    url.searchParams.set('currentUrl', window.location.origin + window.location.pathname);
2933
2934    if (email) {
2935        url.searchParams.set('emailUser', email);
2936    }
2937    if (langue) {
2938        url.searchParams.set('langue', langue);
2939    }
2940    if (instance) {
2941        url.searchParams.set('instance', instance);
2942    }
2943
2944    const finalUrl = url.toString();
2945    $('#iframe_vueChatIReflet').attr('src', finalUrl);
2946    $('#iframe_vueChatIReflet').show();
2947});

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.