
//////////////////////////////
// CONTROLE DES FORMULAIRES //
//////////////////////////////

function validNewsletter() {
	
	e_mail=document.formNewsletter.formEmail.value;
	var place = e_mail.indexOf("@",1);
	var point = e_mail.indexOf(".",place+1);
	if ((place > -1)&&(e_mail.length >2)&&(point > 1)) {
		return true
	}
	else {
		alert('L\'adresse email que vous avez saisie n\'est pas valide');
		document.formNewsletter.formEmail.focus();
		return false
	}
	
}

function validRecherche() {

	if (document.formRecherche.formMot.value == "") {
		alert("Veuillez saisir un mot à chercher");
		document.formRecherche.formMot.focus();
		return false
	}

}

function validContact() {

	if (document.formContact.Nom.value == "") {
		alert("Veuillez indiquer votre nom");
		document.formContact.Nom.focus();
		return false
	}
	
	if (document.formContact.Message.value == "") {
		alert("Votre message est vide");
		document.formContact.Message.focus();
		return false
	}

	e_mail=document.formContact.Email.value;
	var place = e_mail.indexOf("@",1);
	var point = e_mail.indexOf(".",place+1);
	if ((place > -1)&&(e_mail.length >2)&&(point > 1)) {
		return true
	}
	else {
		alert('L\'adresse email que vous avez saisie n\'est pas valide');
		document.formContact.Email.focus();
		return false
	}
		
}

function validCommande() {

	if (document.formCommande.Nom.value == "") {
		alert("Veuillez indiquer votre nom");
		document.formCommande.Nom.focus();
		return false
	}
	
	if (document.formCommande.Commande.value == "") {
		alert("Votre message est vide");
		document.formCommande.Commande.focus();
		return false
	}
	
	if (document.formCommande.Telephone.value == "") {
		alert("euillez indiquer votre numéro de téléphone");
		document.formCommande.Telephone.focus();
		return false
	}
	
	e_mail=document.formCommande.Email.value;
	var place = e_mail.indexOf("@",1);
	var point = e_mail.indexOf(".",place+1);
	if ((place > -1)&&(e_mail.length >2)&&(point > 1)) {
		return true
	}
	else {
		alert('L\'adresse email que vous avez saisie n\'est pas valide');
		document.formCommande.Email.focus();
		return false
	}

}



//////////////////////////////
// AUTRES FONCTIONS         //
//////////////////////////////

function formmailto (prenom, nom) {
	var domaine = "com" ;

	document.write('<a href=\"mailto:' + prenom + '@' + nom  + '.' + domaine + '\" class=\"texte\">') ; 
	document.write(prenom + '@' + nom + '.' + domaine  + '</a>') ;
}

function openClose(id,mode)
{
	if(document.getElementById) {
		element = document.getElementById(id);
		img = document.getElementById('img_' + id);
	} else if(document.all) {
		element = document.all[id];
		img = document.all['img_' + id];
	} else return;
	
	if(element.style) {
		if(mode == 0) {
			if(element.style.display == 'block' ) {
				element.style.display = 'none';
				img.src = 'img/plus.gif';
			} else {
				element.style.display = 'block';
				img.src = 'img/moins.gif';
			}
		} else if(mode == 1) {
			element.style.display = 'block';
			img.src = 'img/moins.gif';
		} else if(mode == -1) {
			element.style.display = 'none';
			img.src = 'img/plus.gif';
		}
	}
}

function mOpenClose(idArray,mode)
{
	for(var i=0;i<idArray.length;i++) {
		openClose(idArray[i],mode);
	}
}