	function hideCategGroupe(){
		a_ul = document.getElementById("commander_choix_serie").getElementsByTagName("ul")
		for (var a=0; a<a_ul.length; a++){
			a_ul[a].style.display = "none";
		}
	}

	function showHideCategGroupe(noGroupe){
		a_ul = document.getElementById("commander_choix_serie").getElementsByTagName("ul")
		for (var a=0; a<a_ul.length; a++){
			if(a_ul[a].id.indexOf("categ_groupe_") != -1 && a_ul[a].id != "categ_groupe_"+noGroupe)
				a_ul[a].style.display = "none";
		}
		
		if(document.getElementById("categ_groupe_"+noGroupe).style.display == "block"){
			document.getElementById("categ_groupe_"+noGroupe).style.display = "none";
		}else{
			document.getElementById("categ_groupe_"+noGroupe).style.display = "block";
		}
	}
	
	function changeSerie(noCategorie, noSerie, page){
		a_serie = document.getElementById("lstSeries").getElementsByTagName("a")
		
		for(var a=0; a<a_serie.length; a++){
			if(a_serie[a].id.indexOf("serie_thumb_") != -1){
				if(a_serie[a].className == "selected"){
					a_serie[a].className = "";
				}
			}
		}
		
		document.getElementById("serie_thumb_"+noSerie).className = "selected";
		
		AffDetailSerie(noCategorie, noSerie, page)
	}
	
	function changebigImageSerie(element, src){
		a_serie = document.getElementById("image_slideshow").getElementsByTagName("a")
		
		for(var a=0; a<a_serie.length; a++){
			if(a_serie[a].className == "selected"){
				a_serie[a].className = "";
			}
		}
		
		element.className = "selected";
		
		document.getElementById("big_imageSerie").src = src;
	}
	
	function showHideBoxInfo(noProduit, str_display){
		document.getElementById("box_produit_"+noProduit).style.display = str_display;
		
		switch(str_display){
		case "none":
			document.getElementById("btn_showProductInfo_"+noProduit).style.display = "block";
			document.getElementById("btn_hideProductInfo_"+noProduit).style.display = "none";
			break;
		case "block":
			document.getElementById("btn_showProductInfo_"+noProduit).style.display = "none";
			document.getElementById("btn_hideProductInfo_"+noProduit).style.display = "block";
			break
		}
	
	}
	
	function updateExpeditionBoite(noProduit, noBoite, Qty){
		if(document.getElementById('date_expe_box_'+noProduit+'_'+noBoite)){
			SubmitString = "flag=UpdateQte";
			SubmitString += "&noBoite=" + noBoite;
			SubmitString += "&BoxOrProduct=box";
			SubmitString += "&Qty=" + Qty;
			
			sendRequest('upd_cart.asp', 'date_expe_box_'+noProduit+'_'+noBoite, SubmitString);	
		
		}
	}
	
	function updateExpeditionProduit(flag, noProduit, Qty){
		if(document.getElementById('date_expe_produit_'+noProduit)){
			SubmitString = "flag="+flag;
			SubmitString += "&noProduit=" + noProduit;
			SubmitString += "&BoxOrProduct=product";			
			SubmitString += "&Qty=" + Qty;
		
			sendRequest('upd_cart.asp', 'date_expe_produit_'+noProduit, SubmitString);
		}
	}
		
	
	
	function ChangeQty(noProduit, Qty){	
		if(lang_site == "en"){
			msg = "Are you sure you want to delete this item?";	
		} else{
			msg = "Êtes-vous certain de vouloir supprimer ce produit?";
		}
		//alert("qty =" + Qty +";");
		if(Qty == ''){
			if (confirm(msg)){	
				send = true;
			} else { 
				send = false;
			}
		}else{ send = true; }
		
		if(send == true){
			if (!isInteger(Qty*10)) {
				if(window.document.getElementById('qte_produit_'+noProduit))
					window.document.getElementById('qte_produit_'+noProduit).value = 0;
				Qty = 0;
			}		
			
			/*SubmitString = "flag=UpdateCart";
			SubmitString += "&noProduit=" + noProduit;
			SubmitString += "&Qty=" + Qty;
			SubmitString += "&redirect=inc_commandes_mini_panier.asp";				
	
			sendRequest('panier_upd.asp', 'divCart', SubmitString);		*/
			
			var redirect = "";
			
			$.ajax({
					type: 'POST',
					url: 'includes/panier_upd.asp',
					data: {flag:"UpdateCart", noProduit:noProduit, Qty:Qty, redirect:redirect},
					dataType: 'html',
					success: function(html, textStatus){
						//alert("Cool");
						//alert(html);
						//document.getElementById('lstSerie').innerHTML = html;
						//document.location.reload();
						refresh_panier();
					},
					error: function(xhr, textStatus, errorThrown){
						alert(xhr.responseText);
						//document.getElementById('lstSerie').innerHTML = xhr.responseText;
						//document.getElementById('lstProduits').innerHTML = html;
						alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
					}
				});
			
			if(document.getElementById("box_produit_"+noProduit)){
				a_input = document.getElementById("box_produit_"+noProduit).getElementsByTagName("input")
				
				var qte_box = 0;
				var qte_qteInProduct = 0;
				for(var a=0; a<a_input.length; a++){
					if(a_input[a].id.indexOf("qte_box_") != -1){
						qte_box = parseFloat(a_input[a].value)
					}
					if(a_input[a].id.indexOf("QteInProduct_") != -1){
						qte_qteInProduct = parseFloat(a_input[a].value)
					}
					if(a_input[a].id.indexOf("qtetotal_box_") != -1){
						a_input[a].value = Qty*qte_qteInProduct + qte_box;
						
						noBoite = a_input[a].id.substr(a_input[a].id.lastIndexOf("_")+1)					
						
						updateExpeditionBoite(noProduit, noBoite, (Qty*qte_qteInProduct + qte_box))
						
						qte_box = 0;
						qte_qteInProduct = 0;
					}
				}
				
				updateExpeditionProduit("UpdateQteBYBox", noProduit, Qty)
			}else{
				updateExpeditionProduit("UpdateQte", noProduit, Qty)	
			}
		}
		
	}
	
	function ClearCart(){	
		if(lang_site == "en"){
			msg = "Are you sure you want to clear cart?";	
		} else{
			msg = "Êtes-vous certain de vouloir vider votre panier?";
		}
		//alert("qty =" + Qty +";");
		
		if (confirm(msg)){	
			send = true;
		} else { 
			send = false;
		}
		
		
		if(send == true){
			
			
			var redirect = "";
			
			$.ajax({
					type: 'POST',
					url: 'includes/panier_upd.asp',
					data: {flag:"ClearCart"},
					dataType: 'html',
					success: function(html, textStatus){
						//alert(html);
						refresh_panier();
					},
					error: function(xhr, textStatus, errorThrown){
						alert(xhr.responseText);						
						alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
					}
				});
			
		}
		
	}
	
	function refresh_panier(){
		$.ajax({
				type: 'POST',
				url: 'includes/inc_rc_panier.asp',
				data: {},
				dataType: 'html',
				success: function(html, textStatus){
					$('#box_panier').html(html).effect('highlight', {color: '#FFF8AF'}, 2000);
				},
				error: function(xhr, textStatus, errorThrown){
					alert(xhr.responseText);
					//document.getElementById('lstSerie').innerHTML = xhr.responseText;
					//document.getElementById('lstProduits').innerHTML = html;
					alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
				}
			});
	}
	
	function QtyKeypress(event, noProduit, Qty){
		if (NumberPickerKeypress(event)){
			setTimeout ("ChangeQty("+noProduit+",window.document.getElementById('qte_produit_'+"+noProduit+").value);", 300);
			return true;
		}
		return false;
	}
	
	function QtyClick(event, noProduit, Qty){
		if (NumberPickerClick(event)){
			setTimeout ("ChangeQty("+noProduit+",window.document.getElementById('qte_produit_'+"+noProduit+").value);", 300);
			return true;			
		}
		return false
	}
	
	
	function ChangeQtyBox(noProduit, noBoite, Qty){	
		if (!isInteger(Qty)) {
			if(window.document.getElementById('qte_box_'+noBoite))
				window.document.getElementById('qte_box_'+noBoite).value = 0;
			Qty = 0
		}	
		
		//var qte_produit = parseFloat(document.getElementById("qte_produit_"+noProduit).value)
		//var qteInProduct = parseFloat(document.getElementById("QteInProduct_"+noProduit+"_"+noBoite).value)
		//document.getElementById("qtetotal_box_"+noProduit+"_"+noBoite).value = qte_produit*qteInProduct + parseFloat(Qty)
		
		
		
		/*SubmitString = "flag=UpdateCart";
		SubmitString += "&noBoite=" + noBoite;
		SubmitString += "&Qty=" + Qty;
		SubmitString += "&redirect=inc_commandes_mini_panier.asp";				

		sendRequest('panier_upd.asp', 'divCart', SubmitString);*/
		
		var redirect = "hotmail.com";
		
		$.ajax({
				type: 'POST',
				url: 'includes/panier_upd.asp',
				data: {flag:"UpdateCart", noBoite:noBoite, Qty:Qty, redirect:redirect},
				dataType: 'html',
				success: function(html, textStatus){
					//alert("Cool");
					//alert(html);
					//document.getElementById('lstSerie').innerHTML = html;
					//document.location.reload();
					refresh_panier();
				},
				error: function(xhr, textStatus, errorThrown){				
					alert(xhr.responseText);
					//document.getElementById('lstSerie').innerHTML = xhr.responseText;
					//document.getElementById('lstProduits').innerHTML = html;
					alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
				}
			});
		
		//updateExpeditionProduit("UpdateQteBYBox", noProduit, qte_produit)
		//updateExpeditionBoite(noProduit, noBoite, (qte_produit*qteInProduct + parseFloat(Qty)))
		//$(this).preventDefault();
	}
	
	function QtyBoxKeypress(event, noProduit, noBoite, Qty){
		if (NumberPickerKeypress(event)){
			setTimeout ("ChangeQtyBox("+noProduit+", "+noBoite+",window.document.getElementById('qte_box_'+"+noBoite+").value);", 300);
			return true;
		}
		return false;
	}
	
	function QtyBoxClick(event, noProduit, noBoite, Qty){
		if (NumberPickerClick(event)){
			setTimeout ("ChangeQtyBox("+noProduit+", "+noBoite+",window.document.getElementById('qte_box_'+"+noBoite+").value);", 300);
			return true;			
		}
		return false
	}
	
	var timeoutID=0;
	function displayInfoBulle(id){
		clearTimeout(timeoutID);
		timeoutID = setTimeout ("document.getElementById('"+id+"').style.display='block';", 300);
	}
	
	function hideInfoBulle(id){
		if(document.getElementById(id).style.display=='block'){
			document.getElementById(id).style.display='none';
		}else{
			clearTimeout(timeoutID);
		}
	}
	
	
	function AffSeriesInfo(noCategorie, noSerie, motcle, page){
		
		AffPages(noCategorie, motcle, page);
		AffDetailSerie(noCategorie, noSerie, motcle, page)
		
		SubmitString = "flag=AffLstSeries";
		SubmitString += "&noCategorie=" + noCategorie;
		SubmitString += "&motcle=" + escape(motcle);
		SubmitString += "&page=" + page;
		sendRequest('inc_commandes_series.asp', 'lstSeries', SubmitString);
				
	}
	
	function AffDetailSerie(noCategorie, noSerie, motcle, page){
		SubmitString = "flag=AffDetailSeries";
		SubmitString += "&noCategorie=" + noCategorie;
		SubmitString += "&noSerie=" + noSerie;
		SubmitString += "&motcle=" + escape(motcle);
		SubmitString += "&page=" + page;

		sendRequest('inc_commandes_series.asp', 'detailSeries', SubmitString);
		
		SubmitString = "flag=AffDescSeries";
		SubmitString += "&noCategorie=" + noCategorie;
		SubmitString += "&noSerie=" + noSerie;
		SubmitString += "&motcle=" + escape(motcle);
		SubmitString += "&page=" + page;
		
		sendRequest('inc_commandes_series.asp', 'descSerie', SubmitString);
	}
	
	function AffPages(noCategorie, motcle, page){
		SubmitString = "flag=AffPages";
		SubmitString += "&noCategorie=" + noCategorie;
		SubmitString += "&motcle=" + escape(motcle);
		SubmitString += "&page=" + page;		

		sendRequest('inc_commandes_series.asp', 'lstSeriesPage', SubmitString);		
	}
	
	function AffPanier(){
		SubmitString = "flag=AffPanier";
		sendRequest('inc_commandes_mini_panier.asp', 'divCart', SubmitString);		
	}
	
	
	function GotoCart(){
		
		rep = trim(getRequest("upd_cart.asp", "flag=NbItemsInCart")).split(";");
		
		total = rep[0];
		nbItem = rep[1];
		

	/*	if ((nbItem >= <%=MinItemsPerOrder%>) || (total >= <%=MinTotalPerOrder%>)){
			gotoURL("panier_commandes.asp");
		}else{
			
			if (total < <%=MinTotalPerOrder%>){
				<%
				message = replace(t("You must purchase a minimum of [TOTAL]!"), "[TOTAL]", cStr(NumberToMoney(MinTotalPerOrder)))
				message = replace(message, "'", "\'")
				%>
				message = '<%=message%>'
				alert(message);
			}else{
				<%
				message = replace(t("Not enough item in cart, need [NBITEMS]!"), "[NBITEMS]", MinItemsPerOrder)
				message = replace(message, "'", "\'")
				%>
				message = '<%=message%>'
				alert(message);
			}
		}*/
	}	
	
	
	function OnLoadCommande(){
	/*	AffSeriesInfo(<%=noCategorie%>, <%=noSerie%>,'<%=motcle%>', <%=page%>);
		<%if session("niveauRepresentant")>0 then%>
			AffPanier()
		<%end if%>*/
	}
	
	function displayBigImageProduitRef(noProduit){
		window.document.getElementById("big_imageSerie").src='gestion/photo.php?d=produits&p='+noProduit;
	}		
	
	function displayBigImageProduit(noProduit, nouveau, langue){
		
		//Créer le background transparent
		var mask = document.createElement("div");
		
		mask.id = "popup_mask";
		mask.className = "popup_mask";
		
		with (mask.style) {
			height = document.getElementById("main").offsetHeight+"px",
			opacity = .7,
			MozOpacity = .7,
			filter = "alpha(opacity=70)"	
		}
		
		document.body.appendChild(mask);
		mask.onclick = closeBigImageProduit
		
		
		//Créer le pop up
		var popup_container = document.createElement("div");
		popup_container.id = "popup_container";
		popup_container.className = "popup_container";
		popup_container.style.top = (document.getElementById("main").offsetHeight/2)+"px",

		document.body.appendChild(popup_container);
		popup_container.onclick = closeBigImageProduit
		
				
		var popup = document.createElement("div");
		popup.id = "popup";
		popup.className = "popup";
				
		popup.innerHTML = '<IMG src="photo.php?d=produits/&p='+noProduit+'&n='+nouveau+'&l='+langue+'" width="510"><div style="text-align:right; margin-top:8px;"><a href="javascript:closeBigImageProduit();">Fermer</a></div>';
			
		popup_container.appendChild(popup);
		
	}	
	
	function closeBigImageProduit(){
		document.getElementById("popup_container").parentNode.removeChild(document.getElementById("popup_container"));
		document.getElementById("popup_mask").parentNode.removeChild(document.getElementById("popup_mask"));
		
	}

   function ScrollBy(dir){
        var left = document.getElementById("myMarquee").scrollLeft;
        if (dir =='left')
           document.getElementById("myMarquee").scrollLeft = left - 74;
        else
           document.getElementById("myMarquee").scrollLeft = left + 74; 
   }
   
	function clickCategories(e){
		
		var myNode = e.srcElement? e.srcElement : e.target;
		
		for (i = 0; i < document.getElementsByTagName("li").length; i++) {
		   document.getElementsByTagName("li")[i].childNodes[0].style.color = "";
		}
		
		myNode.style.color = "#FC9046";

	}   
	
	
	$(function() {
		activate_clear_btn();		
	});
	
	function activate_clear_btn(){
		$("#vider_panier").live('click',function(){
			//alert("test");
			ClearCart();
		});
	}
