var pattern_email = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"
var pattern_url_http = "http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"
var pattern_email_simple = "@"


/* Rest of division by 97 is the last to number of value */

function checkRestDiv(ffield, div) {

        val = ffield.value;
	valToCheck = "";
	for (i=0;i<val.length;i++) {
		if ((val[i] <= '9') && (val[i] >= '0')) {
			valToCheck = valToCheck + val[i];
		}
	}
	if (val.length == 0) {
		return true;
	}
	if (valToCheck.length < 2) {
		alert ("Numéro invalide / Ongeldig nummer");
		return false;
	}
	
	val1 = valToCheck.substring(0, valToCheck.length - 2);
	/*alert ("val1 : " + val1);*/
	val2 = valToCheck.substring(valToCheck.length-2);

	/* If the rest is 00 then the value given is div, doing next command doesn't change
	   the val2 if val2 != div and put it to 00 if val2 == div
	 */
	 
	val2 = val2 % div;
	
	/*alert ("val2 : " + val2);*/
	
	if ((val1 % div) == val2) {
		return true;
	}
	else {
		alert("Numéro invalide / Ongeldig nummer");
		return false;
	}
}

function checkRestDivCompl(ffield, div) {

        val = ffield.value;
	valToCheck = "";
	for (i=0;i<val.length;i++) {
		if ((val[i] <= '9') && (val[i] >= '0')) {
			valToCheck = valToCheck + val[i];
		}
	}
	if (val.length == 0) {
		return true;
	}
	if (valToCheck.length < 2) {
		alert ("Numéro invalide / Ongeldig nummer");		
		return false;
	}
	
	val1 = valToCheck.substring(0, valToCheck.length - 2);
	val2 = valToCheck.substring(valToCheck.length-2);
	
	
	if ((div -(val1 % div)) == val2) {
		return true;
	}
	else {
		alert("Numéro invalide / Ongeldig nummer");		
		return false;
	}
}
	

/* Test if a character is white-space assimilated */
function maIsWhiteSpace(c)
{
	return ((c==' ')|(c=='\t'));
}

/* Trim left white-space of a string */
function maTrimLeft(s)
{
	rs="";
	for (i=0; i<s.length; i++)
	{
		if (!maIsWhiteSpace(s.charAt(i)))
		{
			rs=s.substring(i, s.length);
			break;
		}
	}
	return rs;
}

/* Trim right white-space of a string */
function maTrimRight(s)
{
	rs="";

	for (i=s.length-1; i>=0; i--)
	{
		if (!maIsWhiteSpace(s.charAt(i)))
		{
			rs=s.substring(0, i+1);
			break;
		}
	}
	return rs;
}

/* Trim white space of a string */
function maTrim(s)
{
	return maTrimLeft(maTrimRight(s));
}

/* Display an error related to an input field */
function maInputDisplayError(ffield, t)
{
	if (ffield.value.length==0)
		ffield.value=" ";
	ffield.focus();
	ffield.select();
	alert(t);
}

/****************************************

************ Basic Checks ***************

******************************************/


/* Check if there is a value in an input */
function maInputCheckEmpty(ffield)
{
	tv=maTrim(ffield.value)
	ffield.value=tv;
	cl=tv.length;
	return (cl==0);
}

/****************************************

************ Validations ****************

******************************************/

function validateRegExp(ffield,pattern){
    var rx = new RegExp(pattern);
    var matches = rx.exec(ffield.value);
    return (matches != null && ffield.value == matches[0]);

        /*value = ffield.value;
	var value = new String(value);
	if (pattern != null) {
		if (value.search(pattern) != -1) {
			return true;
		} else return false;
	} else return true;*/
}

function correctStrLength(ffield,min,max){
    str = ffield.value;
    if (str==null) return false
    if (typeof(str) != "string") return false
    if (min != null) if (str.length<min) return false
    if (max != null) if (str.length>max) return false
    return true
}

function correctNumLength(value,min,max){
    value = ffield.value;
	if (!isFinite(value)) return false
    if (min !=null) if (value<min) return false
    if (max !=null) if (value>max) return false
    return true
}


function validateString(ffield,pattern,min,max){
    value = ffield.value;
    //validation expression reguliere
    if (pattern != null)
        if (!validateRegExp(ffield,pattern)){
            return false
        }

    //validation de longueur
    if (!correctStrLength(ffield,min,max)){
        return false
    }
    return true
}

function validateInteger(ffield,min,max){
    
    //verification que c'est bien un entier
    if(!validateRegExp(ffield, "(^[+-]?[0-9]+$)" )){
        return false
    }

    //validation de la longueur
    if (!correctNumLength(ffield,min,max)){
        return false
    }
    
    return true
}

function validateDecimal(ffield,min,max,fractionDigits){
    var value = ffield.value;
    var b
    //verification que c'est bien un decimal
    //2 cas selon qu'il y ait un "." ou pas car regexp suivante ne fonctionne pas :[-+]?[0-9]+(\\.[0-9]+)?
    if (value.indexOf(".")>=0) b=validateRegExp(ffield, "(^[-+]?[0-9]+\.[0-9]+$)" )
    else b=validateRegExp(ffield, "(^[-+]?[0-9]+$)" )
    if(!b){
    	alert("bad number");
        return false
    }

    //validation de la longueur
    if (!correctNumLength(ffield,min,max)){
    	alert("bad length");
        return false
    }

    //validation du nombre de fractionDigits
    if (!correctFractionDigit(ffield,fractionDigits)){
    	alert("bad fraction digit");
        return false
    }
    return true;
}

function correctFractionDigit(ffield,max){
    var value = ffield.value;
    var i
    i=value.indexOf(".")
    if (i>=0){
        return (max>=(value.length-i-1))
    }
    else return true
}

function validateDate(ffield){
    //verification que c'est bien une date
    var value = ffield.value;
    //var pattern = "[0-9]*-[0-9]*-[0-9]*";
    var pattern4match = "([0-3]?[0-9])[\-\/\.]([0-1]?[0-9])[\-\/\.]([0-9]{4})";
    var pattern = /([0-3]?[0-9])[\-\/\.]([0-1]?[0-9])[\-\/\.]([0-9]{4})/
    var date = new String(value);
    //alert(pattern);
    if(!validateRegExp(ffield, pattern4match)){
	return false;
    }
    
    //alert("regexp is ok");
    
    if (date.length!=0) {
    		var daysInMonth = new Array(12);
    		daysInMonth[0] = 31;
    		daysInMonth[1] = 29;
    		daysInMonth[2] = 31;
    		daysInMonth[3] = 30;
    		daysInMonth[4] = 31;
    		daysInMonth[5] = 30;
    		daysInMonth[6] = 31;
    		daysInMonth[7] = 31;
    		daysInMonth[8] = 30;
    		daysInMonth[9] = 31;
    		daysInMonth[10] = 30;
    		daysInMonth[11] = 31;
    		
    		var result = pattern.exec(date);
    		
    		day = result[1];
    		month = result[2];
    		year = result[3];
    		
    		var YearInt = Number(year);
    		var MonthInt = Number(month);
    		var DayInt = Number(day);
    
    		// catch invalid days, except for February
    		if (DayInt <= daysInMonth[MonthInt-1]) {
    			if ((MonthInt == 2) && (DayInt > daysInFebruary(YearInt))) {
    				return false;
    			}
    		} else {
    			return false;
    		}
    }
    return true;
}

function validateTime(ffield){
    var value = ffield.value;
    //verification que c'est bien un time
    
    var pattern = "[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?"
    if(!validateRegExp(ffield, pattern)){
        return false;
    }
    return true;
}




/*************************************************************************/

/* Basic check on url in an input field */
function maInputCheckURL(ffield, t)
{
	v = ffield.value;
	var reHTTPURL = /^http:\/\/.+$/; 
	var reHTTPSURL = /^https:\/\/.+$/;
	var reFTPURL = /^ftp:\/\/.+$/;
	var reFILEURL = /^file:\/.+$/;
	if (v.length==0) return true;
	if (reHTTPURL.test(v)) return true;
	if (reHTTPSURL.test(v)) return true;
	if (reFTPURL.test(v)) return true;
	if (reFILEURL.test(v)) return true;
	maInputDisplayError(ffield, t)
	return false;
}

/****************************************

************ List Box Operations *********

******************************************/

/* Check if a multiple select control is empty */
function maMSelectCheckEmpty(ffield)
{
	return (ffield.options.length<=1);
}

/* Check the minimum number of items in a multiple select control */
function maMSelectCheckMinLength(ffield, l, t)
{
	if (ffield.options.length-1<l)
	{
		maMSelectDisplayError(ffield, t);
		return false;
	}
	return true;
}

/* Check the maximum numbre of items in a multiple select control */
function maMSelectCheckMaxLength(ffield, l, t)
{
	if (ffield.options.length-1>l)
	{
		maMSelectDisplayError(ffield, t);
		return false;
	}
	return true;
}

/* Copy option with index 'ia' on option with index 'ib' in a multiple select control */
function maMSelectCopy(ffield, ia, ib)
{
	ffield.options[ib]=new Option();
	ffield.options[ib].value=ffield.options[ia].value;
	ffield.options[ib].text=ffield.options[ia].text;
	ffield.options[ib].selected=ffield.options[ia].selected;
}

/* Swap two options with index 'ia' and option with index 'ib' in a multiple select control */
function maMSelectSwap(ffield, ia, ib)
{
	tmpo=new Option();
	tmpo.value=ffield.options[ib].value;
	tmpo.text=ffield.options[ib].text;
	tmpo.selected=ffield.options[ib].selected;

	maMSelectCopy(ffield, ia, ib);

	ffield.options[ia]=new Option();
	ffield.options[ia].value=tmpo.value;
	ffield.options[ia].text=tmpo.text;
	ffield.options[ia].selected=tmpo.selected;
}

/* Add an option as the first entry of a multiple select control */
function maMSelectAddFront(ffield, newText, newValue)
{	
	//remove first element with whitespaces (NN 4.7 with of select box)
	if(ffield.options[0] != null && ffield.options[0].value.length == 0) {
		ffield.options[0].selected = true;
		maMSelectRemove(ffield);
	}
	j=ffield.options.length;
	for (i=j; i>0; i--)
		maMSelectCopy(ffield, i-1, i);

	ffield.options[0]=new Option();
	ffield.options[0].value=newValue;
	ffield.options[0].text=newText;
}

/* Remove all selected entries of a multiple select control */
function maMSelectRemove(ffield)
{
	while (true)
	{
		si = ffield.options.selectedIndex;
		if (si==-1)
			break;
		//if (si==ffield.options.length-1)
		//	break;
		ffield.options[si] = null;
	}
}

/* Remove all entries of a multiple select control */
function maMSelectCleanUp(ffield)
{
	j=ffield.options.length;
	for (i=0; i<j; i++)
		ffield.options[0]=null;
}

/* Move up selected entries of a multiple select control */
function maMSelectMoveUp(ffield)
{
	j=ffield.options.length;
	for (i=0; i<j-1; i++)
	{
		if (!(ffield.options[i].selected))
		{
			if (ffield.options[i+1].selected)
			{
				maMSelectSwap(ffield, i, i+1);
			}
		}
	}
}

/* Move down selected entries of a multiple select control */
function maMSelectMoveDown(ffield)
{
	j=ffield.options.length;
	for (i=j-1; i>0; i--)
	{
		if (!(ffield.options[i].selected))
		{
			if (ffield.options[i-1].selected)
			{
				maMSelectSwap(ffield, i, i-1);
			}
		}
	}
}

/* Perform the sending of all args */
function maMSelectSend(ffield)
{	
	
	//j=ffield.options.length-1;
	j=ffield.options.length;
	for (i=0; i<j; i++)
		ffield.options[i].selected=true;
	//TdP: handling the blank field is obsolete
	//TdP: see the maMSelectAddFront
	//ffield.options[j].selected=false;
}

/* Validate a select control */
function validateSelect(ffield, min, max) 
{
	//value = ffield.options.length-1;
	value = ffield.options.length;
	if (min !=null) if (value<min) return false
	if (max !=null) if (value>max) return false
    	return true
}

/* Validate a multiple select control */
function validateSelectMultiple(ffield, min, max) 
{
	value = 0;
	j=ffield.options.length-1;
	for (i=0; i<j; i++) {
		if (ffield.options[i].selected) 
			value++;
	}
	if (min !=null) if (value<min) return false
	if (max !=null) if (value>max) return false
    	return true
}

/* Date check */

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}



/* radiobuttonlist check */
function valRadio(radio) {
var cnt = -1;
for (var i=radio.length-1; i > -1; i--) {
   if (radio[i].checked) {cnt = i; i = -1;}
   }
if (cnt > -1) return radio[cnt].value;
else return null;
}




function clearForm(formName) {
	curForm = eval("document." + formName);
	for (i=0;i<curForm.elements.length;i++) {
		if (curForm.elements[i].type=="text" ||
		    curForm.elements[i].tagName=="SELECT") {
		    curForm.elements[i].value="";
		}
	}

}


function validateGenericMailTo() {
              var FieldList = "";
             //Initialisation compatibilité Firefox
             var G = document.forms['G'] ;

             if (G.from.value == "crealys28mai"){
  
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.Organisation.value == ""){
			FieldList = FieldList + "<li>Organisation/Société/Commune...</li>";
		};
		if (G.Fonction.value == ""){
			FieldList = FieldList + "<li>Fonction</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};
		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};

	};


	if (G.from.value == "nouveaucompte"){        
                // FieldList = "je suis entré";
                // createPopup(FieldList);
		if (G.nom.value == ""){
			FieldList = "<li>Nom</li>";
		};
		if (G.prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.projet.value == ""){
			FieldList = FieldList + "<li>Description du projet</li>";
		};
		if (G.email.value != ""){
			if (!validateRegExp(G.email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			FieldList = FieldList + "<li>Email</li>";
		};
                               if (G.ctrlfield.value == "" ){
			FieldList = FieldList + "<li>Code vérification incorrect</li>";
		};

	};

	if (G.from.value == "nouvelEvenement"){        
		if (G.titre.value == ""){
			FieldList = "<li>Titre de l'évènement</li>";
		};
		if (G.descriptionEvenement.value == ""){
			FieldList = FieldList + "<li>Description</li>";
		};
		if (G.lieuEvenement.value == ""){
			FieldList = FieldList + "<li>Lieu de l'évènement</li>";
		};
		if (G.datedebutEvenement.value != ""){
				if (!validateDate(G.datedebutEvenement)){
					FieldList = FieldList + "<li>Date de début non valide.</li>";
				}	
		} else {

			FieldList = FieldList + "<li>Date de début</li>";
		};
		if (G.datefinEvenement.value != ""){
				if (!validateDate(G.datefinEvenement)){
					FieldList = FieldList + "<li>Date de fin non valide.</li>";
				}	
		}
		else {		
			FieldList = FieldList + "<li>Date de fin</li>";
		};
		if (G.organismeEvenement.value == ""){
			FieldList = FieldList + "<li>Organisme organisateur</li>";
		};
		if (G.nomcontactEvenement.value == ""){
			FieldList = FieldList + "<li>nom du contact</li>";
		};
		if (G.emailcontactEvenement.value != ""){
			if (!validateRegExp(G.emailcontactEvenement,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			FieldList = FieldList + "<li>email du contact</li>";
		};
		if (G.telcontactEvenement.value == ""){
			FieldList = FieldList + "<li>Téléphone du contact</li>";
		};
	};

	if (G.from.value == "proposerbreve"){        
		if (G.titreBreve.value == ""){
			FieldList = "<li>Titre</li>";
		};
		if (G.descriptionBreve.value == ""){
			FieldList = FieldList + "<li>Description</li>";
		};
		if (G.emailcontactBreve.value != ""){
			if (!validateRegExp(G.emailcontactBreve,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			FieldList = FieldList + "<li>Votre email</li>";
		};
		if (G.nomcontactBreve.value == ""){
			FieldList = FieldList + "<li>Votre nom</li>";
		};
		
	};

	if (G.from.value == "idee"){        
		if (G.sujetIdee.value == ""){
			FieldList = "<li>Sujet</li>";
		};
		if (G.idee.value == ""){
			FieldList = FieldList + "<li>Votre idée</li>";
		};
		if (G.nomIdee.value == ""){
			FieldList = FieldList + "<li>Votre nom</li>";
		};
		if (G.emailIdee.value != ""){
			if (!validateRegExp(G.emailIdee,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			FieldList = FieldList + "<li>Votre email</li>";
		};		
	};

	if (G.from.value == "poserquestion"){        
		if (G.sujetQuestion.value == ""){
			FieldList = "<li>Sujet de votre question</li>";
		};
		if (G.question.value == ""){
			FieldList = FieldList + "<li>Votre question</li>";
		};
		if (G.emailQuestion.value != ""){
			if (!validateRegExp(G.emailQuestion,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			FieldList = FieldList + "<li>Votre email</li>";
		};
		if (G.nomQuestion.value == ""){
			FieldList = FieldList + "<li>Votre nom</li>";
		};
		
	};

	if (G.from.value == "insertionlien"){        
		if (G.adressesite.value == ""){
			FieldList = "<li>Adresse du site</li>";
		};
	};

	if (G.from.value == "probleme"){        
		if (G.votreprobleme.value == ""){
			FieldList = "<li>Quel est votre problème ?</li>";
		};
		if (G.emailprobleme.value != ""){
			if (!validateRegExp(G.emailprobleme,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
			FieldList = "<li>Votre email n'est pas valide</li>";
		};
	};

	if (G.from.value == "avis"){        
		if (G.commentaire.value == ""){
			FieldList = "<li>Votre avis</li>";
		};
	};


	if (G.from.value == "demandeinfos"){        
		if (G.sujetIdee.value == ""){
			FieldList = "<li>Réference opportunité</li>";
		};
		if (G.idee.value == ""){
			FieldList = FieldList + "<li>Votre question</li>";
		};
		if (G.nomIdee.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.emailIdee.value != ""){
				if (!validateRegExp(G.emailIdee,pattern_email)){
					FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
				}	else {
					//alert("email enfin valide !");
				};
			} else {
	
			FieldList = FieldList + "<li>email</li>";
		};
	};

	if (G.from.value == "abonnement"){        
		if (G.nom.value == ""){
			FieldList = "<li>Nom</li>";
		};
		if (G.prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.email.value != ""){
				if (!validateRegExp(G.email,pattern_email)){
					FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
				}	else {
					//alert("email enfin valide !");
				};
			} else {
	
			FieldList = FieldList + "<li>email</li>";
		};
	};

	if (G.from.value == "desabonnement"){        
		if (G.email.value != ""){
				if (!validateRegExp(G.email,pattern_email)){
					FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
				}	else {
					//alert("email enfin valide !");
				};
			} else {
	
			FieldList = FieldList + "<li>email</li>";
		};
	};

	if (G.from.value == "europedirect_commandedocuments"){        
		if (G.nom.value == ""){
			FieldList = "<li>Nom</li>";
		};
		if (G.prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.email.value != ""){
				if (!validateRegExp(G.email,pattern_email)){
					FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
				}	else {
					//alert("email enfin valide !");
				};
			} else {
	
			FieldList = FieldList + "<li>email</li>";
		};
		if (G.telephone.value == ""){
			FieldList = FieldList + "<li>Téléphone</li>";
		};
	};


	if (G.from.value == "InscriptionSeminaire"){        
		if (G.intitule.value == ""){
			FieldList = "<li>Intitulé</li>";
		};
		if (G.societe.value == ""){
			FieldList = FieldList + "<li>Société</li>";
		};
		if (G.adressefact.value == ""){
				FieldList = FieldList + "<li>Adresse de facturation</li>";

		};
		if (G.tva.value == ""){
			FieldList = FieldList + "<li>T.V.A.</li>";
		};
                                if (/*(G.paiement[0].checked) &&*/ (G.somme.value =="")){
                                                    FieldList = FieldList + "<li>Somme</li>";
                                };
                                                               
                          
                                 if (!G.conditions.checked){
    		        FieldList = FieldList + "<li>Conditions générales</li>";
		};

	};



	if (G.from.value == "europe-direct-questions"){        
		if (G.nom.value == ""){
			FieldList = "<li>Nom</li>";
		};
		if (G.prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.email.value != ""){
				if (!validateRegExp(G.email,pattern_email)){
					FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
				}	else {
					//alert("email enfin valide !");
				};
			} else {
	
			FieldList = FieldList + "<li>email</li>";
		};
		if (G.telephone.value == ""){
			FieldList = FieldList + "<li>Téléphone</li>";
		};
	};


	if (G.from.value == "euro-info-centre") {
		
		if (G.nom.value == ""){
			FieldList = "<li>Nom</li>";
		};
		if (G.prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.body.value == ""){
			FieldList = FieldList  + "<li>Corps du message</li>";
		};
		
	};
 


	if (G.from.value == "bepenvironnementborchureorder"){        
		if (G.NOM.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.PRENOM.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.ADRESSE.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};
		if (G.COMMUNE.value == ""){
			FieldList = FieldList + "<li>Commune</li>";
		};
		if (G.CP.value == ""){
			FieldList = FieldList + "<li>Code postal </li>";
		};
		if (G.PAYS.value == ""){
			FieldList = FieldList + "<li>Pays </li>";
		};

		if (G.EMAIL.value != ""){
			if (!validateRegExp(G.EMAIL,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			FieldList = FieldList + "<li>E-mail</li>";
		};
	};





	if (G.from.value == "bepenvironnementcontact"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Telephone.value == ""){
			FieldList = FieldList + "<li>Téléphone</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};
		if (G.message.value == ""){
			FieldList = FieldList + "<li>Message</li>";
		};

                                if (G.ctrlfield.value == "" ){
			FieldList = FieldList + "<li>Code vérification incorrect</li>";
		};

	};



	if (G.from.value == "bepenvironnementvisite"){        
		if (G.NomEtablissementScolaire.value == ""){
			FieldList = FieldList + "<li>Nom de l’établissement scolaire</li>";
		};
		if (G.NombreDeVisiteurs.value == ""){
			FieldList = FieldList + "<li>Nombre de visiteurs</li>";
		};
		if (G.AnneeScolaire.value == ""){
			FieldList = FieldList + "<li>Année scolaire</li>";
		};
		if (G.NomPersonneContact.value == ""){
			FieldList = FieldList + "<li>Nom de la personne de contact</li>";
		};
		if (G.Telephone.value == ""){
			FieldList = FieldList + "<li>Téléphone</li>";
		};
		if (G.GSM.value == ""){
			FieldList = FieldList + "<li>Numéro de GSM</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			FieldList = FieldList + "<li>Adresse e-mail</li>";
		};
	};


	if (G.from.value == "bepenvironnementcompost"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};

		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};

                                if (G.ctrlfield.value == "" ){
			FieldList = FieldList + "<li>Code vérification incorrect</li>";
		};

	};

                if (G.from.value == "InscriptionCreativite"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		//if (G.EntrepriseOrganisation.value == ""){
		//	FieldList = FieldList + "<li>Entreprise/Organisation</li>";
		//};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};

		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		//if (G.Tel.value == ""){
		//	FieldList = FieldList + "<li>Téléphone/GSM</li>";
		//};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};
	};

                if (G.from.value == "InscriptionChacunSaRoute"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.Fonction.value == ""){
			FieldList = FieldList + "<li>Fonction</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};

		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};

	};

                if (G.from.value == "BusinessToSeniors"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.Fonction.value == ""){
			FieldList = FieldList + "<li>Fonction</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};

		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};

	};

               if (G.from.value == "FinancementsEuropeens"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.Organisation.value == ""){
			FieldList = FieldList + "<li>Province/Commune/Organisation</li>";
		};
		if (G.Fonction.value == ""){
			FieldList = FieldList + "<li>Fonction</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};
		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};

	};

               if (G.from.value == "VisiteInstitutions09mai"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.Organisation.value == ""){
			FieldList = FieldList + "<li>Organisation/Société/Commune...</li>";
		};
		if (G.Fonction.value == ""){
			FieldList = FieldList + "<li>Fonction</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};
		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};

	};


                if (G.from.value == "inscriptionnec"){        
                                if (G.salutation.selectedIndex ==0){
			FieldList = FieldList + "<li>Salutation</li>";
		};
		if (G.nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};

		if (G.cp.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.email.value != ""){
			if (!validateRegExp(G.email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};
		if (G.tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
	};

                if (G.from.value == "CouponReponseActivIdee"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prénom</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adresse</li>";
		};

		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Localité</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Téléphone/GSM</li>";
		};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};
                                if (valRadio(G.Souhait) == "souhaiteparticiper"){
                                                if (G.Telcontact.value == ""){
			         FieldList = FieldList + "<li>Téléphone Contact</li>";
		                };		
		};

	};

	if (G.from.value == "walloniedeveloppementquestion"){        


		if (valRadio(G.Titre) == null){
			FieldList = FieldList + "<li>Titre</li>";
		};
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Nom de la personne de contact</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Prenom de la personne de contact</li>";
		};

		if (G.Societe.value == ""){
			FieldList = FieldList + "<li>Société ou organisme</li>";
		};
		if (G.Domaine.value == ""){
			FieldList = FieldList + "<li>Domaine d'activité</li>";
		};
		if (G.Fonction.value == ""){
			FieldList = FieldList + "<li>Fonction</li>";
		};

		if (G.Rue.value == ""){
			FieldList = FieldList + "<li>Rue</li>";
		};
		if (G.CodePostal.value == ""){
			FieldList = FieldList + "<li>Code postal</li>";
		};
		if (G.Ville.value == ""){
			FieldList = FieldList + "<li>Ville</li>";
		};
		if (G.Pays.value == ""){
			FieldList = FieldList + "<li>Pays</li>";
		};


		if (G.Telephone.value == ""){
			FieldList = FieldList + "<li>Téléphone</li>";
		};

		if (G.message.value == ""){
			FieldList = FieldList + "<li>message</li>";
		};


		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
		
			//FieldList = FieldList + "<li>Adresse e-mail</li>";
		};


	};

                if (G.from.value == "5sterreninschrijving"){        
		if (G.Nom.value == ""){
			FieldList = FieldList + "<li>Naam</li>";
		};
		if (G.Prenom.value == ""){
			FieldList = FieldList + "<li>Voornaam</li>";
		};
		if (G.EntrepriseOrganisation.value == ""){
			FieldList = FieldList + "<li>Onderneming</li>";
		};
		if (G.Adresse.value == ""){
			FieldList = FieldList + "<li>Adres</li>";
		};

		if (G.Codepostal.value == ""){
			FieldList = FieldList + "<li>Postcode</li>";
		};
		if (G.Localite.value == ""){
			FieldList = FieldList + "<li>Gemeente</li>";
		};
		if (G.Tel.value == ""){
			FieldList = FieldList + "<li>Telefoon/GSM</li>";
		};
		if (G.Email.value == ""){
			FieldList = FieldList + "<li>Email</li>";
		};
		if (G.Email.value != ""){
			if (!validateRegExp(G.Email,pattern_email)){
				FieldList = FieldList + "<li>Uw email adres is niet geldig.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		};

                };



	if (FieldList == ""){
	G.submit();
	} else { 

	createPopup(FieldList);
	
	};
}

function validateToFriend() {
	var FieldList = "";

//Initialisation compatibilité Firefox
                var G = document.forms['G'] ;

	if (G.expediteur.value == ""){
		FieldList = FieldList + "<li>Votre nom</li>";
	};
	if (G.emailFrom.value != ""){
			if (!validateRegExp(G.emailFrom,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
	
		FieldList = FieldList + "<li>Votre email</li>";
	};
	if (G.destinataire.value == ""){
		FieldList = FieldList + "<li>Nom de votre ami</li>";
	};
	if (G.emailTo.value != ""){
			if (!validateRegExp(G.emailTo,pattern_email)){
				FieldList = FieldList + "<li>L'Email de votre ami n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
	
		FieldList = FieldList + "<li>email de votre ami</li>";
	};
	if (FieldList == ""){
	G.submit();
	} else { 

	createPopup(FieldList);
	
	};
}

function validateSubscribe() {
	var FieldList = "";
	if (document.abonnement.nom.value == ""){
		FieldList = "<li>Nom</li>";
	};
	if (document.abonnement.prenom.value == ""){
		FieldList = FieldList + "<li>Prénom</li>";
	};
	if (document.abonnement.email.value != ""){
			if (!validateRegExp(document.abonnement.email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
	
		FieldList = FieldList + "<li>email</li>";
	};
	if (FieldList == ""){
	document.abonnement.submit();
	} else {

	createPopup(FieldList);
	};
}

function validateUnSubscribe() {
	var FieldList = "";
	if (document.desabonnement.email.value != ""){
			if (!validateRegExp(document.desabonnement.email,pattern_email)){
				FieldList = FieldList + "<li>Votre Email n'est pas valide.</li>";
			}	else {
				//alert("email enfin valide !");
			};
		} else {
	
		FieldList = FieldList + "<li>email</li>";
	};
	if (FieldList == ""){
	document.desabonnement.submit();
	} else {

	createPopup(FieldList);
	};
}

function validateSubscribeSem() {

var FieldList = "";
	if (inscription.societe.value == ""){
		FieldList = "<li>Société</li>";
	};
		if (FieldList == ""){
	inscription.submit();
	} else {

	createPopup(FieldList);
	};

	}

function createPopup(FieldList)
{
	var generator=window.open('','name','height=350,width=300');

	generator.document.write('<html><head><title>Erreur de validation</title>');
	generator.document.write('</head><body>');
	generator.document.write('<p>Vous devez obligatoirement remplir ces champs :</p>');
	generator.document.write('<ul>');
	generator.document.write(FieldList);
	generator.document.write('</ul>');
	generator.document.write('</body></html>');
	generator.document.write('<p align="center"><a href="JavaScript: self.close();"><b>Close</b></a></p>');
}