function MM_findObj(n, d) { //v4.01

  var p,i,x;

  if(!d)
  d=document;
  
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document;
	n=n.substring(0,p);
  }
  
  if(!(x=d[n])&&d.all)
  x=d.all[n];
  
  for (i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];
  
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  
  if(!x && d.getElementById)
  x=d.getElementById(n);
  
  return x;

}
//-------------------------------------------------------------------------------------
function MM_validateForm() { //v4.0
  
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  
  for (i=0; i<(args.length-2); i+=3) {
  	test=args[i+2]; val=MM_findObj(args[i]);
    if (val) {
		nm=val.name;
		if ((val=val.value)!="") {
      		if (test.indexOf('isEmail')!=-1) {
				p=val.indexOf('@');
        		if (p<1 || p==(val.length-1))
				errors+='- '+nm+' doit contenir une adresse e-mail.\n';
			}
			else if (test!='R') {
				num = parseFloat(val);
				if (isNaN(val))
				errors+='- '+nm+' doit contenir un nombre.\n';
				if (test.indexOf('inRange') != -1) {
					p=test.indexOf(':');
					min=test.substring(8,p);
					max=test.substring(p+1);
					if (num<min || max<num)
					errors+='- '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n';
    			}
			}
		}
		else if (test.charAt(0) == 'R')
		errors += '- '+nm+' is required.\n';
	}
  }
  
  if (errors)
  
  alert('Un ou plusieurs problèmes on été rencontrés :\n'+errors);
  
  document.MM_returnValue = (errors == '');

}
//------------------------------------------------------------------------------------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//------------------------------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//------------------------------------------------------------------------------------
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//------------------------------------------------------------------------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//------------------------------------------------------------------------------------------------------

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 verif_infos_commandes() {
	
		if ( document.commande.nom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de nom...");
		return false; 
		}
		
		if ( document.commande.prenom.value.length == 0) { 
			alert("Vous n'avez pas mentionné de prenom...");
		return false; 
		}
		
		if ( document.commande.adr1.value.length == 0) { 
			alert("Vous n'avez pas mentionné d'adresse...");
		return false; 
		}
		
		if ( document.commande.cp.value.length == 0) { 
			alert("Vous n'avez pas mentionné de code postal...");
		return false; 
		}
		
		if ( document.commande.ville.value.length == 0) { 
			alert("Vous n'avez pas mentionné de ville...");
		return false; 
		}
		
		if ( document.commande.tel.value.length == 0) { 
			alert("Vous n'avez pas mentionné de numéro de téléphone...");
		return false; 
		}
		
		if ( document.commande.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.commande.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;
		}

/////////////////////////////////////////////////////////////////////
		
	return true;
	}
	
//----------------------------------------------------------------------------------------------------------	

	function DirigerVers() {
		document.commande.submit();
	}

//------------------------------------------------------------------------------------------------------
	function arrondi2(a){ // arrondi à deux chiffres après la virgule

		a=(Math.round(a*100))/100;

		return (a);
	}


//------------------------------------------------------------------------------------------------------
	function total(){
			
		// cernaux de noix + recettes - 125g - 3,45 €
		if (!isNaN(document.commande.art1.value)&&document.commande.art1.value>0){
			if (!document.commande.art1.value==0){
				document.commande.tot1.value=arrondi2(parseFloat(document.commande.art1.value)*3.45);
			}
		}
		else {
			document.commande.art1.value=0;
			document.commande.tot1.value=0;
		}
		// Noix du Périgord AOC en barquette - 1 kg 3,55 €
		if (!isNaN(document.commande.art2.value)&&document.commande.art2.value>0){
			if (!document.commande.art2.value==0){
				document.commande.tot2.value=arrondi2(parseFloat(document.commande.art2.value)*3.75);
			}
		}
		else {
			document.commande.art2.value=0;
			document.commande.tot2.value=0;
		}
		// Noix du Périgord AOC en filet 5 kg 16,25 €
		if (!isNaN(document.commande.art3.value)&&document.commande.art3.value>0){
			if (!document.commande.art3.value==0){
				document.commande.tot3.value=arrondi2(parseFloat(document.commande.art3.value)*16.25);
			}
		}
		else {
			document.commande.art3.value=0;
			document.commande.tot3.value=0;
		}
		// Noix vrac Cat II 5 kg  11,95 €
		if (!isNaN(document.commande.art4.value)&&document.commande.art4.value>0){
			if (!document.commande.art4.value==0){
				document.commande.tot4.value=arrondi2(parseFloat(document.commande.art4.value)*11.95);
			}
		}
		else {
			document.commande.art4.value=0;
			document.commande.tot4.value=0;
		}
		// Noix vrac Cat II 10 kg 22,35 €
		if (!isNaN(document.commande.art5.value)&&document.commande.art5.value>0){
			if (!document.commande.art5.value==0){
				document.commande.tot5.value=arrondi2(parseFloat(document.commande.art5.value)*22.35);
			}
		}
		else {
			document.commande.art5.value=0;
			document.commande.tot5.value=0;
		}
		// Huile de Noix à l'ancienne 25 cl 6,20 €
		if (!isNaN(document.commande.art6.value)&&document.commande.art6.value>0){
			if (!document.commande.art6.value==0){
				document.commande.tot6.value=arrondi2(parseFloat(document.commande.art6.value)*6.20);
			}
		}
		else {
			document.commande.art6.value=0;
			document.commande.tot6.value=0;
		}
		// Huile de Noix à l'ancienne 50 cl 10,60 € 
		if (!isNaN(document.commande.art7.value)&&document.commande.art7.value>0){
			if (!document.commande.art7.value==0){
				document.commande.tot7.value=arrondi2(parseFloat(document.commande.art7.value)*10.60);
			}
		}
		else {
			document.commande.art7.value=0;
			document.commande.tot7.value=0;
		}
		// Huile de Noix Vièrge 1ère pression à froid 25 cl 7,20 €
		if (!isNaN(document.commande.art8.value)&&document.commande.art8.value>0){
			if (!document.commande.art8.value==0){
				document.commande.tot8.value=arrondi2(parseFloat(document.commande.art8.value)*7.20);
			}
		}
		else {
			document.commande.art8.value=0;
			document.commande.tot8.value=0;
		}
		// Huile de Noix Vièrge 1ère pression à froid 50 cl 11,80 €
		if (!isNaN(document.commande.art9.value)&&document.commande.art9.value>0){
			if (!document.commande.art9.value==0){
				document.commande.tot9.value=arrondi2(parseFloat(document.commande.art9.value)*11.80);
			}
		}
		else {
			document.commande.art9.value=0;
			document.commande.tot9.value=0;
		}
		
		// Montant panier
		document.commande.montant_panier.value=
		arrondi2(
		parseFloat(document.commande.tot1.value)+
		parseFloat(document.commande.tot2.value)+
		parseFloat(document.commande.tot3.value)+
		parseFloat(document.commande.tot4.value)+
		parseFloat(document.commande.tot5.value)+
		parseFloat(document.commande.tot6.value)+
		parseFloat(document.commande.tot7.value)+
		parseFloat(document.commande.tot8.value)+
		parseFloat(document.commande.tot9.value)
		);
		
		// Port (fixé à 7 euros pour la france et 34 euros hors france...)
		document.commande.port.value=arrondi2(7);
		if (document.commande.horsfrance.checked) {
			document.commande.port.value=arrondi2(34);
		}
		
		// Total TTC = Montant panier + Port
		document.commande.total_ttc.value=arrondi2(parseFloat(document.commande.montant_panier.value)+parseFloat(document.commande.port.value));
		
		// TVA 5.50
		//document.commande.TVA55.value=arrondi2(parseFloat(document.commande.montant_panier.value)-(parseFloat(document.commande.montant_panier.value)/1.055));
		
		// TVA 19.6
		//document.commande.TVA196.value=arrondi2(parseFloat(document.commande.port.value)-(parseFloat(document.commande.port.value)/1.196));
		
		// Total HT = Total TTC - TVA 5.50 - TVA 19.6
		//document.commande.total_ht.value=arrondi2(parseFloat(document.commande.total_ttc.value)-parseFloat(document.commande.TVA55.value)-parseFloat(document.commande.TVA196.value));
		
		// Total à payer = Total TTC
		document.commande.total_a_payer.value=arrondi2(parseFloat(document.commande.total_ttc.value));	
		
	return true;
	}
	
//------------------------------------------------------------------------------------------------------			
	
	function effacer_champ(element) {
		
		element.value="";
	}			

//------------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------------

/*
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 ALT=Menu 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++;
		}
	}


//----------------------------------------------------------------------------------------------------------