/*
   ############################################################
   #             Script par: Damien LOUVIN                    #
   #                    27/12/2008                            #
   #   Tout droits réservés.                                  #
   #   Reproduction, modification ou simple utilisation       #
   #   interdite sans autorisation préalable                  #
   #                                                          #
   #   All rights reserved.                                   #
   #   reproduction, modification or simple use               #
   #   not allowed without prior permission                   #
   ############################################################
*/
function ValidChar(Mode,Evt){
	switch(Mode){
		case "mail" :rr="^[a-zA-Z0-9@.\x08\x00_-]"; break;
		case "alpha" :rr="^[a-zA-Z \x08\x00]"; break;
		case "alphaplus" :rr="^[a-zA-Z'éèêëàâäûüùçïîìòôö. \x08\x00-]"; break;
		case "alphanum" :rr="^[a-zA-Z0-9 \x08\x00]"; break;
		case "alphanumplus" :rr="^[a-zA-Z0-9 '?!:_+,;°%€éèêëàâäûüùçïîìòôö. \x08\x00\x0D\x22\x2D]"; break;
		case "num" :rr="^[0-9\x08\x00]"; break;
		case "addr" :rr="^[a-zA-Z0-9.'()éèêëàâäûüùçïîìòôö .\x08\x00-]"; break;
		case "date" :rr="^[0-9\/\x08\x00]"; break;
		case "floodcode" :rr="^[(abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789)(\x08\x00)]"; break;

	}
	rt=new RegExp(rr,"g");
	
	if(navigator.appName=="Netscape"){
		rx=rt.test(String.fromCharCode(parseInt(Evt.which)));
	}else if(navigator.appName=="Microsoft Internet Explorer"){
		rx=rt.test(String.fromCharCode(event.keyCode));
	};
	if(rx==false){return false}
	
};

//##############################################################################################################
function AvSubmitForm(){
	Fcolor="#F3E961";
	Fcolor2="#EFF9FE";
	RegMail="^([a-zA-Z]+(\.|-|_)?[a-zA-Z0-9]*)*[^\.|-|_]@([a-zA-Z]+(\.|-|_)?[a-zA-Z0-9]*)*[a-zA-Z]+[\.]{1}[a-zA-Z]{2,4}$";
	ErrMsg="\Les champs obligatoires suivant ne sont pas remplis correctement:   ";
	Form0=document.Form1;
	mail=Form0.ch_2.value;
	sujet=Form0.ch_1.value;
	msg=Form0.ch_3.value;
	floodcode=Form0.ch_4.value;
	ret=0;
	f=Form0;
	tt=new RegExp (RegMail);
	VerMail=tt.test(mail);


		
		
		if(sujet=="" || sujet.length==1){
			f.ch_1.style.backgroundColor=Fcolor;
			ErrMsg+="\n  -Sujet"
			ret++;
		} else if (sujet.length>=2){
			f.ch_1.style.backgroundColor=Fcolor2;
		}
		if(mail=="" || VerMail==false){
			f.ch_2.style.backgroundColor=Fcolor;
			ErrMsg+="\n  -Adresse EMail"
			ret++;
		}else if(VerMail==true){
			f.ch_2.style.backgroundColor=Fcolor2;
		}
		if(msg=="" || msg.length==1){
			f.ch_3.style.backgroundColor=Fcolor;
			ErrMsg+="\n  -Message";
			ret++;
		} else if(msg.length>=2){
			f.ch_3.style.backgroundColor=Fcolor2;
		}
		if(floodcode=="" || floodcode.length<=4){
			f.ch_4.style.backgroundColor=Fcolor;
			ErrMsg+="\n  -Code de sécurité";
			ret++;
		} else if(floodcode.length==5){
			f.ch_4.style.backgroundColor=Fcolor2;
		}

	if(ret>0){
		window.alert(ErrMsg);
		rett=false;
	}else if(ret==0){
		Form0.submit();
		rett=true;
	}
return rett;
}
