// JavaScript Document
	function ajouter(id)
	{
		if(parseInt(document.forms['produit'].elements['qte' + id].value) >0)
		{
			document.forms['produit'].elements['id_plateau'].value = id;
			document.forms['produit'].submit();
		}
	}


function supp(id) //fonction qui supprime le produit
{
	document.forms['panier'].id_plateau_supp.value = id;
	document.forms['panier'].submit();
}

function supp_perso(id) //fonction qui supprime le produit
{
	document.forms['panier'].id_plateau_perso_supp.value = id;
	document.forms['panier'].submit();
}

function valid() //fonction qui valide le panier et renvoi vers la page fiche-commande
{
	document.forms['panier'].action = "fiche-commande.php?commande=1";
	document.forms['panier'].submit();
}

function recalculPanier()
{
	document.forms['panier'].recalculer.value = "recalculer";
	document.forms['panier'].submit();
}
function continuer()
{
	if(document.forms['panier'].cgv.checked)
	{
		document.forms['panier'].action ="vente_plateau_fromage_identification.php";
		document.forms['panier'].submit();
	}else
	alert ("Vous devez accepter et conditions générales de vente pour poursuivre votre commande");
}

function verif_email (email) {
        var s = new String(email);
        if (!s.match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$')) 
            return false;
        else 
           return true;       
}
	
function verif()
{
	var nom = document.forms['inscription'].nom.value;
	var prenom = document.forms['inscription'].prenom.value;
	var adresse = document.forms['inscription'].adresse.value;
	var cp = document.forms['inscription'].cp.value;
	var ville = document.forms['inscription'].ville.value;
	var tel = document.forms['inscription'].tel.value;
	var email = document.forms['inscription'].email.value;
	var mdp1 = document.forms['inscription'].mdp1.value;
	var mdp2 = document.forms['inscription'].mdp2.value;
	var warning = document.getElementById("warning");
	var ok = true;
	
	warning.innerHTML="";
	if (nom =="" || prenom =="" || adresse =="" || cp =="" || ville =="" || tel =="" || email =="" || mdp1 =="" || mdp2 =="")
	{
		warning.innerHTML += "Veuillez remplir tout les champs obligatoires <br />";
		ok = false;
	} 
	
	if (document.forms['inscription'].civilite.value=="")
	{
		warning.innerHTML  += "Veuillez choisir votre civilite <br />";
		ok = false;
	}
	
	if(!verif_email (email))
	{
		warning.innerHTML  += "Votre E-mail n'est pas valide <br />";
		ok = false;
	}
		
	if (mdp1 != mdp2)
	{
		warning.innerHTML  += "Erreur mot de passe <br />"+cp.length;
		ok = false;
	}
	
	if (!isNaN(cp) || cp.length != 5)
	{
		warning.innerHTML += "Le code postal n'est pas valide <br />";
		ok = false;
	}
	
	if (ok)
	document.forms['inscription'].submit();	
}

	function ModifierQte(pForm, iValue){
		iOldQuantity = pForm.value;
		iQuantity = iValue + parseInt(iOldQuantity);
		if (iQuantity <1){
			iQuantity = 1
		}
		pForm.value = iQuantity;
	}
function changeOnglet(val){
active_li = document.getElementById("li"+val);
active_li.className = "active";
}

function SwitchDiv(ParamDiv){

	EtatDisplay = document.getElementById(ParamDiv).style.display;

	if(EtatDisplay=="none" || EtatDisplay==null || EtatDisplay==""){

		document.getElementById(ParamDiv).style.display = "block";

	}else{

		document.getElementById(ParamDiv).style.display = "none";

	}

}

function SwitchTitre(){
	EtatDisplay = document.getElementById('DivAdresse2').style.display;
	if(EtatDisplay=="none" || EtatDisplay==null || EtatDisplay==""){
		document.getElementById('H2Fact').innerHTML = "Adresse de facturation<br /> et de livraison";
		document.getElementById('H2Liv').innerHTML = "";
	}else{
		document.getElementById('H2Fact').innerHTML = "Adresse de facturation";
		document.getElementById('H2Liv').innerHTML = "Adresse de livraison";
	}
}
function popUp(strURL,strType,strHeight,strWidth) {
	var strOptions="";
	if (strType=="console") strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
	window.open(strURL, 'newWin', strOptions);
}

function suppPromo(id_promo){
	if(window.confirm('Etes-vous certain de vouloir supprimer la promotion n°' + id_promo + '?'))
	window.location.href = '../administration/gestion.php?gestion=promotion&promotion=liste&supp='+id_promo;	
}

function suppNewsletter(id_newsletter){
	if(window.confirm('Etes-vous certain de vouloir supprimer le Newsletter n°' + id_newsletter + '?'))
	window.location.href = '../administration/gestion.php?gestion=newslettersupp&supp='+id_newsletter;	
}

var timeout; 
function openInfoDialog() { 
	document.getElementById('divachat').style.visibility = "hidden";
	Dialog.info("<a href=\"http://www.ma-recette-isigny.fr\" target=\"_blank\" title=\"Jeu concours : Ma recette Isigny\" id='interstitiel'><img src=\"img/pub_ma-recette-isigny.fr.jpg\" width=\"250\" height=\"250\" alt\"Jeu concours : Ma recette Isigny\" /></a><br /><br /><a href='#' onclick='cacheflash();Dialog.closeInfo();'>[ Fermer ]</a>", {width:300, height:300, className: "alphacube"});
	timeout=10; setTimeout(infoTimeout, 1000) 
} 
function cacheflash(){
	document.getElementById('divachat').style.visibility = "visible";
	document.getElementById("interstitiel").style.visibility="hidden";	
}
function infoTimeout() { 
	
	timeout--; 
	if (timeout >0) { 
		setTimeout(infoTimeout, 1000) 
	}
	else{
		document.getElementById("interstitiel").style.visibility="hidden";
		document.getElementById('divachat').style.visibility = "visible";
		Dialog.closeInfo();
	}
}
