// JavaScript Document


// affichage de la rubrique en cours

	function afficheRubriqueActive(rub)
	{
		if(rub!="0")
		{
			if (rub==8) document.getElementById(rub).className="temoignages menuActif";
			else document.getElementById(rub).className="menuActif";
		}
	}
	
	
// elasticité en hauteur du pied de page
	
	function piedElastique()
	{
		hauteurPage = document.getElementById("repere").offsetTop;
		hauteurOccupee = document.getElementById("global").offsetHeight + document.getElementById("pied").offsetHeight;
		if(hauteurOccupee < hauteurPage)
		{
			if(document.all)
			{
				window.scroll(0,0);
			}
			hauteurElastique = hauteurPage - hauteurOccupee;
			document.getElementById("elastique").style.height = hauteurElastique +"px";
		}
		else
		{
			document.getElementById("elastique").style.height = 1 +"px";
		}
		
	}
	
	function piedElastique2()
	{
		if(document.all)
		{
			window.scroll(0,0);
		}
		hauteurPage = document.getElementById("repere").offsetTop;
		hauteurOccupee = document.getElementById("global").offsetHeight + document.getElementById("pied").offsetHeight;
		if(hauteurOccupee < hauteurPage)
		{
			
			hauteurElastique = hauteurPage - hauteurOccupee;
			document.getElementById("elastique").style.height = hauteurElastique +"px";
		}
		else
		{
			document.getElementById("elastique").style.height = 1 +"px";
		}
		
	}
	

// survols Macromedia
	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_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_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];}
	}
	
	
// contrôle du formulaire
	function validationForm(monform) // validation des formualires
		{
			var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
			
			if(monform.nom)
			{
				monform.nom.style.borderColor="#d5d5d5";
			}
			
			if(monform.email)
			{
				monform.email.style.borderColor="#d5d5d5";
			}
			/*if(monform.message)
			{
				monform.message.style.borderColor="#d5d5d5";
			}*/
			
			
			if(monform.nom)
			{
				if (monform.nom.value=='')
				{
					alert("Veuillez indiquer votre nom");
					monform.nom.style.borderColor="#b8563a";
					monform.nom.focus();
					return false;
				}
			}
			if(monform.email)
			{
				if (monform.email.value=='')
				{
					alert("Veuillez indiquer votre adresse email");
					monform.email.style.borderColor="#b8563a";
					monform.email.focus();
					return false;
				}
				if(!reg_email.test(monform.email.value))
				{
					alert("Le format de votre adresse email est invalide");
					monform.email.style.borderColor="#b8563a";
					monform.email.focus();
					return false;
				}
			}
			if(monform.cp)
			{
				if (monform.cp.value=='')
				{
					alert("Veuillez indiquer votre code postal");
					monform.cp.style.borderColor="#b8563a";
					monform.cp.focus();
					return false;
				}
			}
			if(monform.ville)
			{
				if (monform.ville.value=='')
				{
					alert("Veuillez indiquer votre ville");
					monform.ville.style.borderColor="#b8563a";
					monform.ville.focus();
					return false;
				}
			}
			if(monform.pays)
			{
				if (monform.pays.value=='')
				{
					alert("Veuillez indiquer votre pays");
					monform.pays.style.borderColor="#b8563a";
					monform.pays.focus();
					return false;
				}
			}
			if(monform.adresse)
			{
				if (monform.adresse.value=='')
				{
					alert("Veuillez indiquer votre adresse");
					monform.adresse.style.borderColor="#b8563a";
					monform.adresse.focus();
					return false;
				}
			}
		
			return true;
		}
		
	
	
// contrôle inscription
		function validationForm2(monform) 
		{
			var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
			
			if(monform.nom)
			{
				monform.nom.style.borderColor="#012d23";
			}
			if(monform.prenom)
			{
				monform.prenom.style.borderColor="#012d23";
			}
			if(monform.adresse)
			{
				monform.adresse.style.borderColor="#012d23";
			}
			if(monform.pays)
			{
				monform.pays.style.borderColor="#012d23";
			}
			if(monform.tel)
			{
				monform.tel.style.borderColor="#012d23";
			}
			if(monform.email)
			{
				monform.email.style.borderColor="#012d23";
			}
			
			
			if(monform.nom)
			{
				if (monform.nom.value=='')
				{
					alert("Veuillez indiquer votre nom");
					monform.nom.style.borderColor="#b8563a";
					monform.nom.focus();
					return false;
				}
			}
			if(monform.prenom)
			{
				if (monform.prenom.value=='')
				{
					alert("Veuillez indiquer votre prénom");
					monform.prenom.style.borderColor="#b8563a";
					monform.prenom.focus();
					return false;
				}
			}
			if(monform.adresse)
			{
				if (monform.adresse.value=='')
				{
					alert("Veuillez indiquer votre adresse");
					monform.adresse.style.borderColor="#b8563a";
					monform.adresse.focus();
					return false;
				}
			}
			if(monform.pays)
			{
				if (monform.pays.value=='')
				{
					alert("Veuillez indiquer votre pays");
					monform.pays.style.borderColor="#b8563a";
					monform.pays.focus();
					return false;
				}
			}
			if(monform.tel)
			{
				if (monform.tel.value=='')
				{
					alert("Veuillez indiquer votre n° de téléphone");
					monform.tel.style.borderColor="#b8563a";
					monform.tel.focus();
					return false;
				}
			}
			if(monform.email)
			{
				if (monform.email.value=='')
				{
					alert("Veuillez indiquer votre adresse email");
					monform.email.style.borderColor="#b8563a";
					monform.email.focus();
					return false;
				}
				if(!reg_email.test(monform.email.value))
				{
					alert("Le format de votre adresse email est invalide");
					monform.email.style.borderColor="#b8563a";
					monform.email.focus();
					return false;
				}
			}
			return true;
		}
		
		
// contrôle identification
		function validationForm3(monform) 
		{
			var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
			
			if(monform.email)
			{
				monform.email.style.borderColor="#012d23";
			}
			if(monform.mdp)
			{
				monform.mdp.style.borderColor="#012d23";
			}
			
			
			if(monform.email)
			{
				if (monform.email.value=='')
				{
					alert("Veuillez indiquer votre adresse email");
					monform.email.style.borderColor="#b8563a";
					monform.email.focus();
					return false;
				}
				if(!reg_email.test(monform.email.value))
				{
					alert("Le format de votre adresse email est invalide");
					monform.email.style.borderColor="#b8563a";
					monform.email.focus();
					return false;
				}
			}
			if(monform.mdp)
			{
				if (monform.mdp.value=='')
				{
					alert("Veuillez indiquer votre mot de passe");
					monform.mdp.style.borderColor="#b8563a";
					monform.mdp.focus();
					return false;
				}
			}
			return true;
		}
		
		
// pour modifier l'opacité des input type image		
		function opaciteOn(bouton)
		{
			document.getElementById(bouton).className="opaciteOn";
		}
		
		function opaciteOff(bouton)
		{
			document.getElementById(bouton).className="opaciteOff";
		}
		
		
// vérification acceptation cgv
		
		function cgv(mode)
		{
			if(document.accepteCgv.caseCgv.checked==false)
			{
				alert("Vous devez accepter les Conditions Générales de Vente en cochant la case correspondante");
				return(false);
			}
			else
			{
				if(mode == 'cheque')
				{
					window.open('confirmation.php','_self');
				}
				else if(mode == 'cb')
				{
					// lien vers le site de la banque pour paiement cb
				}
			}
		}
		function verifLuCGV2()
		{
			if (document.accepteCgv.caseCgv.checked == true) return(true);
			else 
			{
				alert("Vous devez accepter les Conditions Générales de Vente en cochant la case correspondante");
				return(false);
			}
		}		
		