function showCat(id)
{
	if(document.getElementById('ssCat_'+id).style.display == 'none')
		jQuery("#ssCat_"+id).slideDown("normal");
	else
		jQuery("#ssCat_"+id).slideUp("normal");
}

function shadowboxopen(contenu)
{
	Shadowbox.open({
        content:    "<div style='padding:20px;'>"+contenu+"</div>",
        player:     "html",
        title:      "",
        width:      800,
		options:	{overlayColor:"#FFFFFF"}
    });

}

function showAlertClub()
{
	contenu = '<div style="width:560px;padding:20px">'+
					'<table style="width:100%;padding-bottom:5px">'+
						'<tr>'+
							'<td style="width:100%;color:#4A7B1E" align="center">Le Club Privilège est en construction. N\'hésitez pas à repasser plus tard.</td>'+
						'</tr>'+
					'</table>'+
					'<table style="width:560px;position:absolute;bottom:20px;border-top:solid 2px #D7BCB3;padding-top:5px">'+
						'<tr>'+
							'<td style="width:100%;cursor:pointer;color:#B49000;font-weight:bold;" align="center" onclick="Shadowbox.close();">Fermer</td>'+
						'</tr>'+
					'</table>'+
				'</div>';
	Shadowbox.open({
		content:    contenu,
		player:     "html",
		title:      "Club Privilège",
		width:      600,
		height:		100,
		options:	{overlayColor:"#FFFFFF"}
	});
}

function ajoutPanier(idProduit,nomProduit,conditionnement)
{
	qte = document.getElementById('qte_'+idProduit).value;
	if(qte < 0)
	{
		alert('Vous ne pouvez pas entrer de quantité négative.');
	}
	else
	{
		if(qte%6 != 0)
		{
			alert('Chaque vin est vendu en carton homogène de 6 ou 12 bouteilles.');
			
		}
		else
		{
			
			$.ajax({
			   type: "POST",
			   url: "ajaxAjouterContenuPanier.php",
			   data: "IdProduit="+idProduit+"&Quantite="+qte,
			   success: function(msg){
				 //alert(msg);
				 if(msg == "1")
				 {
					 if(qte > 1)
					{
						phrase = 'ont été ajoutés';
					}
					else
					{
						phrase = 'a été ajouté';
					}
					
					contenu = '<div style="width:560px;padding:20px">'+
						'<table style="width:100%;padding-bottom:5px">'+
							'<tr>'+
								'<td style="width:100%;color:#4A7B1E" align="center">'+qte+' '+nomProduit+' '+phrase+' à votre panier.</td>'+
							'</tr>'+
						'</table>'+
						'<table style="width:560px;position:absolute;bottom:20px;border-top:solid 2px #D7BCB3;padding-top:5px">'+
							'<tr>'+
								'<td style="width:40%;cursor:pointer;color:#B49000;font-weight:bold;" align="center" onclick="Shadowbox.close();">Continuer mes achats</td>'+
								'<td colspan="2" align="center" style="width:20%">&nbsp;</td>'+
								'<td style="width:40%;" align="center"><a style="text-decoration:none;color:#B49000;font-weight:bold;" href="boutique_etape1.php">Voir mon panier</a></td>'+
							'</tr>'+
						'</table>'+
					'</div>';
					
					if(document.getElementById('zonePanierEntete').style.display == "none")
					{
						document.getElementById('zonePanierEntete').style.display = "";
						document.getElementById('zoneBlankEntete').style.display = "none";
						$.ajax({
						   type: "POST",
						   url: "ajaxGetInfosPanier.php",
						   data: "",
						   success: function(msg){
							   document.getElementById('qteTotPanier').innerHTML = msg;
						   }
						});
					}
	
					
					
				}
				else
				{
					contenu = '<div style="width:560px;padding:20px">'+
						'<table style="width:100%;padding-bottom:5px">'+
							'<tr>'+
								'<td style="width:100%;color:#4A7B1E" align="center">Erreur lors de l\'ajout du produit au panier</td>'+
							'</tr>'+
						'</table>'+
						'<table style="width:560px;position:absolute;bottom:20px;border-top:solid 2px #D7BCB3;padding-top:5px">'+
							'<tr>'+
								'<td style="width:40%;cursor:pointer;color:#B49000;font-weight:bold;" align="center" onclick="Shadowbox.close();">Continuer mes achats</td>'+
								'<td colspan="2" align="center" style="width:20%">&nbsp;</td>'+
								'<td style="width:40%;" align="center"><a style="text-decoration:none;color:#B49000;font-weight:bold;" href="boutique_etape1.php">Voir mon panier</a></td>'+
							'</tr>'+
						'</table>'+
					'</div>'
				}
				Shadowbox.open({
						content:    contenu,
						player:     "html",
						title:      "Ajout d'un article",
						width:      600,
						height:		100,
						options:	{overlayColor:"#FFFFFF"}
					});
			   }
			   
			 });
	
			/*$.post(
				'ajaxAjouterContenuPanier.php',
				{IdProduit:idProduit,Quantite:qte},
				function(data){
					if(data.ajoutOk){
						alert('OK');
						if(qte > 1)
						{
							phrase = 'ont été ajoutés';
						}
						else
						{
							phrase = 'a été ajouté';
						}
						
						contenu = '<div style="width:560px;padding:20px">'+
							'<table style="width:100%;padding-bottom:5px">'+
								'<tr>'+
									'<td style="width:100%;color:#4A7B1E" align="center">'+qte+' '+nomProduit+' '+phrase+' à votre panier.</td>'+
								'</tr>'+
							'</table>'+
							'<table style="width:560px;position:absolute;bottom:20px;border-top:solid 2px #D7BCB3;padding-top:5px">'+
								'<tr>'+
									'<td style="width:40%;cursor:pointer;color:#B49000;font-weight:bold;" align="center" onclick="Shadowbox.close();">Continuer mes achats</td>'+
									'<td colspan="2" align="center" style="width:20%">&nbsp;</td>'+
									'<td style="width:40%;" align="center"><a style="text-decoration:none;color:#B49000;font-weight:bold;" href="boutique_etape1.php">Voir mon panier</a></td>'+
								'</tr>'+
							'</table>'+
						'</div>'
						
						Shadowbox.open({
							content:    contenu,
							player:     "html",
							title:      "Ajout d'un article",
							width:      600,
							height:		100,
							options:	{overlayColor:"#FFFFFF"}
						});
					}else{
						alert('Erreur dans l\'ajout du produit');
					}
				},
				'json'
			);*/
			
		}
	}
}

function ajoutCave(idProduit,nomProduit,conditionnement)
{
	/*qte = document.getElementById('qte_'+idProduit).value;
	if(qte%6 != 0)
	{
		alert('Chaque vin est vendu en carton homogène de 6 ou 12 bouteilles.');
	}
	else
	{*/
		
		$.ajax({
		   type: "POST",
		   url: "ajaxAjouterContenuCave.php",
		   data: "IdProduit="+idProduit,
		   success: function(msg){
			 //alert(msg);
			 if(msg == "1")
			 {
				/* if(qte > 1)
				{
					phrase = 'ont été ajoutés';
				}
				else
				{
					phrase = 'a été ajouté';
				}*/
				
				contenu = '<div style="width:560px;padding:20px">'+
					'<table style="width:100%;padding-bottom:5px">'+
						'<tr>'+
							'<td style="width:100%;color:#4A7B1E" align="center">'+nomProduit+' a été ajouté à votre cave.</td>'+
						'</tr>'+
					'</table>'+
				'</div>';
				
				if(document.getElementById('maCave').style.display == "none")
				{
					document.getElementById('maCave').style.display = "";
				}

				
				
			}
			else
			{
				contenu = '<div style="width:560px;padding:20px">'+
					'<table style="width:100%;padding-bottom:5px">'+
						'<tr>'+
							'<td style="width:100%;color:#4A7B1E" align="center">Erreur lors de l\'ajout du produit à la cave.</td>'+
						'</tr>'+
					'</table>'+
				'</div>'
			}
			Shadowbox.open({
					content:    contenu,
					player:     "html",
					title:      "Ajout d'un article",
					width:      600,
					height:		100,
					options:	{overlayColor:"#FFFFFF"}
				});
		   }
		   
		 });

		
		
	//}
}

function supprCave(idProduit)
{
	$.ajax({
	   type: "POST",
	   url: "ajaxSupprimerCave.php",
	   data: "IdProduit="+idProduit,
	   success: function(msg){
		 //alert(msg);
		 if(msg == "1")
		 {
			 contenu = '<div style="width:560px;padding:20px">'+
				'<table style="width:100%;padding-bottom:5px">'+
					'<tr>'+
						'<td style="width:100%;color:#4A7B1E" align="center">Le produit a bien été supprimé de votre cave virtuelle.</td>'+
					'</tr>'+
				'</table>'+
			'</div>';
			
		 }
		 else
		 {
			 contenu = '<div style="width:560px;padding:20px">'+
				'<table style="width:100%;padding-bottom:5px">'+
					'<tr>'+
						'<td style="width:100%;color:#4A7B1E" align="center">Erreur lors de la suppression du produit.</td>'+
					'</tr>'+
				'</table>'+
			'</div>'
		 }
		 Shadowbox.open({
				content:    contenu,
				player:     "html",
				title:      "Suppression de produit",
				width:      600,
				height:		100,
				options:	{overlayColor:"#FFFFFF",onClose:function(){document.location = "ma_cave.php";}}
			});
	   }
	})
}

function supprProduit(idProduit)
{
	modifPanier(idProduit,true);
}

function modifPanier(idProduit,supr)
{
	if(supr==null)
		supr=false;
	qte = document.getElementById('qte_'+idProduit).value;
	if(supr)
	{
		qte = 0;
	}
	
	if(qte < 0)
	{
		alert('Vous ne pouvez pas entrer de quantité négative.');
		document.getElementById('qte_'+idProduit).value = 6;
	}
	else
	{
		if(qte%6 != 0)
		{
			alert('Chaque vin est vendu en carton homogène de 6 ou 12 bouteilles.');
		}
		else
		{
			$.ajax({
			   type: "POST",
			   url: "ajaxModifContenuPanier.php",
			   data: "IdProduit="+idProduit+"&Quantite="+qte,
			   success: function(msg){
				 //alert(msg);
				 if(msg == "1")
				 {
					 contenu = '<div style="width:560px;padding:20px">'+
						'<table style="width:100%;padding-bottom:5px">'+
							'<tr>'+
								'<td style="width:100%;color:#4A7B1E" align="center">La quantité a bien été modifée.</td>'+
							'</tr>'+
						'</table>'+
					'</div>';
					
					$.ajax({
					   type: "POST",
					   url: "ajaxGetInfosPanier.php",
					   data: "",
					   success: function(msg){
						   document.getElementById('qteTotPanier').innerHTML = msg;
					   }
					});
				 }
				 else
				 {
					 contenu = '<div style="width:560px;padding:20px">'+
						'<table style="width:100%;padding-bottom:5px">'+
							'<tr>'+
								'<td style="width:100%;color:#4A7B1E" align="center">Erreur lors de la modification de la quantité.</td>'+
							'</tr>'+
						'</table>'+
					'</div>'
				 }
				 Shadowbox.open({
						content:    contenu,
						player:     "html",
						title:      "Modification de quantité",
						width:      600,
						height:		100,
						options:	{overlayColor:"#FFFFFF",onClose:function(){document.location = "boutique_etape1.php";}}
					});
			   }
			})
		}
	}
}

function confirm_commande_cheque()
{
	//alert('test');
	$.ajax({
	   type: "POST",
	   url: "ajaxConfirmCommandeChq.php",
	   data: "",
	   success: function(msg){
		   //alert(msg);
		   if(msg == '1')
		   {
			   contenu = '<div style="width:560px;padding:20px">'+
							'<center>Votre commande est en attente.<br/>A réception de votre paiement, elle vous sera adressée dans les meilleurs délais.<br/>Merci de votre confiance.<br/><a href="boutique_accueil.php">Retour à la boutique</a></center>'+
						'</div>';
			   Shadowbox.open({
					content:    contenu,
					player:     "html",
					title:      "Confirmation de commande",
					width:      600,
					height:		100,
					options:	{overlayColor:"#FFFFFF",onClose:function(){document.location = "boutique_accueil.php";}}
				});
		   }
		   else
		   {
			   contenu = '<div style="width:560px;padding:20px">'+
							'<center>Une erreur est survenue lors de la confirmation de votre commande. Merci de contacter Ackerman.</center>'+
						'</div>';
			   Shadowbox.open({
					content:    contenu,
					player:     "html",
					title:      "Erreur",
					width:      600,
					height:		100,
					options:	{overlayColor:"#FFFFFF"}
				});
		   }
	   }
	});
}

function reloadPanier()
{
	document.location = "boutique_etape1.php";
}

function verif_etape1()
{
  if(document.getElementById('checkCGV').checked)
  {
    document.location = "boutique_etape2.php";
  }
  else
  {
    alert("Vous devez accepter les conditions générales de vente pour poursuivre votre commande.")
  }


}

function verif_etape2()
{
    thereIsBlank = false
     if(document.getElementById('nomFact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner le nom de facturation.";
        return msg;
     }
     
     if(document.getElementById('prenomFact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner le prenom de facturation.";
        return msg;
     }
     
     if(document.getElementById('ad1Fact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner le nom de facturation.";
        return msg;
     }
     if(document.getElementById('cpFact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner le code postal de facturation.";
        return msg;
     }
     if(document.getElementById('villeFact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner la ville de facturation.";
        return msg;
     }
     if(document.getElementById('paysFact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner le pays de facturation.";
        return msg;
     }
     if(document.getElementById('telFact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner le pays de facturation.";
        return msg;
     }
     if(document.getElementById('mailFact').value == '')
     {
        thereIsBlank = true;
        msg = "Merci de renseigner le mail de facturation.";
        return msg;
     }
     
     document.location = "boutique_etape3.php"
}

//function gestionOnglets(cle1,cle2)
//{
	//alert(cle1+" - "+cle2);
	
	//document.getElementById(cle1).style.display = '';
	//document.getElementById(cle2).className='onglet_actif';
	
	/*alert(document.getElementById(cle1));
	
	if(cle1 != 'Vini_produit')
	{
		if(document.getElementById('ongletVini'))
			document.getElementById('ongletVini').className='onglet_inactif';
		if(document.getElementById('Vini_produit'))
			document.getElementById('Vini_produit').style.display = 'none';
	}
	else
	{
		//if(document.getElementById('ongletVini'))
			document.getElementById('ongletVini').className='onglet_actif';
		//if(document.getElementById('Vini_produit'))
			document.getElementById('Vini_produit').style.display = '';
	}
	
	if(cle1 != 'Carac_produit')
	{
		if(document.getElementById('ongletCarac'))
			document.getElementById('ongletCarac').className='onglet_inactif';	
		if(document.getElementById('Carac_produit'))
			document.getElementById('Carac_produit').style.display = 'none';
	}
	else
	{
		//if(document.getElementById('ongletCarac'))
			document.getElementById('ongletCarac').className='onglet_actif';
		//if(document.getElementById('Carac_produit'))
			document.getElementById('Carac_produit').style.display = '';
	}
	
	if(cle1 != 'Desc_produit')
	{
		if(document.getElementById('ongletDesc'))
			document.getElementById('ongletDesc').className='onglet_inactif';	
		if(document.getElementById('Desc_produit'))
			document.getElementById('Desc_produit').style.display = 'none';
	}
	else
	{
		//if(document.getElementById('ongletDesc'))
			document.getElementById('ongletDesc').className='onglet_actif';
		//if(document.getElementById('Desc_produit'))
			document.getElementById('Desc_produit').style.display = '';
	}
	
	if(cle1 != 'Hist_produit')
	{
		if(document.getElementById('ongletHist'))
			document.getElementById('ongletHist').className='onglet_inactif';	
		if(document.getElementById('Hist_produit'))
			document.getElementById('Hist_produit').style.display = 'none';
	}
	else
	{
		//if(document.getElementById('ongletHist'))
			document.getElementById('ongletHist').className='onglet_actif';
		//if(document.getElementById('Hist_produit'))
			document.getElementById('Hist_produit').style.display = '';
	}
	
	if(cle1 != 'Plus_produit')
	{
		if(document.getElementById('ongletPlus'))
			document.getElementById('ongletPlus').className='onglet_inactif';	
		if(document.getElementById('Plus_produit'))
			document.getElementById('Plus_produit').style.display = 'none';
	}
	else
	{
		//if(document.getElementById('ongletPlus'))
			document.getElementById('ongletPlus').className='onglet_actif';
		//if(document.getElementById('Plus_produit'))
			document.getElementById('Plus_produit').style.display = '';
	}
	*/
	
	
	
	
	
//}