/* Minification failed. Returning unminified contents.
(108,6): run-time error JS1004: Expected ';'
(111,23): run-time error JS1004: Expected ';'
(119,22): run-time error JS1004: Expected ';'
(251,6): run-time error JS1004: Expected ';'
(252,24): run-time error JS1004: Expected ';'
(267,24): run-time error JS1004: Expected ';'
 */
function onBegin()
{
    $("#divLoading").removeClass('d-none');
    $('#searchBtn').prop("disabled", true);  
}

function onComplete()
{
    $("#divLoading").addClass('d-none');
    $('#searchBtn').prop("disabled", false);   
}

function onSuccess(context)
{
    //var d = new Date();
    //var day = d.getDate();
    //var month = d.getMonth() + 1;
    //var year = d.getFullYear();
    //$("#divLoading").html("Live rates at " + day + "." +
    //month + "." + year + " " + d.getHours() + ":" +
    //d.getMinutes() + ":" + d.getSeconds());
}

$(function () {
    //function doSearch(pButton)
    //{
    //    $("#divLoad").removeClass('d-none');
    //    var sHref = $(pButton).data('request-url');
    //    var searchText = $("#search_query_top").val();
    //    if (searchText == null || searchText == "")
    //        searchText = getParameterByName('s');
    //    var hasSearch = (searchText != null && searchText != "");
    //    var page = 1;

    //    if (hasSearch)
    //        sHref += "?s=" + searchText;

    //    var listFiltre = [];
    //        $("input.filtre:checkbox:checked").each(function () {
    //            listFiltre.push($(this).attr('filtre'));
    //    });
    //    if (listFiltre.length > 0) {
    //        if (hasSearch) {
    //            sHref += "&";
    //        }
    //        else {
    //            sHref += "?";
    //        }
    //        sHref += "filter=" + listFiltre.join("|");
    //    }

    //    window.location.href = window.location.origin + sHref;
    //}

    //function getParameterByName(name, url) {
    //    if (!url) url = window.location.href;
    //    name = name.replace(/[\[\]]/g, "\\$&");
    //    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    //        results = regex.exec(url);
    //    if (!results) return null;
    //    if (!results[2]) return '';
    //    return decodeURIComponent(results[2].replace(/\+/g, " "));
    //}

    //$("#searchBtn").click(function () {
    //    $("#searchBtn").attr('disabled', true);
    //    $("#searchBtn").attr('disabled', true);
    //    $("#divLoading").removeClass("d-none")
    //    $("#divLoading").css('display', 'true');
        
    //    doSearch();
    //});

    //$('#sSearch').keypress(function (e) {
    //    if (e.key == 'Enter') {
    //        $("#divLoading").removeClass("d-none")
    //        $("#divLoading").css('display', 'true');
    //        doSearch();
    //        //window.location.href = $("#searchBtn").attr("href");
    //    }
    //});

	$("#filtreBtn").click(function (e) {
        $("#searchBtn").attr('disabled', true);
        $("#filtreBtn").attr('disabled', true);
        $("#divLoad").removeClass("d-none")
		$("#divLoad").css('display', 'true');
        doFilter("#filtreBtn");
    });

    //$(".btnPerPage").click(function (e) {
    //    $("#searchBtn").attr('disabled', true);
    //    $("#filtreBtn").attr('disabled', true);
    //    $("#divLoad").removeClass("d-none")
    //    $("#divLoad").css('display', 'true');
    //    doFilter("#filtreBtn");
    //});
});

function changeQtePerPage() {
    $("#searchBtn").attr('disabled', true);
    $("#filtreBtn").attr('disabled', true);
    $("#divLoad").removeClass("d-none")
    $("#divLoad").css('display', 'true');
    doFilter("#filtreBtn");
}

async function loadFrontPage (type, block){
	const isFr = window.location.href.indexOf("/fr/") > 0;
	const lang = isFr ? "fr" : "en";
	const request = await fetch(`/${lang}/Catalog/ListeFrontPage?mode=${type}`,
		{
			method: 'GET',
			headers: {
				'Accept': 'application/json',
			}
		});
	
	const result = await request.text();
	return {block: block, value: result};
}

function changePage(pageNo) {
    doFilter(pageNo);
}

function doFilter(pageNo) {
    $("#divLoad").removeClass('d-none');
    var sHref = $("#searchBtn").data('request-url');
    var searchText = $("#search_query_top").val();
    if (searchText == null || searchText == "")
        searchText = getParameterByName('s');
    var hasFirst = (searchText != null && searchText != "");

    if (hasFirst)
        sHref += "?s=" + searchText;

    var listFiltre = [];
    $("input.filtre:checkbox:checked").each(function () {
        listFiltre.push($(this).attr('filtre'));
    });

    if (pageNo && pageNo > 0) {
        if (hasFirst) {
            sHref += "&";
        }
        else {
            sHref += "?";
            hasFirst = true;
        }
        sHref += "page=" + pageNo;
    }

    if (window.location.href.indexOf('Mode=') > 0) {
        var valeur = window.location.href.substr(window.location.href.indexOf('Mode='), 6);
        var mode = "";

        if (valeur.indexOf("=P") > 0) {
            mode = "Promo";
        }
        else if (valeur.indexOf('=L') > 0) {
            mode = "Liquidation";
        }
        else {
            mode = "Nouveaute";
        }

        if (hasFirst) {
            sHref += "&";
        }
        else {
            sHref += "?";
            hasFirst = true;
        }
        sHref += "Mode=" + mode;
    }

    if (listFiltre.length > 0) {
        if (hasFirst) {
            sHref += "&";
        }
        else {
            sHref += "?";
            hasFirst = true;
        }
        sHref += "filter=" + listFiltre.join("|");
    }

    if ($("#filterAvailabilityAvailable").prop("checked")) {
        if (hasFirst) {
            sHref += "&";
        }
        else {
            sHref += "?";
            hasFirst = true;
        }
        sHref += "enStock=1";
    }

    if ($("#ItemPerPage") && $("#ItemPerPage").val() > 0) {
        if (hasFirst) {
            sHref += "&";
        }
        else {
            sHref += "?";
            hasFirst = true;
        }
        sHref += "ItemParPage=" + $("#ItemPerPage").val();
    }

    location.assign(window.location.origin + sHref);
    return false;
};
(function( $ ) {

	//Function to animate slider captions 
	function doAnimations( elems ) {
		//Cache the animationend event in a variable
		var animEndEv = 'webkitAnimationEnd animationend';
		
		elems.each(function () {
			var $this = $(this),
				$animationType = $this.data('animation');
			$this.addClass($animationType).one(animEndEv, function () {
				$this.removeClass($animationType);
			});
		});
	}
	
	//Variables on page load 
    var $myCarousel = $('#carousel-ccigo'),
		$firstAnimatingElems = $myCarousel.find('.item:first').find("[data-animation ^= 'animated']");
		
	//Initialize carousel 
	$myCarousel.carousel();
	
	//Animate captions in first slide on page load 
	doAnimations($firstAnimatingElems);
	
	//Pause carousel  
	//$myCarousel.carousel('pause');
	
	
	//Other slides to be animated on carousel slide event 
	$myCarousel.on('slide.bs.carousel', function (e) {
		var $animatingElems = $(e.relatedTarget).find("[data-animation ^= 'animated']");
		doAnimations($animatingElems);
	});  
	
})(jQuery);;
async function handleLogin(username, password, popup, toastContainer) {
	const response = await fetch("/fr/Account/Login", {
		method: "POST",
		headers: {'Content-Type': 'application/json'},
		body: JSON.stringify({
			email: username,
			password: password,
			isPopup: popup,
		})
	});

	if (response.ok)
		$('#dialogLogin').dialog('close');
	else {
		if(toastContainer.trim() !== "")
		{
			const result = await response.json();
			const container = document.querySelector(toastContainer);
			const toast = new Toasty('error', result.statusText);
			container.appendChild(toast.displayToast());
		}
	}
}

function logout() {
	$.ajax({
		url: '/fr/Account/Logout',
		type: 'POST',
		dataType: 'html',
		success: function (result) {
			SetCartGuid("");
			document.location.href = "/";
		}
	});
}
;
let ToastType;
(function (ToastType) {
	ToastType["success"] = "success";
	ToastType["error"] = "error";
	ToastType["warning"] = "warning";
})(ToastType || (ToastType = {}));
class Toasty {
	/**
	 * @param {string |success|error|warning } type toast type
	 * @param {string} message toast message
	 */
	constructor(type, message) {
		this.type = type;
		this.element = document.createElement('div');
		this.element.classList.add("toasts");
		this.element.classList.add("show");
		this.element.classList.add(this.type);
		this.element.innerHTML = message;
	}
	/** Add the fade css class to the div */
	addFade() {
		this.element.classList.add("fade");
	}
	/**
	 *
	 * @return {object} div containing the div object
	 */
	displayToast() {
		setTimeout(() => { this.addFade(); }, 3000);
		setTimeout(() => { this.element.remove(); }, 5000);
		return this.element;
	}
};
document.addEventListener('click', (e) => {
	const isDropdownButton = e.target.matches("[data-dropdown-button]");
	const isSubDropdownButton = e.target.matches("[data-sub-dropdown-button]");
	if (!isSubDropdownButton && !isDropdownButton &&
		(e.target.closest("[data-dropdown]") != null) &&
		(e.target.closest("[data-sub-dropdown]") != null))
	{
		return;
	}

	document.querySelectorAll("[data-sub-dropdown].active").forEach(dropdown => {
		dropdown.classList.remove("active");
	})
	document.querySelectorAll("[data-dropdown].active").forEach(dropdown => {
		dropdown.classList.remove("active");
	})

	let currentDropdown;
	let currentSubDropdown;
	if (isDropdownButton || isSubDropdownButton) {
		currentDropdown = e.target.closest("[data-dropdown]");
		currentDropdown.classList.add("active");

		if (isSubDropdownButton) {
			currentSubDropdown = e.target.closest("[data-sub-dropdown]")
			currentSubDropdown.classList.add("active");
		}
	}
});
$(function () {
	$(".IdPays").change(function () {
		const val = $(this).val();
    var idProv = $(this).attr("subLookup");
		
		var subItems = "";
		$.getJSON("/fr/Base/GetProvince", { id: val }, function (data) {
			$.each(data, function (index, item) {
                subItems += "<option value='" + item.Value + "'>" + item.Text + "</option>"
            });
            $("#" + idProv).html(subItems)
        });
    });
});

//$(function () {
//    $("#username").on('change keyup paste', function ()
//    {
//        var sUsername = $("#username").val();
//        if (sUsername.length > 3 && sUsername.trim() !== "")
//        {
//            // Perform the ajax post
//            $.post("/fr/Account/ValiderNomUtilisateur", { "pUser": sUsername },
//                function (data)
//                {
//                    if (data === 'success')
//                    {
//                        $("#isValid").attr("src", "/Images/valide.png");
//                    }
//                    else {
//                        $("#isValid").attr("src", "/Images/invalide.png");
//                    }
//                });
//        }
//        else
//        {
//            $("#isValid").attr("src", "/Images/invalide.png");
//        }
//    });
//});

//Code facebook
$(function (d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/fr_FR/sdk.js#xfbml=1&version=v2.9";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


function addRequestVerificationToken(data) {
    data.__RequestVerificationToken = $('input[name=__RequestVerificationToken]').val();
    return data;
};

function addProduitCard(btn) {

	const cartGuid = GetCartGuid();
	const idToCart = $(btn).attr("data-id");

	$.ajax({
		url: '/fr/Base/GetCartGuid',
		type: 'GET',
		data: { currentGuid: cartGuid, canCreateNew: true },
		contentType: 'application/json;',
		success: function (data) {
			SetCartGuid(data);
			addToCart(data, idToCart);
		}
	});	
}

function addToCart(cartGuid, idToCart) {
	let dQte = 1;
	if ($("#qte-" + idToCart).length) {
		dQte = $("#qte-" + idToCart).val();
	}
	//Validation du multiple s'il en a un
	if ($('#MultipleAchat').length) {
		var multiplier = $('#MultipleAchat').text();
		var win = $(window);
		var height = win.height() * 0.9;
		var width = 460;

		if (win.width < 480) {
			width = 440;
		}
		if (win.width <= 360) {
			width = 300;
		}

		if (dQte % multiplier !== 0) {
			$("#dialogError").removeClass("d-none");
			$("#dialogError").dialog({
				modal: true,
				width: width,
				resizable: false,
				draggable: false,
				position: ["center", 20],
				show: "blind",
				hide: "blind",
				create: function (event) {
					$(event.target).parent().css({
						'position': 'fixed',
						'left': (win.width() - width) / 2,
						'top': (win.height() - width) / 2,
						'overflow-y': 'auto',
						'max-height': height
					});
				},
				open: function (event) {
					$('body').addClass('stop-scrolling');
				},
				close: function (event, ui) {
					$('body').removeClass('stop-scrolling');
				},
			});
		}
		else {
			$("#dialogError").addClass("d-none");

			if (idToCart !== '') {
				////if ($("#qte-" + idToCart).length) {
				////	dQte = $("#qte-" + idToCart).val();
				////}
				//$.post("/fr/ShoppingCart/AddToCart", { "id": idToCart, "qte": dQte, "addFromList": true },
				//	function (data) {
				//		if (data === 'success') {
				//			flyToElement($('#item-' + idToCart + ' div[class="itemCard"]'), $('#cartBtn'));
				//		}
				//	});
				//SetCount();
				$.ajax({
					url: '/fr/ShoppingCart/AddToCart',
					type: 'POST',
					contentType: "application/json; charset=utf-8",
					data: JSON.stringify({ "idInv": idToCart, "qte": dQte, "addFromList": true }),
					success: function (data) {
						if (data === 'success') {
							//flyToElement($('#item-' + idToCart), $('#btnPanier'));
							//SetCount();
							const cartGuid = GetCartGuid();
							GetCountItems(cartGuid);
						}
					}
				});
			}
		}
	}
	else if (idToCart !== '') {
		////var dQte = 1;
		////if ($("#qte-" + idToCart).length) {
		////	dQte = $("#qte-" + idToCart).val();
		////}
		//$.post("/fr/ShoppingCart/AddToCart", { "id": idToCart, "qte": dQte, "addFromList": true },
		//	function (data) {
		//		if (data === 'success') {
		//			flyToElement($('#item-' + idToCart + ' div[class="itemCard"]'), $('#cartBtn'))
		//		}
		//	});
		$.ajax({
			url: '/fr/ShoppingCart/AddToCart',
			type: 'POST',
			contentType: "application/json; charset=utf-8",
			data: JSON.stringify({ "idInv": idToCart, "qte": dQte, "addFromList": true }),
			success: function (data) {
				if (data === 'success') {
					//flyToElement($('#item-' + idToCart), $('#btnPanier'));
					//SetCount();
					var cartGuid = GetCartGuid();
					GetCountItems(cartGuid);
				}
			}
		});
		
	}
}

//Vieille fonction
//function addProduitCard(btn) {
//	if ($("#ClientAccount").length) {
//	//if ($("#isConnect").val() == "true") {
//        // Get the id from the link
//		var idToCart = $(btn).attr("data-id");
//		var dQte = 1;
//		if ($("#qte-" + idToCart).length) {
//			dQte = $("#qte-" + idToCart).val()
//		};
//		//Validation du multiple s'il en a un
//        if ($('#MultipleAchat').length)
//        {
//			var multiplier = $('#MultipleAchat').text();
//			var win = $(window);
//			var height = win.height() * 0.9;
//			var width = 460;

//			if (win.width < 480) {
//				width = 440;
//			}
//			if (win.width <= 360) {
//				width = 300;
//			}
			
//			if (dQte % multiplier != 0) {
//				$("#dialogError").removeClass("d-none");
//				$("#dialogError").dialog({
//					modal: true,
//					width: width,
//					resizable: false,
//					draggable: false,
//					position: ["center", 20],
//					show: "blind",
//					hide: "blind",
//					create: function (event) {
//						$(event.target).parent().css({
//							'position': 'fixed',
//							'left': (win.width() - width) / 2,
//							'top': (win.height() - width) / 2,
//							'overflow-y': 'auto',
//							'max-height': height
//						});
//					},
//					open: function (event) {
//						$('body').addClass('stop-scrolling');
//					},
//					close: function (event, ui) {
//						$('body').removeClass('stop-scrolling');
//					},
//				});
//			}
//			else {
//				$("#dialogError").addClass("d-none");

//				if (idToCart !== '') {
//					//if ($("#qte-" + idToCart).length) {
//					//	dQte = $("#qte-" + idToCart).val();
//					//}
//					var addFromList = true;
//					$.post("/fr/ShoppingCart/AddToCart", { "id": idToCart, "qte": dQte, "addFromList": addFromList },
//						function (data) {
//							if (data === 'success') {
//								flyToElement($('#item-' + idToCart + ' div[class="itemCard"]'), $('#cartBtn'))
//							}
//                        });
//                    SetCount();
//				}
//			}
//		}
//		else if (idToCart !== '') {
//			//var dQte = 1;
//			//if ($("#qte-" + idToCart).length) {
//			//	dQte = $("#qte-" + idToCart).val();
//			//}
//			var addFromList = true;
//			$.post("/fr/ShoppingCart/AddToCart", { "id": idToCart, "qte": dQte, "addFromList": addFromList},
//                    function (data) {
//                        if (data === 'success') {
//							flyToElement($('#item-' + idToCart + ' div[class="itemCard"]'), $('#cartBtn'))
//                        }
//                });
//            SetCount();
//        }
//    } //Pas connecter
//    else {
//		var oParam = this;
//		var win = $(window);
//        //Affichage du popup
//        $.ajax({
//			url: '/fr/Account/PopUpLogin',
//			data: { pLogin: undefined },
//			type: 'POST',
//            dataType: 'html'
//        }).success(function (result) {
//            //Affichage du popup
//            $('#dialogLogin').html(result);

//            $("#dialogLogin").dialog({
//                modal: true,
//                width: 'auto',
//                resizable: false,
//                draggable: false,
//				position: ["center", 20],
//                show: "blind",
//                hide: "blind",
//                title: "",
//                create: function (event) {
//                    $(event.target).parent().css({
//						'position': 'fixed',
//						'left': (win.width() - $(this).parent().outerWidth()) / 2,
//						'top': (win.height() - $(this).parent().outerHeight()) / 2,
//						'overflow-y': 'auto',
//						'max-height': win.height() * 0.9
//					});
//				},
//				open: function (event) {
//					$('body').addClass('stop-scrolling');
//				},
//				close: function (event, ui) {
//					location.reload(true);
//				},
//            });
//        });
//    }
//};

function loginPopup(gotoControllerParam, gotoActionParam) {
	const lang = (window.location.href.indexOf('/fr/')) > 0 ? 'fr' : 'en';
	if ($("#ClientAccount").length === 0) {
		let win = $(window);
		//Affichage du popup
		$.ajax({
			url: `/${lang}/Account/PopUpLogin`,
			data: { pLogin: undefined, gotoController: gotoControllerParam, gotoAction: gotoActionParam },
			type: 'POST',
			dataType: 'html',
			success: function (result) {
				//Affichage du popup
				$('#dialogLogin').html(result);

				$("#dialogLogin").dialog({
					modal: true,
					width: 'auto',
					resizable: false,
					draggable: false,
					position: ["center", 20],
					show: "blind",
					hide: "blind",
					title: "",
					create: function (event) {
						$(event.target).parent().css({
							'position': 'fixed',
							'left': (win.width() - $(this).parent().outerWidth()) / 2,
							'top': (win.height() - $(this).parent().outerHeight()) / 2,
							'overflow-y': 'auto',
							'max-height': win.height() * 0.9
						});
					},
					open: function (event) {
						$('body').addClass('stop-scrolling');
					},
					close: function (event, ui) {
						location.reload();
					},
				});
			}
		});
	}
}


function SetCartGuid(guid) {
    if (Modernizr.localstorage) {
        const localCartGuid = window.localStorage;
		const cartToken = JSON.stringify(guid);
		localCartGuid.setItem("cartGuid", cartToken);

        return true;
    }
    else
        return false;
}

function GetCartGuid() {
    if (Modernizr.localstorage) {
        const localData = window.localStorage;
		let cartGuid = JSON.parse(localData.getItem("cartGuid"));
		if (cartGuid === null) {
			cartGuid = '';
		}
		return cartGuid;
    }
    else
        return '';
}

function GetWebUserId() {
	return new Promise((resolve, reject) => {
		$.ajax({
			url: '/fr/Base/GetWebUserId',
			type: 'GET',
			contentType: 'application/json;',
			success: function (data) {
				resolve(data);
			},
			error: function (error) {
				reject('')
			},
		})
	})
}

function SetCount() {
	var cartText = $("#btnPanier").text();
	var cartGuid = GetCartGuid();

	$.ajax({
		url: '/fr/Home/GetCountItems',
		type: 'POST',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify({ "cartGuid": cartGuid }),
		success: function (data) {

			if (data !== null && data !== "failed") {
				//Set the count of items
				if (data > 0) {
					var start_pos = cartText.indexOf("(") + 1;
					var text_before = cartText.substring(0, start_pos - 1);
					//$("#btnPanier").text(text_before + " (" + data + ")");
					if (location.href.indexOf("/en/") > -1) {
						$("#btnPanier").text("CART (" + data + ")");
					}
					else {
						$("#btnPanier").text("PANIER (" + data + ")");
					}
				}
			}
		}
	});
}

function ajoutPressePapier(btn) {
    var sTextImport = $("#textImport").val();
    $.ajax({
        url: '/fr/ShoppingCart/AjoutPressePapier',
        type: 'POST',
        data: { sText: sTextImport },
		dataType: 'html',
		success:function (result) {
			window.location.reload(true);
		}
    })
}

function removeFromCart(btn) {
	var recordToDelete = $(btn).attr("data-id");
	var win = $(window);

	var height = win.height() * 0.9;
	var width = 460;

	if (win.width < 480) {
		width = 440;
	}
	if (win.width <= 360) {
		width = 300;
	}
	$.ajax({
		url: '/fr/ShoppingCart/DeleteConfirmation',
		type: 'GET',
		data: { sId: recordToDelete },
		dataType: 'html',
		success: function (result) {
			//Affichage du popup
			$('#dialog').html(result);

			$("#dialog").dialog({
				modal: true,
				width: width,
				resizable: false,
				draggable: false,
				position: ["center", 20],
				show: "blind",
				hide: "blind",
				title: "",
				create: function (event) {
					$(event.target).parent().css({
						'position': 'fixed',
						'left': (win.width() - width) / 2,
						'top': (win.height() - width) / 2,
						'overflow-y': 'auto',
						'max-height': height
					});
				},
				open: function (event) {
					$('body').addClass('stop-scrolling');
				},
				close: function (event, ui) {
					$('body').removeClass('stop-scrolling');
					window.location.reload();
				},
			});
		}
	});
}

function emptyCart() {
	var win = $(window);

	var height = win.height() * 0.9;
	var width = 460;

	if (win.width < 480) {
		width = 440;
	}
	if (win.width <= 360) {
		width = 300;
	}
	$.ajax({
		url: '/fr/ShoppingCart/EmptyCartConfirmation',
		type: 'GET',
		dataType: 'html',
		success: function (result) {
			//Affichage du popup
			$('#dialog').html(result);

			$("#dialog").dialog({
				modal: true,
				width: width,
				resizable: false,
				draggable: false,
				position: ["center", 20],
				show: "blind",
				hide: "blind",
				title: "",
				create: function (event) {
					$(event.target).parent().css({
						'position': 'fixed',
						'left': (win.width() - width) / 2,
						'top': (win.height() - width) / 2,
						'overflow-y': 'auto',
						'max-height': height
					});
				},
				open: function (event) {
					$('body').addClass('stop-scrolling');
				},
				close: function (event, ui) {
					$('body').removeClass('stop-scrolling');
					window.location.reload(true);
				},
			});
		}
	});
}

function flyToElement(flyer, flyingTo) {
    var $func = $(this);
	var divider = 3;
    var flyerClone = $(flyer).clone();
    $(flyerClone).css({ position: 'absolute', top: $(flyer).offset().top + "px", left: $(flyer).offset().left + "px", opacity: 1, 'z-index': 1000 });
    $('body').append($(flyerClone));
    var gotoX = $(flyingTo).offset().left + ($(flyingTo).width() / 2) - ($(flyer).width() / divider) / 2;
    var gotoY = $(flyingTo).offset().top + ($(flyingTo).height() / 2) - ($(flyer).height() / divider) / 2;

    $(flyerClone).animate({
        opacity: 0.4,
        left: gotoX,
        top: gotoY,
        width: $(flyer).width() / divider,
        height: $(flyer).height() / divider
    }, 700,
    function () {
        $(flyingTo).fadeOut('fast', function () {
            $(flyingTo).fadeIn('fast', function () {
                $(flyerClone).fadeOut('fast', function () {
                    $(flyerClone).remove();
                });
            });
        });
    });
};

function logout() {
	$.ajax({
		url: '/fr/Account/Logout',
		type: 'POST',
		dataType: 'html',
		success: function (result) {
			SetCartGuid("");
			document.location.href = "/";
		}
	});
}

function increaseDetQte() {
	var multiplier = 0;
	var qteMin = 0;

	if ($('#MultipleAchat').length) {
		multiplier = $('#MultipleAchat').text();
	}

	if ($('#QteMin').length) {
		qteMin = $('#QteMin').text();
	}

	if ($('#qte-' + $(this).attr("data-id")).val() > parseInt(qteMin)) {
		if (multiplier > 1) {
			$('#qte-' + $(this).attr("data-id")).val(parseInt($('#qte-' + $(this).attr("data-id")).val()) - multiplier);
		}
		else {
			$('#qte-' + $(this).attr("data-id")).val(parseInt($('#qte-' + $(this).attr("data-id")).val()) - 1);
		}
	}
}

function decreaseDetQte() {
	var multiplier = 0;

	if ($('#MultipleAchat').length) {
		multiplier = $('#MultipleAchat').text();
	}

	if (multiplier > 1) {
		$('#qte-' + $(this).attr("data-id")).val(parseInt($('#qte-' + $(this).attr("data-id")).val()) + parseInt(multiplier));
	}
	else {
		$('#qte-' + $(this).attr("data-id")).val(parseInt($('#qte-' + $(this).attr("data-id")).val()) + 1);
	}
}

function toggleMenu(dataId) {
	$('[data-id="' + dataId + '"]').toggleClass('product-menu-item__open');
}

function toggleFilter(filterId) {
	$('[data-id-filter="' + filterId + '"]').toggleClass('product-menu-item__open');
}

const displayErreur = (imageId, messageId, messageErreur) => {
	$(imageId).prepend($('<img>', {id: 'theImg', src: '/Images/invalide.png'}));
	$(messageId).text(messageErreur);
}
;
