
// ----- gestion du menu du haut en jQuery + jQuery.accordion ----- //
var obj = null;
function checkHover() {
	if (obj) {
		obj.find('ul').slideUp('fast');
	} //if
} //checkHover

$(document).ready(function() {
	$('#niveau_1 > li').hover(function() {
			if (obj) {
				obj.children('ul').slideUp('fast');
				obj = null;
			} //if
			
			if ($(this).children('ul').is(":hidden")) {	
				$(this).children('ul').slideDown('fast');
			}
		}, function() {
			obj = $(this);
			setTimeout(
			"checkHover()",
			300);
		}
	);
});

// ----- Gestion de la newsLetter ----- //
function verifNews(formName){
	
	var a,i,j,k,arobase,objForm;
	i=0;
	k=0;
	objForm = document.getElementsByName(formName);
	a =objForm[0].email.value;
	
	for(j=0; j<a.length-1;j++){
		if(a.charAt(j)=="@"){ i++; arobase=i; }
	}
	
	for(j=arobase; j<a.length-1;j++){
		if(a.charAt(j)==".") k++;
	}
	
	if (a==""){
		alert("Champ MAIL obligatoire");
	}else if(i!=1 || k<1){
		alert("Adresse MAIL invalide");
	}else{
		objForm[0].submit();
	}
}

// ----- Validation de la commande ----- //
function validCommande2(){
	document.formcom.submit();
}

// ------- gestion des adresses de commande et livraison identiques ----- //
function livraisonvoir()
{
	var blocLivr = $('#blocLivraison')
	if (document.mod.livraisonOk.checked) {
		blocLivr.hide();
	}
	else {
		blocLivr.show();
		document.location.href = "/clients/vos-informations.php#ancreLivraison";
	}
}

// ----- validation du formulaire de contact ----- //

function validcontact(){
	
	var a,i,j,k,arobase;
	i=0;
	k=0;
	a = document.formcontact.mailcontact.value;  
	
	for(j=0; j<a.length-1;j++){
		if(a.charAt(j)=="@")
		{ i++; arobase=i; }
	}
	for(j=arobase; j<a.length-1;j++){
		if(a.charAt(j)==".")
			k++;
	}
	
	if (document.formcontact.nom.value==""){
		alert("Champ NOM obligatoire");
	}else if (document.formcontact.mailcontact.value==""){
		alert("Champ MAIL obligatoire");
	}else if(i!=1 || k<1){
		alert("Adresse MAIL invalide");
	}else if (document.formcontact.commentaires.value==""){
		alert("Champ COMMENTAIRES obligatoire");
	}else{
		document.formcontact.submit();
	}
}