function Verif(){
	var validation = "Val";
	var valchamp = "";
	var valchampconcat = "";
	var cptr=0;
	var premier=0;
	elements = document.formulaire.length; // calcul du nombre de champs du tableau
	nbreElements = elements-2; // suppression des 2 derniers champs (2 boutons) du nombre total de champ
	for(i=0; i<nbreElements; i++){
		if(document.formulaire.elements[i].name.indexOf(validation)==0){ //si le nom du champ contient Val => ncessit de le valider
			if(document.formulaire.elements[i].value==""){ //si la valeur du champ est vide
				valchamp = document.formulaire.elements[i].name.substring(3,document.formulaire.elements[i].name.length); //suppression des lettres Val pour affichage de l'alert des champs non remplis
				if (cptr==0){
					valchampconcat = valchamp; // si c'est le 1er champ  tre concatn, pas de virgule au dbut
					premier=i; //indice du premier champ non renseign  valider pour la prise de focus en fin de verification de formulaire
				} else {
					valchampconcat = valchampconcat+", "+valchamp; // concatenation des diffrents champs non valids pour l'affichage dans l'alert
				}
				cptr++;
			} 
		}
	}
	
	
	
	
		if(valchampconcat!=""){ // si la concatnation des champs non valids n'est pas vide, on affiche une alert qui repertorie les champs  remplir
			alert("Vous n'avez pas rempli le(s) champ(s) "+valchampconcat);
			document.formulaire.elements[premier].focus(); //donne le focus au 1er champ non rempli  valider
			return false;		
		}  else {
		
		
		
		
		if(document.formulaire.elements[5].value!="") {
				var valeurEmail = document.formulaire.elements[5].value;
				var at="@";
				var dot=".";
				var lat=valeurEmail.indexOf(at);
				var lstr=valeurEmail.length;
				var ldot=valeurEmail.indexOf(dot);	
		
				
				
				if(valeurEmail.indexOf(at)==-1 || valeurEmail.indexOf(at)==0 || valeurEmail.indexOf(at)==lstr) {
						   alert("email non valide");
						   document.formulaire.elements[5].focus();
						   return false;
						   }
				if (valeurEmail.indexOf(dot)==-1 || valeurEmail.indexOf(dot)==0 || valeurEmail.indexOf(dot)==lstr){
						   alert("email non valide");
						   document.formulaire.elements[5].focus();
						   return false;
						   }
			
				 if (valeurEmail.indexOf(at,(lat+1))!=-1){	
						   alert("email non valide");
						   document.formulaire.elements[5].focus();
						   return false;
				 }
			
				 if (valeurEmail.substring(lat-1,lat)==dot || valeurEmail.substring(lat+1,lat+2)==dot){
						   alert("email non valide");
						   document.formulaire.elements[5].focus();
						   return false;					
				}
				 if (valeurEmail.indexOf(dot,(lat+2))==-1){	
								   alert("email non valide");
								   document.formulaire.elements[5].focus();
								   return false;	
				 }
				 if (valeurEmail.indexOf(" ")!=-1){
								   alert("email non valide");
								   document.formulaire.elements[5].focus();
								   return false;						 
				 } 
				 
				 
				 
			
			
			
			
			} else {
					
				/*return true;*/
			}
			
			
			
			
			
		} 
   
	
}
   
	

	
	
function validationFormulaire(frm) {
 if(frm.name=="admin"){
		var textAlert="";
		if(frm.elements[9].value=="Suppression"){
			confirm("Voulez-vous vraiment supprimer cette oeuvre ?");
		} else {

			for (i=0; i<frm.length-1; i++){
				if(frm.elements[9].value=="Ajout"){
				
					if(i<5 && frm.elements[i].value=="") {
						textAlert= "Les champs prcds d'une toile doivent tre remplis";
						if(frm.elements[0].value==""){
							textAlert= textAlert+"\n"+"un titre doit tre saisi";
						}
						if(frm.elements[1].value==""){
							textAlert= textAlert+"\n"+"une image doit tre slectionne";
							return false; 
						} 						
						if(frm.elements[2].value==""){
						   textAlert= textAlert+"\n"+"Les dimensions doivent tre saisies";
						}     
						if(frm.elements[3].value==""){
						   textAlert= textAlert+"\n"+"Une anne doit tre rentre";
						}   
						if (isNaN(parseInt(frm.elements[3].value))){
						   textAlert= textAlert+"\n"+"Une anne doit tre un nombre a 4 chiffres";
						}  
						if(frm.elements[4].value==""){
						   textAlert= textAlert+"\n"+"Une prix doit tre rentr";
						}  
						alert(textAlert);
						frm.elements[i].focus();
						return false;              
					}
					
				} 
				if(frm.elements[10].value=="Modification"){
					if(i<5 && i!=1 && frm.elements[i].value=="") {
						if(frm.elements[0].value==""){
							textAlert= textAlert+"\n"+"un titre doit tre saisi";
						}
						if(frm.elements[2].value==""){
						   textAlert= textAlert+"\n"+"Les dimensions doivent tre saisies";
						}     
						if (isNaN(parseInt(frm.elements[3].value))){
							textAlert= textAlert+"\n"+"Une anne doit tre rentre";
						}  
						if(frm.elements[4].value==""){
						   textAlert= textAlert+"\n"+"Une prix doit tre rentr";
						}  
						alert(textAlert);
						frm.elements[i].focus();
						return false;              

					}
				}

			}
		
		}	
	
	}
			
}


