//----------------------------------------------------------------------------------------------------------

function champs_livraison_domicile_ok() {
	
		if ( document.adr_livraison.nom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de nom...");
		return false; 
		}
		
		if ( document.adr_livraison.prenom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de prenom...");
		return false; 
		}
		
		if ( document.adr_livraison.adr1.value.length == 0) { 
			alert("Vous n'avez pas mentionné d'adresse...");
		return false; 
		}
		
		if ( document.adr_livraison.cp.value.length == 0) { 
			alert("Vous n'avez pas mentionné de code postal...");
		return false; 
		}
		
		if ( document.adr_livraison.ville.value.length == 0) { 
			alert("Vous n'avez pas mentionné de ville...");
		return false; 
		}
		
		if ((document.adr_livraison.telfix.value.length == 0)&&(document.adr_livraison.telptb.value.length == 0)) { 
			alert("Vous n'avez pas mentionné de numéro de téléphone...");
		return false; 
		}
		
	return true;
	}
	
//----------------------------------------------------------------------------------------------------------	
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------


function champs_bergerie_ok() {
	
		if ( document.maj_bergeries.nom_bergerie.value.length == 0) { 
			alert("Nom de la bergerie obligatoire");
		return false; 
		}
		
		if (( document.maj_bergeries.nom_village.value == '')&&(document.maj_bergeries.new_village.value.length == 0)) { 
			alert("Si vous désignez 'Nouveau...' dans la liste de villages, inscrivez le nom de celui-ci");
		return false; 
		}
		
		if (( document.maj_bergeries.nom_village.value != '')&&(document.maj_bergeries.new_village.value.length != 0)) { 
			alert("Attention, vous enregistrez un nouveau village alors qu'un choix a déjà été effectué");
		return false; 
		}
		
		var fiche = document.maj_bergeries.fiche_bergerie.value;
		var position = fiche.indexOf(" ",0);
		
		if (position==-1) {
			if ( fiche.length == 0) { 
				alert("Nom de la fiche de la bergerie obligatoire");
				return false; 
			}
		}
		else {
				alert ("Attention, le nom de la fiche ne doit pas contenir d'espace(s) !")
				return false;
		}
		
	return true;
}

//------------------------------------------------------------------------------------------------------

function champs_chef_ok() {
	
			if ( document.maj_chefs.nom_chef.value.length == 0) { 
				alert("Nom du Chef obligatoire");
			return false; 
			}
		
			if (document.maj_chefs.prenom_chef.value.length == 0) { 
				alert("Prenom du Chef obligatoire");
			return false; 
			}
			
			if (document.maj_chefs.nom_ville.value.length == 0) { 
				alert("Ville du chef obligatoire");
			return false; 
			}
		
			var fiche = document.maj_chefs.fiche_chef.value;
			var position = fiche.indexOf(" ",0);
			
			if (position==-1) {	
				if (fiche.length == 0) { 
					alert("Nom de la fiche du Chef obligatoire");
					return false;
				}
			}
			
			else {
				alert ("Attention, le nom de la fiche ne doit pas contenir d'espace(s) !")
				return false;
			} 
				
	return true;
}
	
//------------------------------------------------------------------------------------------------------

function champs_recette_ok() {
	
		if ( document.maj_recettes.nom_recette.value.length == 0) { 
			alert("Nom de la recette obligatoire");
		return false; 
		}
		
		var fiche = document.maj_recettes.fiche_recette.value;
		var position = fiche.indexOf(" ",0);
		
		if (position==-1) {
			if ( fiche.length == 0) { 
				alert("Nom de la fiche de la recette obligatoire");
				return false; 
			}
		}
		else {
				alert ("Attention, le nom de la fiche ne doit pas contenir d'espace(s) !")
				return false;
		}
		

	return true;
}

//------------------------------------------------------------------------------------------------------

function confirmation(nom_form)
	{
	var temp = nom_form.name.substr(0,5);
	if (temp == "suppr") {
		if (confirm('Confirmez-vous la suppression de cet élément ?'))	{
			nom_form.submit();
		}
		else {
			alert('La suppression n\'a pas été prise en compte.');
		}
	}
	else {
		if (confirm('Confirmez-vous l\'enregistement des modifications pour cet élément ?')) {
			nom_form.submit();
		}
		else {
			alert('Vos modifications n\'ont pas été prises en compte.');
		}
	}
}
//---------------------------------------------------------------------------------------------------------

function Popup(page,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

//----------------------------------------------------------------------------------------------------------

function champs_inscription_ok() {
	
		if ( document.inscription.nom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de nom...");
		return false; 
		}
		
		if ( document.inscription.prenom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de prenom...");
		return false; 
		}
		
		if ( document.inscription.adr1.value.length == 0) { 
			alert("Vous n'avez pas mentionné d'adresse...");
		return false; 
		}
		
		if ( document.inscription.cp.value.length == 0) { 
			alert("Vous n'avez pas mentionné de code postal...");
		return false; 
		}
		
		if ( document.inscription.ville.value.length == 0) { 
			alert("Vous n'avez pas mentionné de ville...");
		return false; 
		}
		
		if ( document.inscription.tel.value.length == 0) { 
			alert("Vous n'avez pas mentionné de numéro de téléphone...");
		return false; 
		}
		
		if ( document.inscription.email.value.length == 0) { 
			alert("Vous n'avez pas mentionné d'adresse e-mail...");
		return false; 
		}

/////////////// Verification de la validité de l'adresse e-mail/////////////
		
		var email = document.inscription.email.value;
		var arobase = email.indexOf("@");
		if (arobase == -1) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}
	
		// présence et position du point après @
		var point = email.indexOf(".", arobase);
		if ((point == -1) || (point == (arobase + 1))) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}
		
		// présence d'au moins deux caractères après le dernier point
		var point = email.lastIndexOf(".");
		if (((point + 1) == email.length)||((point + 2) == email.length)){
			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}
		
		// présence d'au moins deux caractères avant @
		if (arobase <2) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}	
		
		// non-présence de deux points consécutivement
		var points = email.indexOf("..")
		if (points != -1) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}

/////////////////////////////////////////////////////////////////////
		
		if ( document.inscription.pass.value == "") { 
			alert(" Vous devez entrer un mot de passe et le confirmer... ");
		return false; 
		}
		
		if ( document.inscription.pass.value != document.inscription.pass2.value) { 
			alert(" Vous devez entrer deux fois le même mot de passe... ");
		return false; 
		}
		
		
	return true;
	}

//----------------------------------------------------------------------------------------------------------

function champs_inscription_saveurs_ok() {
	
		if ( document.inscription.nom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de nom...");
		return false; 
		}
		
		if ( document.inscription.prenom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de prenom...");
		return false; 
		}
		
		if ( document.inscription.adr1.value.length == 0) { 
			alert("Vous n'avez pas mentionné d'adresse...");
		return false; 
		}
		
		if ( document.inscription.cp.value.length == 0) { 
			alert("Vous n'avez pas mentionné de code postal...");
		return false; 
		}
		
		if ( document.inscription.ville.value.length == 0) { 
			alert("Vous n'avez pas mentionné de ville...");
		return false; 
		}
		
		if ( document.inscription.tel.value.length == 0 && document.inscription.telptb.value.length == 0 ) { 
			alert("Vous n'avez pas mentionné de numéro de téléphone...");
		return false; 
		}
		
		
	return true;
	}
	
//----------------------------------------------------------------------------------------------------------	
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
	
	function DirigerVers() {
		document.commande.submit();
	}

//------------------------------------------------------------------------------------------------------

	function maj_somme(){
		
			var base=document.commande.base_montant.value;
			
			document.commande.montant.value=parseInt(base);
							
			document.commande.montant.value=parseInt(document.commande.montant.value)*parseInt(document.commande.quantite.value);
	
			return true;
	}
	
//------------------------------------------------------------------------------------------------------

	
	function maj_somme_demi(){
	
			var base=document.commande.base_montant.value;
		
			document.commande.montant.value=parseInt(base);
						
			document.commande.montant.value=parseInt(document.commande.montant.value)*parseInt(document.commande.quantite.value);
			
			return true;
	}	

//------------------------------------------------------------------------------------------------------

	
	function maj_somme_selection(){
		
		if (document.commande.quantite1){
			if (document.commande.quantite1.value>10){document.commande.quantite1.value=10}
			if (document.commande.quantite1.value<0){document.commande.quantite1.value=0}
			if (document.commande.quantite1.value==''){document.commande.quantite1.value=0}
			document.commande.montant1.value=parseInt(document.commande.base_montant1.value)*parseInt(document.commande.quantite1.value);
			document.commande.montant.value = document.commande.montant1.value ;
		}
		
		if (document.commande.quantite2){
			if (document.commande.quantite2.value>10){document.commande.quantite2.value=10}
			if (document.commande.quantite2.value<0){document.commande.quantite2.value=0}
			if (document.commande.quantite2.value==''){document.commande.quantite2.value=0}
			document.commande.montant2.value=parseInt(document.commande.base_montant2.value)*parseInt(document.commande.quantite2.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant2.value) ;
		}
		
		if (document.commande.quantite3){
			if (document.commande.quantite3.value>10){document.commande.quantite3.value=10}
			if (document.commande.quantite3.value<0){document.commande.quantite3.value=0}
			if (document.commande.quantite3.value==''){document.commande.quantite3.value=0}
			document.commande.montant3.value=parseInt(document.commande.base_montant3.value)*parseInt(document.commande.quantite3.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant3.value) ;
		}
		
		if (document.commande.quantite4){
			if (document.commande.quantite4.value>10){document.commande.quantite4.value=10}
			if (document.commande.quantite4.value<0){document.commande.quantite4.value=0}
			if (document.commande.quantite4.value==''){document.commande.quantite4.value=0}
			document.commande.montant4.value=parseInt(document.commande.base_montant4.value)*parseInt(document.commande.quantite4.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant4.value) ;
		}
		
		if (document.commande.quantite5){
			if (document.commande.quantite5.value>10){document.commande.quantite5.value=10}
			if (document.commande.quantite5.value<0){document.commande.quantite5.value=0}
			if (document.commande.quantite5.value==''){document.commande.quantite5.value=0}
			document.commande.montant5.value=parseInt(document.commande.base_montant5.value)*parseInt(document.commande.quantite5.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant5.value) ;
		}
		
		if (document.commande.quantite6){
			if (document.commande.quantite6.value>10){document.commande.quantite6.value=10}
			if (document.commande.quantite6.value<0){document.commande.quantite6.value=0}
			if (document.commande.quantite6.value==''){document.commande.quantite6.value=0}
			document.commande.montant6.value=parseInt(document.commande.base_montant6.value)*parseInt(document.commande.quantite6.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant6.value) ;
		}
		
		if (document.commande.quantite7){
			if (document.commande.quantite7.value>10){document.commande.quantite7.value=10}
			if (document.commande.quantite7.value<0){document.commande.quantite7.value=0}
			if (document.commande.quantite7.value==''){document.commande.quantite7.value=0}
			document.commande.montant7.value=parseInt(document.commande.base_montant7.value)*parseInt(document.commande.quantite7.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant7.value) ;
		}
		
		if (document.commande.quantite8){
			if (document.commande.quantite8.value>10){document.commande.quantite8.value=10}
			if (document.commande.quantite8.value<0){document.commande.quantite8.value=0}
			if (document.commande.quantite8.value==''){document.commande.quantite8.value=0}
			document.commande.montant8.value=parseInt(document.commande.base_montant8.value)*parseInt(document.commande.quantite8.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant8.value) ;
		}
		
		if (document.commande.quantite9){
			if (document.commande.quantite9.value>10){document.commande.quantite9.value=10}
			if (document.commande.quantite9.value<0){document.commande.quantite9.value=0}
			if (document.commande.quantite9.value==''){document.commande.quantite9.value=0}
			document.commande.montant9.value=parseInt(document.commande.base_montant9.value)*parseInt(document.commande.quantite9.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant9.value) ;
		}
		
		if (document.commande.quantite10){
			if (document.commande.quantite10.value>10){document.commande.quantite10.value=10}
			if (document.commande.quantite10.value<0){document.commande.quantite10.value=0}
			if (document.commande.quantite10.value==''){document.commande.quantite10.value=0}
			document.commande.montant10.value=parseInt(document.commande.base_montant10.value)*parseInt(document.commande.quantite10.value);
			document.commande.montant.value = parseInt(document.commande.montant.value) + parseInt(document.commande.montant10.value) ;
		}
	}

//------------------------------------------------------------------------------------------------------			
	
	function effacer_champ(element) {
		
		element.value="";
	}			

//------------------------------------------------------------------------------------------------------

function champs_selection_ok() {
	
			if ( document.ajouter_selection.ref_selection.value.length == 0) { 
				alert("Référence de la sélection obligatoire");
			return false; 
			}
		
			if (document.ajouter_selection.designation_selection.value.length == 0) { 
				alert("Désignation de la sélection obligatoire");
			return false; 
			}
			
			if (document.ajouter_selection.prix_selection.value.length == 0) { 
				alert("Prix de la sélection obligatoire");
			return false; 
			} 
				
	return true;
}

//----------------------------------------------------------------------------------------------------------

function champs_modification_client_ok() {
	
		if ( document.modification.nom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de nom...");
		return false; 
		}
		
		if ( document.modification.prenom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de prenom...");
		return false; 
		}
		
		if ( document.modification.adr1.value.length == 0) { 
			alert("Vous n'avez pas mentionné d'adresse...");
		return false; 
		}
		
		if ( document.modification.cp.value.length == 0) { 
			alert("Vous n'avez pas mentionné de code postal...");
		return false; 
		}
		
		if ( document.modification.ville.value.length == 0) { 
			alert("Vous n'avez pas mentionné de ville...");
		return false; 
		}
		
		if ( document.modification.tel.value.length == 0) { 
			alert("Vous n'avez pas mentionné de numéro de téléphone...");
		return false; 
		}
		
		if ( document.modification.email.value.length == 0) { 
			alert("Vous n'avez pas mentionné d'adresse e-mail...");
		return false; 
		}

/////////////// Verification de la validité de l'adresse e-mail/////////////
		
		var email = document.modification.email.value;
		var arobase = email.indexOf("@");
		if (arobase == -1) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}
	
		// présence et position du point après @
		var point = email.indexOf(".", arobase);
		if ((point == -1) || (point == (arobase + 1))) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}
		
		// présence d'au moins deux caractères après le dernier point
		var point = email.lastIndexOf(".");
		if (((point + 1) == email.length)||((point + 2) == email.length)){
			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}
		
		// présence d'au moins deux caractères avant @
		if (arobase <2) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}	
		
		// non-présence de deux points consécutivement
		var points = email.indexOf("..")
		if (points != -1) {
  			alert("L'adresse e-mail mentionnée n'est pas valide...");
  			return false;
		}

/////////////////////////////////////////////////////////////////////
		
		if ( document.modification.passwd.value == "") { 
			alert(" Vous devez entrer un mot de passe et le confirmer... ");
		return false; 
		}
		
		if ( document.modification.passwd.value != document.modification.passwd2.value) { 
			alert(" Vous devez entrer deux fois le même mot de passe... ");
		return false; 
		}
		
		
	return true;
	}

//----------------------------------------------------------------------------------------------------------

/*
SCRIPT EDITE SUR L'EDITEUR JAVASCRIPT
http://www.editeurjavascript.com
*/
imgPath = new Array;
SiClickGoTo = new Array;
if (document.images)
	{
	i0 = new Image;
	i0.src = 'preparez/images/0001.jpg';
	SiClickGoTo[0] = "";
	imgPath[0] = i0.src;
	i1 = new Image;
	i1.src = 'preparez/images/0002.jpg';
	SiClickGoTo[1] = "";
	imgPath[1] = i1.src;
	i2 = new Image;
	i2.src = 'preparez/images/0003.jpg';
	SiClickGoTo[2] = "";
	imgPath[2] = i2.src;
	i3 = new Image;
	i3.src = 'preparez/images/0004.jpg';
	SiClickGoTo[3] = "";
	imgPath[3] = i3.src;
	i4 = new Image;
	i4.src = 'preparez/images/0005.jpg';
	SiClickGoTo[4] = "";
	imgPath[4] = i4.src;
	i5 = new Image;
	i5.src = 'preparez/images/0006.jpg';
	SiClickGoTo[5] = "";
	imgPath[5] = i5.src;
	i6 = new Image;
	i6.src = 'preparez/images/0007.jpg';
	SiClickGoTo[6] = "";
	imgPath[6] = i6.src;
	i7 = new Image;
	i7.src = 'preparez/images/0008.jpg';
	SiClickGoTo[7] = "";
	imgPath[7] = i7.src;
	i8 = new Image;
	i8.src = 'preparez/images/0009.jpg';
	SiClickGoTo[8] = "";
	imgPath[8] = i8.src;
	i9 = new Image;
	i9.src = 'preparez/images/0010.jpg';
	SiClickGoTo[9] = "";
	imgPath[9] = i9.src;
	i10 = new Image;
	i10.src = 'preparez/images/0011.jpg';
	SiClickGoTo[10] = "";
	imgPath[10] = i10.src;
	i11 = new Image;
	i11.src = 'preparez/images/0012.jpg';
	SiClickGoTo[11] = "";
	imgPath[11] = i11.src;
	}
a = 0;
function ejs_img_fx(img)
	{
	if(img && img.filters && img.filters[0])
		{
		img.filters[0].apply();
		img.filters[0].play();
		}
	}

function StartAnim()
	{
	if (document.images)
		{
		document.write('<A HREF="liste_recettes.php" onClick="ImgDest();return(false)"><IMG SRC="preparez/images/0001.jpg" BORDER=0 NAME=defil style="filter:progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=100,Duration=1)"></A>');
		defilimg()
		}
	else
		{
		document.write('<A HREF="liste_recettes.php"><IMG SRC="preparez/images/0001.jpg" BORDER=0></A>')
		}
	}
function ImgDest()
	{
	document.location.href = "#";
	}
/*
function ImgDest()
	{
	document.location.href = SiClickGoTo[a-1];
	}
*/
function defilimg()
	{
	if (a == 12)
		{
		a = 0;
		}
	if (document.images)
		{
		ejs_img_fx(document.defil)
		document.defil.src = imgPath[a];
		tempo3 = setTimeout("defilimg()",4000);
		a++;
		}
	}


//----------------------------------------------------------------------------------------------------------