PageSourceSearch

https://www.thalgo.fr/site/templates/defaut/front/javascript/general.js?v=1790237408

js thalgo.fr collected 2026-09-26 04:05:27 UTC 53,544 bytes, 1,604 lines download raw bytes

1//OK:general.js front, after jquery.php ? ==> global.js
2var x,hrefs=[];
3var trad_pass = $('.trads_pass');
4
5$(document).ready(function(){
6	setInterval('changeaccroches()', 4000);
7    // Carrousel Produits
8	$('.owl-products').owlCarousel({
9		loop : $(this).length > 1 ? true : false,
10		autoplay : true,
11		nav : false,
12		dots : true,
13	    responsive : {
14	        0 : {
15	            items : 1
16	        },
17	        767 : {
18	            items : 3
19	        },
20	        991 : {
21	            items : 4
22	        },
23	        1199 : {
24	            items : 4
25	        }
26	    },
27	});
28
29	if($(window).width() < 992) {
30
31		var owl =  $('.owl-products-bloc .owl-products.owl-carousel');
32		owl.on('changed.owl.carousel', function(event) {
33			$('.owl-products-bloc.active .owl-nav').empty();
34			$('.owl-products-bloc.active .owl-nav').removeClass('disabled');
35			$('.owl-products-bloc.active .owl-nav').css('display', 'block');
36
37			$('.owl-products-bloc.active .owl-dots .owl-dot.active').find('span').css('background', '#006072');
38			$('.owl-products-bloc.active .owl-dots .owl-dot.active').prevAll('.owl-dot').find('span').css('background', '#006072');
39			$('.owl-products-bloc.active .owl-dots .owl-dot.active').nextAll('.owl-dot').find('span').css('background', '#61b0bc');
40
41			var avant = $('.owl-products-bloc.active .owl-dots .owl-dot.active').prevAll('.owl-dot').length + 1;
42			var items = $('.owl-products-bloc.active .owl-dots .owl-dot').length;
43			$('.owl-products-bloc.active .owl-nav').html(avant + "/" + items );
44			
45		})
46
47	}
48	
49
50	//Zoom photo produit
51	if ($(window).width() > 991) {
52		/*$('.photo_prod').elevateZoom({
53			zoomWindowFadeIn: 500,
54			zoomWindowFadeOut: 500,
55			lensFadeIn: 500,
56			lensFadeOut: 500
57			/* zoomWindowWidth: 120,
58            zoomWindowHeight: 120
59			
60		});*/
61    }
62//Not having axeptio
63if([2,3,11,31,34,38,32].indexOf(domain_id)<0){
64    if ($('#cookies').length > 0) {
65		$.cookieCuttr({
66			cookieDeclineButton					: false,
67			cookieAnalyticsMessage				: $('#cookieAnalyticsMessage').val(),
68			cookieWhatAreLinkText				: $('#cookieWhatAreLinkText').val(),
69			cookieDeclineButtonText				: $('#cookieDeclineButtonText').val(),
70			cookieAcceptButtonText				: $('#cookieAcceptButtonText').val(),
71			cookieWhatAreTheyLink				: $('#cookieWhatAreTheyLink').val(),
72			cookieNotificationLocationBottom	: true
73		});
74	}
75}
76/*
77	$(':checkbox').change(function() {
78    	if($(this).checked) {
79			$(this).val('Y');
80		} else {
81            $(this).val('N');
82		}
83	});
84*/
85    	// Animations
86/*
87	new WOW().init();
88*/
89	// Animation du Header
90/*
91	var currentPos = $(window).scrollTop();
92	var previousPos = currentPos;
93	if (currentPos > 10) {
94		$('#header').removeClass('active');
95	}
96	$('#header').hover(function() {
97		$(this).addClass('active');
98	}, function() {
99		if (currentPos > 10) {
100			$(this).removeClass('active');
101		}
102	});
103
104	$(window).scroll(function(event){
105		previousPos = currentPos;
106		currentPos = $(this).scrollTop();
107		if (currentPos < previousPos) {
108			dirScroll = 'up';
109		} else {
110			dirScroll = 'down';
111		}
112
113	   	if (dirScroll == 'down' && currentPos > 10) {
114			$('#header').removeClass('active');
115	   	} else if (dirScroll == 'up' && currentPos < 344) {
116			$('#header').addClass('active');
117		} else {
118//			$('#header').addClass('active');
119		}
120	})
121*/
122
123	// Dropdown Menu
124	var timerIn = 200;
125	var timerOut = 200;
126
127	if($(window).width() > 991) {
128	$('ul.nav li.dropdown').hover(function() {
129	    $(this).find('> .dropdown-menu').stop(true, true).fadeIn(timerIn);
130	    $(this).addClass('open');
131
132			if($(this).hasClass('niveau1megamenu')) {
133				$(this).find('> .dropdown-menu').css('display', 'flex');
134			}
135	}, function(e) {
136		if (!$(e.target).is('input')) {
137			$(this).find('> .dropdown-menu').stop(true, true).fadeOut(timerOut);
138			$(this).removeClass('open');
139		}
140	});
141}
142
143
144	/* Affichage du drapeau des langues */
145	if($(window).width() < 768 && $('.langs').length > 0) {
146		var langs_responsive = $('.langs').clone();
147        langs_responsive.appendTo($('.top'));
148        langs_responsive.css('position', 'absolute');
149        langs_responsive.css('top', '4px');
150        langs_responsive.css('right', '8px');
151	}
152	$('.lang, .lang a').mouseover(function(e) {
153		$('.langs ul').css('opacity', 0.99);
154	}, function(e) {
155		if($('.langs ul').css('opacity') != 1) {
156			e.stopImmediatePropagation();
157			$('.langs ul').css('opacity', 0);
158		}
159	});
160
161	if (!(document.getElementById('popup_panier') === null)) { // && localStorage.getItem('panier') != 'ignore') {
162		// Affichage du panier en cours à la connexion
163		popup_reprise_panier();
164	}
165
166	var alreadyLoaded = [];
167/*
168    $('.produits_menu_hover').each(function() {
169		var barremenu = false;
170    	//vérif si l'un des produits_suggestions a la classe rattachement, sinon charger le first
171        $(this).find('.produits_suggestions.rattachement').first().each(function() {
172        	var menuitems_id = $(this).attr('data-id');
173            //console.log('Charge:' + menuitems_id);
174			load_produits_menu(menuitems_id);
175			barremenu = true;
176		});
177
178		if(barremenu == false) {
179		    $(this).find('.produits_suggestions').first().each(function() { //vérif que le menuitems::first contient des produits !
180		        var menuitems_id = $(this).attr('data-id');
181                //console.log('Charge:' + menuitems_id);
182		        load_produits_menu(menuitems_id);
183			});
184		}
185	});
186
187	$('.produits_menu_hover').hover(
188		function() {
189		    $(this).find('.produits_suggestions.rattachement').each(function() {
190		 		//On recupere l'id du menuitem concerné
191		        var menuitems_id = $(this).attr('data-id');
192				if(alreadyLoaded.indexOf(menuitems_id) == -1) { //si ses produits n'ont pas déjà été chargés
193			        load_produits_menu(menuitems_id);
194                    //console.log('Charge:' + menuitems_id);
195			        alreadyLoaded.push(menuitems_id);
196		        } else {
197					//console.log(menuitems_id + ': déjà chargé');
198				}
199			});
200			var barremenu = false;
201            $(this).find('.produits_suggestions.rattachement').first().each(function() {
202				barremenu = true;
203            	$(this).find('.produits_menu').css('display', 'inline-flex');
204			});
205			if(barremenu == true) {
206                $(this).find('.produits_suggestions').first().each(function() {
207                	$(this).find('.produits_menu').css('display', 'inline-flex');
208				});
209			}
210		}
211	);
212
213	$('.produits_suggestions.rattachement').hover(
214		function() {
215	        var menuitems_id = $(this).attr('data-id');
216	        //console.log('Affiche:' + menuitems_id);
217	        $('.produits_menu_hover').find('.produits_menu').css('display', 'none');
218	        $(this).find('.produits_menu').css('display', 'inline-flex');
219		}, function() {
220		}
221	);
222*/
223
224	function popup_reprise_panier() {
225		bootbox.dialog({
226			title: $('#popup_panier').data('title'),
227		 	message: $('#popup_panier').data('message') ,
228		  	buttons: {
229		    	ignore: {
230			      	label: "Ignorer",
231					className	: 'btn-return',
232			      	callback: function() {
233			      		$.ajax({
234							type	: 'GET',
235							url		: lang_path + '/basket/ignore_panier/index.html?'+ $('#popup_panier').data('id'),
236							error	: function(msg) {
237								alert("Une erreur s'est produite.");
238							},
239							success	: function(data) {
240          						//localStorage.setItem('panier', data);
241							}
242						});
243					}
244		    	},
245		    	join: {
246			      	label: "Reprendre !",
247			      	callback: function(e) {
248			      		$('.spinner').css('display', 'block');
249			      		$.ajax({
250							type	: 'GET',
251							url		: lang_path + '/basket/reprise_panier/index.html?paniers_id='+ $('#popup_panier').data('id'),
252							error	: function(msg) {
253								alert("Erreur durant la requete .. auriez-vous cliqué deux fois ?");
254							},
255							success	: function(data) {
256								window.location.replace(data);
257							}
258						});
259			      	}
260		    	}
261		  	}
262		});
263		return false;
264	}
265
266	$('.ga').on('click', function (e) {
267		google_analytics($(this).data('ga-ctx'), ($(this).data('ga-name') ? $(this).data('ga-name') : ''));
268	});
269
270    $('.reprise_panier').on('click', function(e) {
271      	$.ajax({
272			type	: 'GET',
273			url		: lang_path + '/basket/reprise_panier/index.html?paniers_id=' + $(this).attr('data-id'),
274			error	: function(msg) {
275				alert("Erreur durant la requete .. auriez-vous cliqué deux fois ?");
276			},
277			success	: function(data) {
278				console.log(data);
279				window.location.replace(data);
280			}
281		});
282	});
283
284	/**
285	 * Actions reatives au Menu
286	 */
287
288	 // Recalcul du background du bloc menu right
289     var menu_width = $(window).width() - ($('.nav-menu').offset().left + $('.nav-menu').outerWidth());
290	 $('.menu_left').width(menu_width);
291     $('.menu_right').width(menu_width);
292	 $('.menu_left').css('left', '-' + menu_width + 'px');
293	 $('.menu_right').css('right', '-' + menu_width + 'px');
294
295	 //Supression de l'ombre quand le menu se déploie
296
297
298	// Initialisation du menu
299	$('.nav-menu .nav').find('.sousmenu').parent().each(function(){
300		var liparent = $(this);
301		var submenu = $(this).find('.sousmenu');
302		var timerIn = 200;
303		var timerOut = 200;
304
305		//var alink = $(this).find('a:eq(0)');
306		$(this).hover(
307			function(){
308				submenu[0].style.display='flex';return;
309				//console.log('cp1');
310				//alink.addClass('menuselected');
311				//liparent.addClass('menuselected');
312				submenu.fadeIn(timerIn);
313			},
314			function(){
315				submenu[0].style.display='none';return;
316                //console.log('cp2');
317				submenu.fadeOut(timerOut);
318				//alink.removeClass('menuselected');
319				//liparent.removeClass('menuselected');
320			}
321		);
322	});
323
324	$('#header-search-deploiement').on('click', function() {
325		if ($(this).hasClass('deploye')) {
326			$(this).removeClass('deploye');
327			$('#search-deploiement').hide(200);
328		} else {
329			$(this).addClass('deploye');
330			$('#search-deploiement').show(200);
331		}
332	});
333
334	// Gestion du panel gauche (clic)
335/*
336	$('#header-menu-deploiement').on('click', function() {
337        $('#menu-deploiement').height($(window).height() - $('#header').height());
338  	 	$('#menu-deploiement').show();
339  	 	$('#menu-deploiement-black').show();
340    	$('#menu-deploiement').animate({left: '0'},{duration: "slow"});
341
342        // Si je veux ouvrir le menu
343        //$('#header-menu-deploiement').hide();
344		//$('#header-menu-deploiement-close').show();
345    	//$('#header-menu-deploiement-close').animate({right: '80%'},{duration: "slow"});
346        $('#header-menu-deploiement').animate({left: '80%'},{duration: "slow"});
347
348	});
349*/
350
351	// Si je veux fermer le menu
352/*
353	$('#header-menu-deploiement-close').on('click', function() {
354        $('#menu-deploiement').animate({left: '-80%'},{duration: "slow"});
355
356		$('#header-menu-deploiement-close').hide();
357		$('#header-menu-deploiement').show();
358    	$('#header-menu-deploiement').animate({right: '0'},{duration: "slow"});
359
360	});
361*/
362/*
363    $("#header-menu-deploiement").toggle(function() {
364	//	$('#menu-deploiement').height($(window).height() - $('#header').height());
365  	 	$('#menu-deploiement').show();
366  	 	$('#menu-deploiement').animate({left: '0'},{duration: "slow"});
367        $('#header-menu-deploiement').animate({left: '83%'},{duration: "slow"});
368        //$('#header .top').toggleClass('fixed');
369        //$('#header-menu-deploiement').toggleClass('fixed');
370        //$('.head').css('margin-top', $('#header .top').outerHeight(true));
371	}, function() {
372	  	$('#menu-deploiement').animate({left: '-80%'},{duration: "slow"});
373		$('#header-menu-deploiement').animate({left: '24px'},{duration: "slow"});
374        //$('#header .top').toggleClass('fixed');
375        //$('#header-menu-deploiement').toggleClass('fixed');
376        //$('.head').css('margin-top', 0);
377	});
378*/
379    // Menu mobile
380/*
381	$('#menu-deploiement li.niveau1').on('click', function(e) {
382    	$(this).toggleClass('open');
383	});
384
385    $('#menu-deploiement a').on('click', function(e) {
386		var alink = $(this);
387		var li = alink.parent();
388		var submenu = li.find('ul:eq(0)');
389
390		// Si je clique sur un lien qui a une sous arborescence :
391		// - si c'est mon premier clic sur ce lien (classe clicked non présente) :
392		if (submenu.length > 0 && !alink.hasClass('clicked')) {
393			e.preventDefault(); // Je désactive le clic
394			alink.addClass('clicked'); // J'ajoute la classe clicked
395			li.addClass('menuselected');
396
397			// Je masque les autres arborescences
398			alink.parents('.niveau1').siblings().each(function() {
399				$(this).find('.clicked, .menuselected').removeClass('clicked menuselected');
400				$(this).find('ul').hide();
401			});
402
403			alink.parents('.niveau1submenu').siblings().each(function() {
404				$(this).find('.clicked, .menuselected').removeClass('clicked menuselected');
405				$(this).find('ul').hide();
406			});
407
408			// Je déroule la sous arborescence
409			submenu.show();
410
411			if ($('body').hasClass('shifter')) {
412				$('#barre_menu').animate({scrollTop: li.offset().top});
413			}
414
415  		}
416
417
418	});
419
420	$('.deploiement_menu').on('click', function() {
421		$('#barre_menu').slideToggle();
422		return false;
423	});
424
425	*/
426    // Initialisation des champs Dates
427    init_dates();
428
429	// Carrousel Avantages
430	/*$('.avantages .owl-avantages').owlCarousel({
431		loop : false,
432		autoplay : false,
433		nav : $(window).width() < 992 ? true : false,
434		navText : ["<img src='" + site_img_path + "/ico-arrow-left.png'>", "<img src='" + site_img_path + "/ico-arrow-right-footer.png'>"],
435		dots : false,
436	    responsive : {
437	        0 : {
438	            items : 1
439	        },
440	        600 : {
441	            items : 2
442	        },
443	        1000 : {
444	            items : 4
445	        }
446	    }
447	});
448
449	if($(window).width() > 599){
450		$('.avantages .owl-prev').css('left', 0);
451		$('.avantages .owl-next').css('right', 0);
452	}*/
453
454	// Sélecteur de langues
455	$('.footer-signature ul.dropdown-menu').css('top', '-' + parseInt($('.footer-signature ul.dropdown-menu').height() + 10) + 'px');
456
457    /*
458	* Gestion du commentaire de la popup
459	**/
460	$('.box_oui').on('click', function() {
461		if ($(this).hasClass('checked')) {
462			$(this).removeClass('checked');
463			$('.box_non').addClass('checked');
464			$('textarea').slideUp();
465			$('input.cadeau').attr('value','false');
466			$('input.message').attr('value','');
467		} else {
468			$(this).addClass('checked');
469			$('.box_non').removeClass('checked');
470			$('textarea').slideDown();
471			$('input.cadeau').attr('value','true');
472			$('input.message').attr('value',$('textarea').val());
473		}
474	});
475	$('.box_non').on('click', function() {
476		if ($(this).hasClass('checked')) {
477			$(this).removeClass('checked');
478			$('.box_oui').addClass('checked');
479			$('textarea').slideDown();
480			$('input.cadeau').attr('value','true');
481			$('input.message').attr('value',$('textarea').val());
482		} else {
483			$(this).addClass('checked');
484			$('.box_oui').removeClass('checked');
485			$('textarea').slideUp();
486			$('input.cadeau').attr('value','false');
487			$('input.message').attr('value','');
488		}
489	});
490	$('.box_textarea').on('change', function() {
491		$('input.message').attr('value',$('textarea').val());
492	});
493	$('.box_textarea').on('keyup', function() {
494		$('input.message').attr('value',$('textarea').val());
495	});
496
497	$('.popup_panier .right a, .popup_panier .fermer a, .popup_panier .left a').on('click', function(e) {
498		e.preventDefault();
499		$('input.redirect').attr('value',$(this).attr('href'));
500		$('form.forms_panier').submit();
501	});
502	// Récupération du plus grand height dans le footer
503	height = 0;
504	$('.footer-menu ul.nav > li ul.footer-menu-list').each(function() {
505		if (height < $(this).height()) {
506			height = $(this).height();
507		};
508		$(this).height(height);
509	});
510
511	/*
512	*	Fonction relatives aux avis des produits
513	*/
514	var regex_avis = new RegExp('^avis-verifies$');
515
516	if ($('.produit_ref').length > 0 && $('.allowed_avis').length > 0 && regex_avis.test($('.allowed_avis').val())) {
517        $.each($('.produit_ref'), function() {
518			if ($(this).attr('data-ref').length > 0 && $(document).find('.avis_verifies_avis').length > 0) {
519				console.log("dddd");
520            var produits_globals = [];
521    		var produits_globals_number = 0;
522            var obj_produit = $(this);
523			var produits_ref = $(this).attr('data-ref');
524
525			//On explose la chaine a chaque virgules pour obtenir toutes les references précédentes.
526			var produits_ref = produits_ref.split(",");
527			var number_of_ref = produits_ref.length;
528			var produits_id = $('.produits_id').val();
529			if (produits_id === undefined) {
530				produits_id = $(this).attr('data-produits_id');
531			}
532
533			var prod_id = $(this).find('a').attr('href');
534
535			if (domain_id == 2) {
536				var key = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9';
537				if (produits_id !== undefined) {
538					var url_average = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/AVERAGE/' + produits_id + '.json';
539				} else {
540					var url_average = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json';
541				}
542				
543				var url_reviews = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
544			} else if (domain_id == 3) {
545				var key = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f';
546				if (produits_id !== undefined) {
547				var url_average = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/AVERAGE/' + produits_id + '.json' ;
548				} else {
549					var url_average = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json' ;
550				}
551				var url_reviews = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
552			} else if (domain_id == 31) {
553				var key = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84';
554				if (produits_id !== undefined) {
555					var url_average = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/AVERAGE/' + produits_id + '.json' ;
556				} else {
557					var url_average = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json' ;
558				}
559				var url_reviews = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
560			}
561
562			var url_de_base = url_average;
563			if (prod_id !== undefined && produits_id === undefined) {
564				var values=prod_id.split('#');
565				url_average = key + '/AWS/PRODUCT_API/AVERAGE/' + values[1] + '.json';
566			} else if (produits_id !== undefined)  {
567				url_average = key + '/AWS/PRODUCT_API/AVERAGE/' + produits_id + '.json';
568			}
569
570			var filtre = '';
571			var resultat_error = '';
572			
573			//$.each(produits_ref, function( key, value ) {
574				//Recuperation des avis globaux
575				$.ajax({
576					//url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/e297a919-adec-ea24-4d0f-34c77fc82660/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json',
577                    //url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/ec5ac29f-f244-e084-1941-253fc1ca1404/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json',
578                    url : url_average,
579					type : 'GET',
580					dataType : 'json',
581					async : false,
582					success : function(data, statut){
583						fill_global(data,number_of_ref, obj_produit, produits_globals, produits_globals_number);
584					},
585					error : function(resultat, statut, erreur){
586						resultat_error = true;
587						//fill_global(false,number_of_ref, obj_produit, produits_globals, produits_globals_number);
588					}
589				});
590			//});
591			
592			//if (resultat_error == true) {
593				url_average = key + '/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json' ;
594				console.log(url_average);
595				//$.each(produits_ref, function( key, value ) {
596				//Recuperation des avis globaux
597				$.ajax({
598					//url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/e297a919-adec-ea24-4d0f-34c77fc82660/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json',
599                    //url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/ec5ac29f-f244-e084-1941-253fc1ca1404/AWS/PRODUCT_API/AVERAGE/' + produits_ref + '.json',
600                    url : url_average,
601					type : 'GET',
602					dataType : 'json',
603					success : function(data, statut){
604						fill_global(data,number_of_ref, obj_produit, produits_globals, produits_globals_number);
605					},
606					error : function(resultat, statut, erreur){
607						//fill_global(false,number_of_ref, obj_produit, produits_globals, produits_globals_number);
608					}
609				});
610			//});
611			//} 
612
613
614            if (obj_produit.hasClass('produit_ref_detail')) {
615	            //$.each(produits_ref, function( key, value ) {
616					//Recuperation des avis detail
617					$.ajax({
618						//url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/e297a919-adec-ea24-4d0f-34c77fc82660/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json',
619	                    //url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/ec5ac29f-f244-e084-1941-253fc1ca1404/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json',
620	                    url : url_reviews,
621						type : 'GET',
622						dataType : 'json',
623						success : function(data, statut){
624							fill_detail(data,number_of_ref,filtre);
625						},
626						error : function(resultat, statut, erreur){
627							var resultat_err = resultat.statusText;
628							//fill_detail(false,number_of_ref,filtre);
629						}
630					});
631				//});
632
633				console.log(url_reviews);
634				//if (resultat_err == 'error') {
635					url_reviews = key + '/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json';
636					$.ajax({
637						//url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/e297a919-adec-ea24-4d0f-34c77fc82660/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json',
638						//url : 'https://cl.avis-verifies.com/fr/cache/e/2/9/ec5ac29f-f244-e084-1941-253fc1ca1404/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json',
639						url : url_reviews,
640						type : 'GET',
641						dataType : 'json',
642						success : function(data, statut){
643							fill_detail(data,number_of_ref,filtre);
644						},
645						error : function(resultat, statut, erreur){
646							var resultat_err = resultat.statusText;
647							//fill_detail(false,number_of_ref,filtre);
648						}
649					});
650				//}
651			}
652		
653		}
654
655        });
656
657		
658	}
659
660    $('.ajout_listing:not(.t)').addClass('t').unbind().click(function(e) {
661    	//cl(this);//Safari :: Type Error
662		e.preventDefault();
663        ajout_listing($(this).parents('.actions').find('.forms_panier'));
664	});
665
666    $('.ajout_favoris').on('click', function(e) {
667    	e.preventDefault();
668     	ajout_favoris($(this).parents('#ariane').find('.forms_favoris'), $(this).parents('#ariane').find('.forms_favoris .produits_id').val());
669	});
670
671	$('.retrait_favoris').on('click', function(e) {
672	    e.preventDefault();
673	    retrait_favoris($(this).parents('#ariane').find('.forms_favoris'), $(this).parents('#ariane').find('.forms_favoris .produits_id').val());
674	});
675
676	$('.login_favoris').on('click', function(e) {  //Ajout de favs sans être connecté
677	    e.preventDefault();
678        $.ajax({
679			type	: 'GET',
680			url			: $(document).find('.forms_favoris').attr('action'),
681	        data		: $(document).find('.forms_favoris').serialize(),
682			error	: function(msg) {
683				alert('error: '+msg);
684			},
685			success	: function(data) {
686				$('.spinner').css('display', 'none');
687				if (data) {
688					 window.location.replace(data);
689	            }
690			}
691		});
692	});
693
694	$('.forms_panier_principal .btn-small').on('click', function(e) {
695    	e.preventDefault();
696		directAddFavoris($(this));
697	});
698 
699	$(document).on('click', '.avis_colonne_gauche .informations', function() {
700		var produits_ref = $(document).find('.produit_ref_detail').attr('data-ref');
701		var number_of_ref = $(this).find('div').attr('class');
702
703		var produits_id = $('.produits_id').val();
704	
705		//On explose la chaine a chaque virgules pour obtenir toutes les references précédentes.
706		if (domain_id == 2) {
707			var url_reviews = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
708		} else if (domain_id == 3) {
709			var url_reviews = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
710		} else if (domain_id == 31) {
711			var url_reviews = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
712		}
713		
714		$.ajax({
715			url : url_reviews,
716			type : 'GET',
717			dataType : 'json',
718			success : function(data, statut){
719				fill_detail(data,number_of_ref);
720			},
721		});
722
723		if (domain_id == 2) {
724			var url_reviews = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json';
725		} else if (domain_id == 3) {
726			var url_reviews = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json';
727		} else if (domain_id == 31) {
728			var url_reviews = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/REVIEWS/' + produits_ref + '.json';
729		}
730
731		$.ajax({
732			url : url_reviews,
733			type : 'GET',
734			dataType : 'json',
735			success : function(data, statut){
736				fill_detail(data,number_of_ref);
737			},
738		});
739
740	});
741
742	$(document).find('#liste_attributs').on('change','.select_attribut', function() {
743		var produit = $(this).find('option:selected').text();
744		var ref = produit.split(" ");
745		$('.produit_ref_detail').attr('data-ref', ref[0]);
746
747		var number_of_ref = 1;
748		
749		var filtre = '';
750
751		var produits_id = $('.produits_id').val();
752	
753		if (domain_id == 2) {
754			var url_reviews = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/REVIEWS/' + ref[0] + '.json';
755		} else if (domain_id == 3) {
756			var url_reviews = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/REVIEWS/' + ref[0] + '.json';
757		} else if (domain_id == 31) {
758			var url_reviews = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/REVIEWS/' + ref[0] + '.json';
759		}
760
761		$.ajax({
762			url : url_reviews,
763			type : 'GET',
764			dataType : 'json',
765			success : function(data, statut){
766				fill_detail(data,number_of_ref,filtre);
767			},
768		});
769
770
771		//On explose la chaine a chaque virgules pour obtenir toutes les references précédentes.
772		if (domain_id == 2) {
773			var url_reviews = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
774		} else if (domain_id == 3) {
775			var url_reviews = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
776		} else if (domain_id == 31) {
777			var url_reviews = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
778		}
779		
780		$.ajax({
781			url : url_reviews,
782			type : 'GET',
783			dataType : 'json',
784			success : function(data, statut){
785				fill_detail(data,number_of_ref,filtre);
786			},
787		});
788
789	});	
790
791	$(document).on('change', '#filtrer_avis', function() {
792		var produits_ref = $(document).find('.produit_ref_detail').attr('data-ref');
793		$('.informations > div').each(function() {
794			if ($(this).css('opacity') == 1) {
795				var number_of_ref = $(this).find('div').attr('class');
796			}
797		});
798
799		var produits_id = $('.produits_id').val();
800		if ( typeof number_of_ref === 'undefined') {
801			var number_of_ref = 1;
802		}
803		
804		var filtre = $(this).val();
805	
806		if (domain_id == 2) {
807			var url_reviews = 'https://cl.avis-verifies.com/fr/cache/1/d/e/1de9fee1-afb2-5124-69cd-26780e6ad8b9/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
808		} else if (domain_id == 3) {
809			var url_reviews = 'https://cl.avis-verifies.com/gb/cache/f/d/3/fd386fc7-98b0-87f4-9988-7fca9f6b242f/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
810		} else if (domain_id == 31) {
811			var url_reviews = 'https://cl.avis-verifies.com/es/cache/1/d/a/1da704f0-32df-8164-ad48-335730425a84/AWS/PRODUCT_API/REVIEWS/' + produits_id + '.json';
812		}
813
814		$.ajax({
815			url : url_reviews,
816			type : 'GET',
817			dataType : 'json',
818			success : function(data, statut){
819				fill_detail(data,number_of_ref,filtre);
820			},
821		});
822	});
823
824	//Fonction permettante de remplir un tableau qui contiendra toutes les notes
825	//globales des versions du produit et d'appeler l'affichage en front une foi
826	//que toutes les refs sont récupérées.
827	function fill_global(data, number_of_ref, obj, produits_globals, produits_globals_number){
828		if (data != false) {
829			produits_globals.push(data);
830			produits_globals_number++;
831		} else {
832			produits_globals_number++;
833		}
834
835		
836		if (produits_globals_number == number_of_ref){
837        	changer_data_global(produits_globals, obj);
838		}
839	}
840
841	//Fonction permettante de remplir un tableau qui contiendra toutes les commentaires
842	//detailes des versions du produit et d'appeler l'affichage en front une foi
843	//que toutes les refs sont récupérées.
844
845	/*function fill_detail(data,number_of_ref){
846		if (data != false){
847			$.each(data, function( key, value ) {
848				produits_details.push(value);
849			});
850			produits_details_number ++;
851		} else {
852			produits_details_number ++;
853		}
854		if (produits_details_number == number_of_ref){
855			produits_details.sort(function(a,b){
856			  return new Date(b.review_date) - new Date(a.review_date);
857			});
858			changer_data_detail(produits_details);
859		}
860	}*/
861
862	function fill_detail(data,number_of_ref,filtre){
863		var produits_details = [];
864		var produits_details_number = 0;
865		if (data != false){
866			$.each(data, function( key, value ) {
867				if (number_of_ref != 1) {
868					$('.avis_block').empty();
869					var note_retenue = number_of_ref.replace('note', '');
870					for (i=0; i < 6; i++) {
871						if (i == note_retenue) {
872							$('.informations .note'+i).css('opacity', '1');
873						} else {
874							$('.informations .note'+i).css('opacity', '0.20');
875						}
876					}
877					if (value.rate == note_retenue) {
878						produits_details.push(value);
879					}
880				} else {
881					produits_details.push(value);
882				}
883				
884			});
885			produits_details_number ++;
886		} else {
887			produits_details_number ++;
888		}
889
890
891		number_of_ref = 1;
892
893		console.log(produits_details);
894		if (produits_details_number == number_of_ref){
895			if (filtre == '' || filtre == 'newest') {
896				produits_details.sort(function(a,b){
897					return new Date(b.review_date) - new Date(a.review_date);
898				  });
899			} else if (filtre == 'oldest') {
900				produits_details.sort(function(a,b){
901					return new Date(a.review_date) - new Date(b.review_date);
902			});
903			} else if (filtre == 'highest') {
904				produits_details.sort(function(a,b){
905					return b.rate - a.rate;
906			});
907			} else if (filtre == 'lowest') {
908				produits_details.sort(function(a,b){
909					return a.rate - b.rate;
910			});
911			}
912
913			console.log(produits_details);
914			changer_data_detail(produits_details,filtre);
915		}
916	}
917
918	//Parser le json si string recuperer si non ok
919	/*function changer_data_global(produits_globals, obj) {
920		var count = 0;
921		var rate = 0;
922		$.each(produits_globals, function( key, value ) {
923			count = count + parseInt(value.count, 10);
924			rate = rate + parseFloat(value.rate, 10);
925		});
926		rate = rate / produits_globals.length;
927
928		//On recupere l'url de l'image pour les étoiles
929		//var src_short = $('.note_generale .note img').attr('src');
930		//src_short = src_short.substring(0, src_short.indexOf('etoiles_'));
931		//var src_full = src_short + 'etoiles_' + Math.round(rate) + '.png';
932
933	    //On remplit nos champs
934		//$('.nb_avis p span').text(count);
935	    //$('.note_generale .note img').attr('src', src_full);
936		//$('.note_generale .note .note_texte .chiffre').text(Math.round(rate));
937	    obj.find('.nb_avis_total').text(count);
938
939		if (domain_id == 9999) {
940		
941			let jsonLdScript = document.querySelector('script[type="application/ld+json"]');
942			let jsonld = JSON.parse(jsonLdScript.innerText);
943
944			jsonld.aggregateRating.ratingValue = count;
945			jsonld.aggregateRating.ratingCount = rate;
946
947		}
948		
949		console.log(rate);
950
951	    obj.find('.stars').html('');
952	    for ($i=0; $i < 5; $i++) {
953			if ($i < Math.round(rate)) {
954				obj.find('.stars').html(obj.find('.stars').html() + '<i class="fa fa-star" aria-hidden="true"></i>');
955	    	} else {
956				obj.find('.stars').html(obj.find('.stars').html() + '<i class="fa fa-star-o" aria-hidden="true"></i>');
957			}
958		}
959	} */
960
961		//Parser le json si string recuperer si non ok
962		function changer_data_global(produits_globals, obj) {
963			var count = 0;
964			var rate = 0;
965			$.each(produits_globals, function( key, value ) {
966				count = count + parseInt(value.count, 10);
967				rate = rate + parseFloat(value.rate, 10);
968			});
969			rate = (rate / produits_globals.length).toFixed(1);
970
971			if ($('.note_moyenne .note').length > 0) {
972				$('.note_moyenne .note').text(rate);
973				//if ($('.total_avis .tot').text() == '') {
974					$('.total_avis .tot').text(count);
975				//}		
976			}
977	
978			console.log(count);
979			//On recupere l'url de l'image pour les étoiles
980			obj.find('.nb_avis_total').text(count);
981		
982			obj.find('.stars').html('');
983			for ($i=0; $i < 5; $i++) {
984				if ($i < Math.round(rate)) {
985					obj.find('.stars').html(obj.find('.stars').html() + '<i class="fa fa-star" aria-hidden="true"></i>');
986				} else {
987					obj.find('.stars').html(obj.find('.stars').html() + '<i class="fa fa-star-o" aria-hidden="true"></i>');
988				}
989			}
990		}
991
992	/*var first_detail = true;
993	function changer_data_detail(data) {
994		if (data.length) {
995			$('#produits_avis').show();
996	        $('.avis_block').empty();
997			//On vie le cadre si aucun témoignage n'est présent
998		/*
999			if($('.temoignages_liste').find('.vide') && first_detail == true){
1000				$('.temoignages_liste').text('');
1001			}
1002		
1003			first_detail = false;
1004			for (key in data) {
1005				//On recupere l'url de l'image pour les étoiles
1006				//var src_short = $('.note_generale .note img').attr('src');
1007				//src_short = src_short.substring(0, src_short.indexOf('etoiles_'));
1008				//var src_full = src_short + 'etoiles_' + Math.round(data[key].rate) + '.png';
1009
1010				//On récupere le text de la note générale (qui est le meme pour l'avis)
1011				var note_texte = $('.note_generale .note .note_texte').text();
1012				//var after_str = note_texte.substring(1, 100);
1013				//var str_full = Math.round(data[key].rate) + after_str;
1014
1015				//On récupère la date au format correct
1016				var format_date = data[key].review_date;
1017				if(!format_date){cl(data,key);continue;}
1018				var format_date = format_date.substring(0, format_date.lastIndexOf(' '));
1019				var format_date = format_date.split("-");
1020				var format_date = format_date[2] + "/" + format_date[1] + "/" + format_date[0];
1021
1022	/*
1023				$('.temoignages_liste').append(
1024					'<div class="temoignage remplit">' +
1025						'<div class="temoignage_content">' +
1026							'<p class="temoignage_auteur_date">' + data[key].lastname + '.' + data[key].firstname + ' : ' + format_date + '</p>' +
1027							'<p class="temoignage_message">' + data[key].review + '</p>' +
1028						'</div>' +
1029						'<div class="temoignage_note">' +
1030							'<p class="note"><img src="' + src_full + '" alt="" /><span class="note_texte">' + str_full + '</span></p>' +
1031						'</div>' +
1032					'</div>'
1033				);
1034	
1035
1036		        stars = '';
1037				for ($i=0; $i < 5; $i++) {
1038					if ($i < data[key].rate) {
1039						stars = stars + '<i class="fa fa-star" aria-hidden="true"></i>';
1040					} else {
1041						stars = stars + '<i class="fa fa-star-o" aria-hidden="true"></i>';
1042					}
1043				}
1044
1045				$('.avis_block').append(
1046			        '<div class="avi_block">' +
1047			            '<hr>' +
1048			            '<div class="head">' +
1049			                '<p class="designation">' + $('.produit_ref').find('.designation').html() + '</p>' +
1050			                '<p class="note">' +
1051			                    '<span class="stars">' + stars + '</span>' +
1052			                '</p>' +
1053			            '</div>' +
1054			            '<p class="commentaire">' + data[key].review + '</p>' +
1055		             	'<p class="utilisateur">' +
1056			                '<span class="identite">' + data[key].lastname + '.' + data[key].firstname + '</span>, ' +
1057			                '<span class="date">' + format_date + '</span>' +
1058			            '</p>' +
1059			        '</div>'
1060				);
1061			}
1062		} else {
1063            //$('.voir_avis').hide().
1064            $('.voir_avis').css('cursor', 'text');
1065            $('.voir_avis').on('click', function(e) { //Ajout de favs sans être c
1065onnecté
1066	   			e.preventDefault();
1067			});
1068		}
1069
1070
1071	} */
1072
1073	var first_detail = true;
1074	function changer_data_detail(data,filtre) {
1075		if (data.length) {
1076			$('#produits_avis').show();
1077			if (filtre != '') {
1078				$('.avis_block').empty();
1079			}
1080
1081			//On vie le cadre si aucun témoignage n'est présent
1082
1083			first_detail = false;
1084			if ($('.note_moyenne .note').length > 0) {
1085				var note = [];
1086				if($('.note5').attr('nombre_avis')) {
1087					note[5] = parseInt($('.note5').attr('nombre_avis'));
1088				} else {
1089					note[5] = 0;
1090				}
1091
1092				if($('.note4').attr('nombre_avis')) {
1093					note[4] = parseInt($('.note4').attr('nombre_avis'));
1094				} else {
1095					note[4] = 0;
1096				}
1097
1098				if($('.note3').attr('nombre_avis')) {
1099					note[3] = parseInt($('.note3').attr('nombre_avis'));
1100				} else {
1101					note[3] = 0;
1102				}
1103				
1104				if($('.note2').attr('nombre_avis')) {
1105					note[2] = parseInt($('.note2').attr('nombre_avis'));
1106				} else {
1107					note[2] = 0;
1108				}
1109
1110				if($('.note1').attr('nombre_avis')) {
1111					note[1] = parseInt($('.note1').attr('nombre_avis'));
1112				} else {
1113					note[1] = 0;
1114				}
1115
1116				if($('.note0').attr('nombre_avis')) {
1117					note[0] = parseInt($('.note0').attr('nombre_avis'));
1118				} else {
1119					note[0] = 0;
1120				}
1121
1122			}
1123
1124
1125
1126
1127			for (key in data) {
1128
1129
1130				if ($('.note_moyenne .note').length > 0) {
1131
1132					if (data[key].rate == 5) {
1133						note[5] += 1;
1134					} else if (data[key].rate == 4) {
1135						note[4] += 1;
1136					} else if (data[key].rate == 3) {
1137						note[3] += 1;
1138					} else if (data[key].rate == 2) {
1139						note[2] += 1;
1140					} else if (data[key].rate == 1) {
1141						note[1] += 1;
1142					}
1143
1144
1145
1146				}
1147
1148				
1149				//On récupere le text de la note générale (qui est le meme pour l'avis)
1150				var note_texte = $('.note_generale .note .note_texte').text();
1151
1152				//On récupère la date au format correct
1153				var format_date = data[key].review_date;
1154				if(!format_date){cl(data,key);continue;}
1155				var format_date = format_date.substring(0, format_date.lastIndexOf(' '));
1156				var format_date = format_date.split("-");
1157				if (format_date[0] == '2020') {
1158					format_date[0] = '2022';
1159				}
1160				var format_date = format_date[2] + "/" + format_date[1] + "/" + format_date[0];
1161
1162				var order_date = data[key].order_date;
1163				var order_date = order_date.substring(0, order_date.lastIndexOf(' '));
1164				var order_date = order_date.split("-");
1165				if (order_date[0] == '2020') {
1166					order_date[0] = '2022';
1167				}
1168				var order_date = order_date[2] + "/" + order_date[1] + "/" + order_date[0];
1169
1170
1171	
1172				stars = '';
1173				for ($i=0; $i < 5; $i++) {
1174					if ($i < data[key].rate) {
1175						stars = stars + '<i class="fa fa-star" aria-hidden="true"></i>';
1176					} else {
1177						stars = stars + '<i class="fa fa-star-o" aria-hidden="true"></i>';
1178					}
1179				}
1180
1181				$('.avis_block').append(
1182					'<div class="avi_block">' +
1183						'<hr>' +
1184						'<div class="head" style="margin-bottom:10px;">' +
1185							'<p class="note">' +
1186								'<span class="stars" style="color: #FFCD00 !important;font-size:20px">' + stars + '</span> <span style="font-size:18px;">'+data[key].rate+'/5</span>' +
1187							'</p>' +
1188						'</div>' +
1189						'<p class="commentaire" style="margin-bottom:10px;">' + data[key].review + '</p>' +
1190						 '<p class="utilisateur">' +
1191							'<span class="identite" style="font-weight:100">' + data[key].lastname + '.' + data[key].firstname + '</span>, ' +
1192						'</p>' +
1193					'</div>'
1194				);
1195			}
1196
1197
1198			if ($('.note_moyenne .note').length > 0) {
1199				var count = parseInt($(document).find('.total_avis > .tot').text());
1200				count  = isNaN(count) ? 1 : count;
1201				var pourcent_total = ((note[5] + note[4] + note[3] ) / count) *100;
1202				if (filtre == '') {
1203					$('.pourcentage_avis').find('.percent').text(parseInt(pourcent_total) + '%');
1204				}
1205			}
1206
1207			for (i=0; i < 6; i++) {
1208				if (filtre == '') {
1209					var pourcent = [];
1210					pourcent[i] = Math.round((note[i] / count) *100);
1211					$('.note'+i).find('.perc_rate').text(pourcent[i] + '%');
1212					$('.note'+i).attr('nombre_avis', note[i]);
1213					$('.note'+i).find('.pourcent_bar').css('background', 'linear-gradient(to right, rgb(173, 173, 173) '+pourcent[i]+'%, rgb(216, 216, 216) '+pourcent[i]+'%)');
1214					if (pourcent[i] > 0) {
1215						$('.note'+i).parent('.informations').css('cursor', 'pointer');
1216					}
1217				}	
1218			}
1219
1220		} else {
1221			//$('.voir_avis').hide().
1222			if ($("#produits_avis").css('display') == 'none'){
1223				$('.avis_verifies_avis').css('display', 'none');
1224			}
1225			$('.voir_avis').css('cursor', 'text');
1226			$('.voir_avis').on('click', function(e) { //Ajout de favs sans être c
1226onnecté
1227				   e.preventDefault();
1228			});
1229		}
1230	}
1231
1232
1233	function retrait_favoris(form, produits_id) {
1234		$('.spinner').css('display', 'block');
1235		$.ajax({
1236			type	: 'GET',
1237			url			: form.attr('action'),
1238	        data		: form.serialize(),
1239			error	: function(msg) {
1240				alert('error: '+msg);
1241			},
1242			success	: function(data) {
1243				$('.spinner').css('display', 'none');
1244				if (data) {
1245					if (form.closest('tr').length > 0) {
1246						form.closest('tr').css('display', 'none');
1247					}
1248					$('.ajout_favoris' + produits_id).attr('style', 'display: block !important');
1249	                $('.retrait_favoris' + produits_id).hide();
1250				    $('.actionFav_'+produits_id).attr('value', 'add');
1251	            }
1252			}
1253		});
1254	}
1255
1256	function ajout_favoris(form, produits_id) {
1257		$('.spinner').css('display', 'block');
1258		console.log(form.serialize());
1259		$.ajax({
1260			type	: 'GET',
1261			url			: form.attr('action'),
1262	        data		: form.serialize(),
1263			error	: function(msg) {
1264				alert(msg);
1265			},
1266			success	: function(data) {
1267				$('.spinner').css('display', 'none');
1268				console.log(data);
1269				if(data) {
1270			        $('.retrait_favoris' + produits_id).attr('style', 'display: block !important');
1271	                $('.ajout_favoris' + produits_id).hide();
1272			        $('.actionFav_' + produits_id).attr('value', 'remove');
1273				}
1274	   		}
1275		});
1276	}
1277
1278	/* Fermer la pop-up d'achat */
1279	$('.close_popup').live('click',function(){
1280		$('.popup_panier').hide();
1281	});
1282
1283	$('.fermer').live('click',function(){
1284		$('.popup_panier').hide();
1285	});
1286
1287	/* Supprime le bloc AJAX */
1288	$('.close_ajax_box').live('click',function(){
1289		$(this).parents('.ajax_box').remove();
1290	    $('.overlay_bg').hide();
1291	});
1292
1293	/* Supprime le bloc AJAX en responsive */
1294	$('.close_ajax_box_cross').live('click',function(){
1295		$(this).parents('.ajax_box').remove();
1296	    $('.overlay_bg').hide();
1297	});
1298
1299	/* Traitement de la pagination */
1300    $('.page-select').change(function(){
1301        if ($('.table-nav').data('link').indexOf('index.html') > 0) {
1302            document.location = $('.table-nav').data('link') + '&nbpg=' + $(this).val();
1303        } else {
1304            document.location = $('.table-nav').data('link') + 'index.html?nbpg=' + $(this).val();
1305        }
1306    });
1307    $('.page-nav').click(function(){
1308        if ($('.table-nav').data('link').indexOf('index.html') > 0) {
1309            document.location = $('.table-nav').data('link') + '&pg=' + $(this).data('page');
1310        } else {
1311            document.location = $('.table-nav').data('link') + 'index.html?pg=' + $(this).data('page');
1312        }
1313    });
1314    $('.page-input').change( function(){
1315        var curpage = parseInt($(this).val());
1316        var maxpage = parseInt($('.maxpage').html());
1317        if (curpage < 1) curpage = 1;
1318        if (curpage > maxpage) curpage = maxpage;
1319        $(this).val(curpage);
1320        document.location = $('.table-nav').data('link') + 'index.html?&pg=' + curpage;
1321    });
1322//
1323	x=document.querySelectorAll('a[data-toggle][href]');//forEach(function(e){e.onclick=function(x){if(desktop){location.href=e.href;}};/*cl(e,e.href);*/})
1324	for(var i in x){
1325		if(typeof x[i] == 'object'){
1326			//cl(i,typeof x[i],x[i],typeof(x[i].href));
1327			if(typeof(x[i].href)!='undefined'){
1328				hrefs.push(x[i].href);
1329				if(desktop) {//0,0,x[i] => 0,this,event		x[i]=> event, undefined,undefind
1330					x[i].onclick = function(el,e){//.bind(0,x[i]);
1331						cl(e,el);
1332						location.href = correctUrl(el.href);
1333					}.bind(0,x[i]);
1334				}
1335			}
1336		}
1337		//forEach(function(e){e.onclick=function(x){if(desktop){location.href=e.href;}};/*cl(e,e.href);*/})
1338	}
1339	//cl('a[data-toggle][href]',hrefs);
1340	btnPlusMinus();
1341	$('.btn-rupture').parent('p').hover(function(){
1342		$(this).find('span').css('display','block');
1343	},
1344		function(){
1345		$(this).find('span').css('display','none');
1346	}
1347	);
1348
1349	$('input[name=utilisateurs_password], #moncompte_connexion input[name=password]').after('<i class="fa fa-eye show-password"></i>');
1350
1351	$('.show-password').on('click', function() {
1352		var x = $('input[name=utilisateurs_password]');
1353		console.log(x.length);
1354		if (x.length == 0) {
1355			var x = $('#moncompte_connexion input[name=password]');
1356		}
1357		console.log(x.length);
1358		if (x.attr('type') == "password") {
1359			x[0].setAttribute("type", "text");
1360		} else {
1361			x[0].setAttribute("type", "password");
1362		}
1363 	});
1364	
1365});//end jqready
1366
1367$(window).load(function() {
1368	if ($('.basket-left').length == 0) {
1369	 $.ajax({
1370		type	: 'GET',
1371		url		: '/basket/count_basket/index.html',
1372		error	: function(msg) {
1373			alert(msg);
1374		},
1375		success	: function(data) {
1376			console.log(data);
1377			// Affiche le contenu du fichier dans le conteneur dédié
1378			var tab = data.split(',');
1379			if (tab[0] == 'connexion') {
1380				$('.connexion').hide();
1381				$('.deconnexion').show();
1382				if (('.ajout_favoris').length > 0) {
1383					$('.login_favoris').show();
1384					$('.ajout_favoris').hide();
1385					$('.retrait_favoris').hide();
1386				}
1387			}
1388			else {
1389				$('.deconnexion').hide();
1390				$('.connexion').show();
1391				$('.my-account .dropdown-menu').html('<li><p class="nav-desc"><a href="/account/logout/">Déconnexion</a></p></li>');
1392				if (('.ajout_favoris').length > 0) {
1393					$('.login_favoris').hide();
1394					$('.ajout_favoris').show();
1395					$('.retrait_favoris').show();
1396				}
1397			}
1398			$('.head-basket span').text(tab[1]);
1399			if (tab[1] > 1 ) {
1400				var art = 'Articles';
1401			} else {
1402				var art = 'Article';
1403			}
1404			 
1405			$('.menu-refonte .nav-title i').text(tab[1] + ' ' + art);
1406		}
1407	});
1408}
1409});
1410
1411function load_produits_menu(menuitems_id) {
1412    //On appelle la methode AJAX qui recupère les produits du menuitem
1413    $('.produits_menu .spinner').css('display', 'inline-block');
1414    $.ajax({
1415		type	: 'GET',
1416		url		: lang_path + '/produits/suggestions/index.html?menuitems_id='+menuitems_id,
1417		error	: function(msg) {
1418			//alert("Erreur durant la requete .. auriez-vous cliqué deux fois ?");
1419		},
1420		success	: function(data) {
1421			$('.produits_menu .spinner').css('display', 'none');
1422		    if (data) {
1423		    	$('#menuitem-'+menuitems_id).find('.produits_menu').empty();
1424		        $('#menuitem-'+menuitems_id).find('.produits_menu').append(data);
1425		    }
1426		    //$('produits_menu').load(lang_path + '/tpl_layout_header.php');
1427		}
1428	});
1429}
1430
1431/**
1432 * Actions relatives aux champs Dates
1433 */
1434function init_dates() {
1435    $('.date-picker').datepicker({
1436        autoclose: true,
1437        language: lang
1438    });
1439}
1440
1441function google_analytics(context, name) {
1442	if (typeof ga !== 'undefined') {
1443        ga('require', 'ecommerce');
1444        switch (context) {
1445            case 'carrousel':
1446    			ga('send', 'event', 'button', 'Clic', 'Lien', name);
1447				break;
1448
1449			case 'document':
1450    			ga('send', 'event', 'button', 'Téléchargement', 'PDF', name);
1451				break;
1452
1453			case 'newsletter':
1454    			ga('send', 'event', 'button', 'Clic', 'Bouton', 'Inscription newsletter');
1455				break;
1456
1457			case 'panier':
1458            	ga('send', 'event', 'button', 'Clic', 'Bouton', 'Ajouter au panier');
1459				break;
1460
1461			/*
1462			case 'transaction':
1463	            ga('ecommerce:addTransaction', {
1464				  'id': '1234',
1465				  'affiliation': 'Acme Clothing',
1466				  'revenue': '11.99',
1467				  'shipping': '5',
1468				  'tax': '1.29',
1469				  'currency': 'EUR'
1470				});
1471
1472	            ga('ecommerce:addItem', {
1473				    'id': '1234',
1474				    'name': 'Fluffy Pink Bunnies',
1475				    'sku': 'DD23444',
1476				    'category': 'Party Toys',
1477				    'price': '11.99',
1478				    'quantity': '1',
1479				    'currency': 'EUR'
1480				});
1481	            ga('ecommerce:send');
1482				break;
1483			*/
1484		}
1485	}
1486}
1487
1488
1489function ajout_listing(form) {
1490	$('.spinner').css('display', 'block');
1491	$.ajax({
1492		type	: 'GET',
1493		url			: form.attr('action'),
1494		data		: form.serialize(),
1495		error	: function(msg) {
1496			cl('errror',msg);
1497		},
1498		success	: function(data) {
1499			//cl({success:1,data});
1500			$('.spinner').css('display', 'none');
1501			console.log(data);
1502			if (data) {
1503				$('.popup_panier').empty();
1504				$('.popup_panier').append(data);
1505				$('.popup_panier').css('display', 'block');
1506
1507				/*
1508                * Gestion du commentaire de la popup
1509                **/
1510				$('.box_oui').on('click', function() {
1511					if ($(this).hasClass('checked')) {
1512						$(this).removeClass('checked');
1513						$('.box_non').addClass('checked');
1514						$('textarea').slideUp();
1515						$('input.cadeau').attr('value','false');
1516						$('input.message').attr('value','');
1517					} else {
1518						$(this).addClass('checked');
1519						$('.box_non').removeClass('checked');
1520						$('textarea').slideDown();
1521						$('input.cadeau').attr('value','true');
1522						$('input.message').attr('value',$('textarea').val());
1523					}
1524				});
1525				$('.box_non').on('click', function() {
1526					if ($(this).hasClass('checked')) {
1527						$(this).removeClass('checked');
1528						$('.box_oui').addClass('checked');
1529						$('textarea').slideDown();
1530						$('input.cadeau').attr('value','true');
1531						$('input.message').attr('value',$('textarea').val());
1532					} else {
1533						$(this).addClass('checked');
1534						$('.box_oui').removeClass('checked');
1535						$('textarea').slideUp();
1536						$('input.cadeau').attr('value','false');
1537						$('input.message').attr('value','');
1538					}
1539				});
1540				$('.box_textarea').on('change', function() {
1541					$('input.message').attr('value',$(this).val());
1542				});
1543				$('.box_textarea').on('keyup', function() {
1544					$('input.message').attr('value',$(this).val());
1545				});
1546
1547				$('.popup_panier .right a, .popup_panier .fermer a, .popup_panier .left a').on('click', function(e) {
1548					e.preventDefault();
1549					$('input.redirect').attr('value',$(this).attr('href'));
1550					$('form.forms_panier_message').submit();
1551				});
1552
1553				btnPlusMinus();
1554			}
1555		}
1556	});
1557}
1558
1559function directAddFavoris(elem){
1560	console.log(elem.closest('.produit-add-popin'));
1561	elem.next().fadeIn(800);
1562	$.ajax({
1563		type	: 'GET',
1564		url		: elem.closest('.forms_panier_principal').attr('action') + '?' + elem.closest('.forms_panier_principal').serialize(),
1565		error	: function(msg) {
1566		},
1567		success	: function(data) {
1568			elem.next().fadeOut(800);
1569		}
1570	});
1571}
1572
1573$(document).on('keyup', 'input[name="utilisateurs_password"]', function() {
1574	var txtInput = $(this).val();
1575	var regPass =  new RegExp("^(?=.*?[A-Z])(?=.*?[#?!@$%^&*-_])");
1576	if (txtInput.length > 7) {
1577	  if (!regPass.test(txtInput)) {
1578		$('.help-pass').html(trad_pass.data('majspe'));
1579		$('.center .btn-thalgo, .valider_informations').attr("disabled", 'disabled');
1580	  } else {
1581		var atCount = $(this).val().replace(/[^@]/g, "").length;
1582		if (atCount > 1) {
1583			$('.help-pass').html(trad_pass.data('uncar'));
1584			$('.center .btn-thalgo, .valider_informations').attr("disabled", 'disabled');
1585		} else {
1586			$('.help-pass').html("");
1587			$('.center .btn-thalgo, .valider_informations').removeAttr('disabled');
1588		}
1589	  }
1590	} else {
1591		$('.help-pass').html(trad_pass.data('sizeletter'));  
1592		$('.center .btn-thalgo, .valider_informations').attr("disabled", 'disabled');
1593	}
1594  });
1595
1596  function changeaccroches(){
1597      var $active = $('.bandeau_promo_haut .active');
1598      var $next = ($active.next().length > 0) ? $active.next() : $('.bandeau_promo_haut a:first');
1599      $active.fadeOut(1500,function(){
1600	  $active.removeClass('active');	
1601	  $next.show();
1602	  $next.addClass('active');
1603      });
1604}

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.