
var errfound=false;
var k_intOk=0;
var k_intLngInvalide=1;
var k_intSaisieOblg=2;
var k_intCarNonAutorise=3;
var k_intStructureEmailInvalide=4;
var k_intNumInvalide=5;
var k_intValNonNum=6;
var k_intStructureDateInvalide=7;
var k_intDateInvalide=8;
var k_intSelectionOblg=9;
var k_intQuestion=10;
var k_intDateType=12;
var k_intChampSeq=13;
var k_intChampPasSlash=14;
var k_intNonCoche=15;
var k_intTelFrIncorrect = 17;
var k_intDateNaissanceSuperieureJour = 18;
var k_intAgeLimiteDepasse = 19;

var k_strlng_Fr="Fr";
var k_strlng_En="En";

//***************************************
// Valide qu'un checkbox est coché
//
// ??/??/???? - ETE : Création
// 03/05/2005 - SMN : Mise en lib
// 19/07/2005 - ETE : Rajout test checkbox seul!!!
//***************************************
function ValidRadioChecked( objCheckbox )
{
		for (var intX=0 ;  intX < objCheckbox.length ; intX++)
		{
			if (objCheckbox[intX].checked == true)
			{ 
				return k_intOk;
				break;
			}
		}

		// MODIF pour checkbox seul
		if (objCheckbox.length > 1 ){
			return k_intSelectionOblg;
		} else {
			if (objCheckbox.checked == true){
			 	return k_intOk;
			} else {
				return k_intSelectionOblg;
			}
		}
}

/****************************************************************************************************
 Fonction qui met en majuscule la première lettre de chaque mot
 Et qui traite les mots exceptions en minuscule (et, de, etc...)

 30/11/2006 - YHN : Création
'****************************************************************************************************/
function PremiereLettreEnMajuscule(strChaineTestee)
{
	var booNouveauMot = true;
	var intChainePosition;
	var strCaractere;
	var strChaine = '';
	var tabMinuscules = [" De ","De "," Du ","D'"," D'"," L'"," Le "," Les "," La "," Et ", " En "," Des "];
	var tabMajuscules = ['Chu ','Ch ','Chi ','Smur ','Hia ','Chsf ','Chr ','Chd ', 'Chg '];
	var strMinuscules;
	var strMajuscules;
	var tabChiffresRomains = [" I"," Ii"," Iii"," Iv"," V"," Vi"," Vii"," Viii"," Ix"," X"," Xi"," Xii"," Xiii"," Xiv"," Xv"," Xvi"," Xvii"," Xviii"," Xix"," Xx"];
	var strChiffreRomain;
	var strChaineTemp;
	var strChaineTemp2;
	var intIndex;
			
	if (strChaineTestee != ''){
		
		for (intChainePosition = 0; intChainePosition < strChaineTestee.length; intChainePosition ++){
			
			//On récupère le caractère en cours
			strCaractere = strChaineTestee.substr(intChainePosition, 1 );
		
			if ((booNouveauMot) && (strCaractere.toUpperCase() != strCaractere.toLowerCase() )) {
				strCaractere = strCaractere.toUpperCase();
				booNouveauMot = false;
			} else {
				if (strCaractere.toUpperCase() == strCaractere.toLowerCase() ) {
					booNouveauMot = true;
				} else {
					strCaractere = strCaractere.toLowerCase();
				}
			}
			
			strChaine = strChaine + strCaractere;
		}
	
		
		//Exceptions : valeurs des tableaux			
		for (intIndex = 0; intIndex < tabMinuscules.length; intIndex++)
		{
			//On met en minuscule les exceptions
			strChaine = strChaine.replace(tabMinuscules[intIndex], tabMinuscules[intIndex].toLowerCase());	
		}

		for (intIndex = 0; intIndex < tabMajuscules.length; intIndex++)
		{
			//On met en majuscule les exceptions
			if (strChaine.length == tabMajuscules[intIndex].length) {
				//Initiales uniquement, par exemple chu
				strChaine = strChaine.replace(tabMajuscules[intIndex], tabMajuscules[intIndex].toLowerCase());		
			} else {
				//Mot entier
				strChaine = strChaine.replace(tabMajuscules[intIndex], tabMajuscules[intIndex].toUpperCase());		
			}
		}

		for (intIndex = 0; intIndex < tabChiffresRomains.length; intIndex++)
		{
			//On met en majuscule les chiffres romains (doivent etre dans les 6 dernières lettres)
			//Vérifier qu'il n'y a que des chiffres potentiellement romains dans les 6 dernières lettres
			if (strChaine.length > 6) {
				//strChaineTemp = left(strChaine,strChaine.length-6);
				strChaineTemp = strChaine.substring(0,strChaine.length-6)
				//strChaineTemp2 = right(strChaine,6);
				strChaineTemp2 = strChaine.substring(strChaine.length, strChaine.length - 6);
				strChaine = strChaineTemp +  strChaineTemp2.replace(tabChiffresRomains[intIndex], tabChiffresRomains[intIndex].toUpperCase());
			} else {
				//strChaineTemp2 = right(strChaine,strChaine.length);
				strChaineTemp2 = strChaine.substring(strChaine.length, strChaine.length - strChaine.length);
				strChaine = strChaineTemp2.replace(tabChiffresRomains[intIndex], tabChiffresRomains[intIndex].toUpperCase());
			}
		}
	}
	
	return strChaine;
}


//***************************************
// Affiche les erreurs
//
// ??/??/???? - ??? : Création
// 29/05/2006 - SMN : Ajout N° 17 (tel)
// 10/07/2006 - ERU : Ajout N° 18 et 19 (Contrôles de dates)
//***************************************
function AffErr (CodeLangue,CodeErreur) {
	var g_strMesgErr;
	switch (CodeLangue.toLowerCase()) {
		case "fr":
			switch (CodeErreur) {
				case 1:
					g_strMesgErr="La longueur de champ est invalide";
					break;
				case 2:
					g_strMesgErr="La saisie de ce champ est obligatoire";
					break;
				case 3:
					g_strMesgErr="Caractère(s) non autorisé(s)";
					break;
				case 4:
					g_strMesgErr="Structure invalide (ex : j.dupondt@domain.fr)";
					break;
				case 5:
					g_strMesgErr="Numéro invalide";
					break;
				case 6:
					g_strMesgErr="Valeur non numérique";
					break;
				case 7:
					g_strMesgErr="Structure invalide (ex : 01/01/1998)";
					break;
				case 8:
					g_strMesgErr="Date invalide";
					break;
				case 9:
					g_strMesgErr="Sélectionnez un élément dans la liste";
					break;			
				case 10:
					g_strMesgErr="En êtes-vous sûr ?";
					break;							
				case 11:
					g_strMesgErr="La date de debut ne peut être supérieure à la date de fin";
					break;
				case 12:
					g_strMesgErr="Le filtre ne s'applique que sur un type de date";
					break;							
				case 13:
					g_strMesgErr="Les champs doivent être saisis de manière séquentielle";
					break;
				case 14: 
					g_strMesgErr="Le caractère '\\' est interdit";
					break;
				case 15: 
					g_strMesgErr="Tous les boutons radios ne sont pas sélectionnés";
					break;
				case 16:
					g_strMesgErr="Valeur non autorisée";
					break;
				case 17:
					g_strMesgErr="Format de numéro de téléphone incorrect. Le numéro doit contenir 10 chiffres et commencer par 01, 02, 03, ... (ex : 02 99 22 83 40)";
					break;
				case 18:
					g_strMesgErr="La date de naissance est supérieure à la date du jour";
					break;
				case 19:
					g_strMesgErr="Age limite dépassé";
					break;
				case 20:
					g_strMesgErr="Saisie en minuscule obligatoire (première majuscule)";
					break;
				default :
					g_strMesgErr="Erreur Générale";
					break;
				}
			break;
		default:
			switch (CodeErreur) {
				case 1:
					g_strMesgErr="Invalid length";
					break;
				case 2:
					g_strMesgErr="data entry required";
					break;					
				case 3:
					g_strMesgErr="characters forbidden";
					break;
				case 4:
					g_strMesgErr="Invalid email structure (ex : j.dupont@domain.fr)";
					break;
				case 5:
					g_strMesgErr="Invalid number";
					break;
				case 6:
					g_strMesgErr="Numeric only";
					break;
				case 7:
					g_strMesgErr="Invalid date structure (ex : 01/01/1998)";
					break;
				case 8:
					g_strMesgErr="Invalide date";
					break;
				case 9:
					g_strMesgErr="Select an element in the list";
					break;						
				case 10:
					g_strMesgErr="Are you sure ?"
					break;
				case 11:
					g_strMesgErr="The date of debut can not be superior to the date of the end";
					break;	
				case 12:
					g_strMesgErr="The filter applies only to a type of date";
					break;							
				case 13:
					g_strMesgErr="Fields must be seized in a sequential way";
					break;
				case 14: 
					g_strMesgErr="Character ' \\ ' is forbidden";
					break;
				case 15: 
					g_strMesgErr="All radio buttons are not selected";
					break;
				case 16: 
					g_strMesgErr="Value is not allowed";
					break;					
				case 17:
					g_strMesgErr="Incorrect phone format. The phone number must contain 10 numbers and begin with 01, 02, 03, ... (ex : 02 99 22 83 40)";
					break;
				case 18:
					g_strMesgErr="The date of birth is higher than the current date";
					break;
				case 19:
					g_strMesgErr="Exceeded limit age";
					break;
				case 20:
					g_strMesgErr="EN[Saisie en minuscule obligatoire (première majuscule)]";
					break;
				default:
					g_strMesgErr="General error";
					break;
			}
			break;
	}
	return g_strMesgErr;
}

//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidLength(a_strChaine, a_intLongueurSouhaitee)
{
	if (a_strChaine.length != a_intLongueurSouhaitee)
		return k_intLngInvalide;
	
	return k_intOk;
}


//***************************************
// Affiche les erreurs
//
// ??/??/???? - ??? : Création
//***************************************
function ValidLengthMinMax(a_strChaine, a_intLongueurMin, a_intLongueurMax)
{
	if ((a_strChaine.length<a_intLongueurMin) || (a_strChaine.length>a_intLongueurMax))
		return k_intLngInvalide;
	return k_intOk;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidLengthDiff(a_strChaine, a_intLongueurOne, a_intLongueurTwo)
{
	if ((a_strChaine.length!=a_intLongueurOne) && (a_strChaine.length!=a_intLongueurTwo))
		return k_intLngInvalide;
	return k_intOk;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidLenghtForBoth(a_strChaineOne,a_strChaineTwo)
{
	if ( (a_strChaineOne.length==0)&&(a_strChaineTwo==0) )
		return k_intSaisieOblg;
	
	if ((a_strChaineOne.length > 0)&&(a_strChaineTwo > 0))
		return k_intFiltreType;	
	return k_intOk;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function Valid(a_strChaine)
{
	if (a_strChaine.length==0)
		return k_intSaisieOblg;
	return k_intOk;
}

//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidSelection (a_strListe)
{
	if (a_strListe.selectedIndex<=0)
		return k_intSelectionOblg;
	return k_intOk;
}

//***************************************
// Contrôle si un élément a été sélectionner
//
// 23/05/2007 - ELS : Création
//***************************************
function ValidLargeSelection (a_strListe)
{
	if (a_strListe.selectedIndex<0)
		return k_intSelectionOblg;
	return k_intOk;
}

//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidSelectionItem(a_strItemSelected,a_strItem)
{
	if ( a_strItemSelected[a_strItemSelected.selectedIndex].value==a_strItem)
		return k_intOk;
	return k_intNo;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidSelectObligatoire (a_strListe)
{
	if (a_strListe.value=="False")
		return k_intSelectionImpossible;
	return k_intOk;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidMinSelection (a_strListe)
{
	if (a_strListe.length<1)
		return k_intUnAttributMin;
	return k_intOk;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ValidNum(a_strChaine) 
{
	if (a_strChaine.length>0)
	{
		for (var c=0;c<a_strChaine.length;c++) 
			if ((a_strChaine.charAt(c)<'0') || (a_strChaine.charAt(c)>'9'))
				return k_intValNonNum;
	}
	else
		return k_intSaisieOblg;
		
	return k_intOk;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function Error (a_element,a_strMessage,Check)
{
	if (errfound) return;
	window.alert (a_strMessage);
	if (Check==1)
	{
		a_element.select ();
		a_element.focus();
	}
	errfound=true;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function IsDate (a_strDate,a_strCodelangue) 
{
	var jour=0;
	var mois=0;
	var annee=0;
	var Dsiecle=0;
	var Fsiecle=0;
	var result=0;
	var arrondit=0;
	var DateCourante=new Date();
	var JourCourant=DateCourante.getDate();
	var MoisCourant=1+DateCourante.getMonth();
	var AnneeCourante=1900 + DateCourante.getYear();	
	for (var i = 0; (i<a_strDate.length); i++)
		if ( ((a_strDate.charAt(i)<"0") || (a_strDate.charAt(i)>"9")) && a_strDate.charAt(i)!="/")
			return k_intStructureDateInvalide;
	if ( (ValidLength(a_strDate,10)!=k_intOk) || (a_strDate.charAt(2)!='/') || (a_strDate.charAt(5)!='/'))
		return k_intStructureDateInvalide;

	switch (a_strCodelangue)
	{
		case "Fr" : case "fr" :
			jour=parseInt(a_strDate.substring(0,2),10);
			mois=parseInt(a_strDate.substring(3,5),10);
			break;
		default :
			mois=parseInt(a_strDate.substring(0,2),10);
			jour=parseInt(a_strDate.substring(3,5),10);
			break;
	}
	annee=parseInt(a_strDate.substring(6,10),10);

	if ( (jour<1) || (jour>31) || (mois<1) || (mois>12) )
		return k_intDateInvalide;
	if ( ( (mois==4) || (mois==6) || (mois==9) || (mois==11)) && (jour==31) )
		return k_intDateInvalide;
	if ( (mois==2) && (jour>29) )
		return k_intDateInvalide;
	if ( (mois==2) && (jour==29) ) {
		Dsiecle=parseInt(a_strDate.substring(6,8));
		Fsiecle=parseInt(a_strDate.substring(8,10));		
		if (Fsiecle==0)
			result=(Dsiecle/4);
		else
			result=(annee/4);
		arrondit = Math.round(result);
		if ( ((result-arrondit)!=0) && ((result-arrondit)!=1))
			return k_intDateInvalide;
	}
	return k_intOk;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
// 19/05/2006 - YHN : Correction pour Extension ".Info"
// 06/06/2006 - SMN : Suppression du test du nom de l'email (avant le @) < à 2 (pour que les adresses de type c@toto.fr passent)
//***************************************
function ValidEmail (a_strEmail)
{
	var FindCar;
	var PtrStrOrigine;
	var g_intPositionAt=0;
	var g_intPositionLastAt=0;
	var g_intPositionLastPoint=0;
	var g_strCarAutorise="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@.-_";

	// Test de longueur minimale de 6 caractère x@x.xx
	if (a_strEmail.length < 5 )	return k_intLngInvalide;
	
	// Test les caractères autorisé
	for (FindCar=0, ptrStrOrigine = 0; (ptrStrOrigine < a_strEmail.length) && (FindCar!=-1) ;ptrStrOrigine++) FindCar=g_strCarAutorise.indexOf(a_strEmail.charAt(ptrStrOrigine));
	if (FindCar==-1)return k_intCarNonAutorise;

	g_intPositionAt = a_strEmail.indexOf("@");
	g_intPositionLastAt = a_strEmail.lastIndexOf("@");
	if ( (g_intPositionAt==-1) || (g_intPositionLastAt!=g_intPositionAt) || (g_intPositionAt<1) )
		return k_intStructureEmailInvalide;

	g_intPositionLastPoint = a_strEmail.lastIndexOf(".");
	if ( (g_intPositionLastPoint==-1) || ((a_strEmail.length - g_intPositionLastPoint)>5) || ((a_strEmail.length - g_intPositionLastPoint)<3) || (g_intPositionLastPoint+1 == a_strEmail.length) ) 
		return k_intStructureEmailInvalide;

	if (g_intPositionLastPoint<g_intPositionAt+2)
		return k_intStructureEmailInvalide;
	
	return k_intOk;
}

//***************************************
// Teste si la chaine passée en paramètre est bien bien formatée pour un nom ou un prénom
//
// 26/07/2007 - YSR : Création
//***************************************
function ValidNomPrenom (a_strNomPrenom)
{
	var FindCar;
	var PtrStrOrigine;
	var g_strCarAutorise="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmñnopqrstuvwxyzàâäèéêëìîïòôöùûüÿyçc'.- ";

	// Test les caractères autorisé
	for (FindCar=0, ptrStrOrigine = 0; (ptrStrOrigine < a_strNomPrenom.length) && (FindCar!=-1) ;ptrStrOrigine++) FindCar=g_strCarAutorise.indexOf(a_strNomPrenom.charAt(ptrStrOrigine));
	if (FindCar==-1)return k_intCarNonAutorise;

	return k_intOk;
}


//***************************************
// Renvoie la chaine sans les accents
//
// 27/07/2007 - YSR : Création
//***************************************
function TraiteAccent (a_strChaineATraiter)
{
	var strChaine = a_strChaineATraiter;
	strChaine=strChaine.replace(/[éèêë]/g,"e");
	strChaine=strChaine.replace(/[àâäãá]/g,"a");
	strChaine=strChaine.replace(/[ïîíì]/g,"i");
	strChaine=strChaine.replace(/[ùûü]/g,"u");
	strChaine=strChaine.replace(/[öô]/g,"o");
	strChaine=strChaine.replace(/[ÿ]/g,"y");
	strChaine=strChaine.replace(/[ÈÉÊË]/g,"E");
	strChaine=strChaine.replace(/[ÀÁÂÃÄÅ]/g,"A");
	strChaine=strChaine.replace(/[ÌÍÎÏ]/g,"I");
	strChaine=strChaine.replace(/[ÙÚÛÜ]/g,"U");
	strChaine=strChaine.replace(/[ÒÓÔÕÖØ]/g,"O");
	return strChaine;
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function display_day(strLangue,strType)
{
	var date=new Date();
	var monthName;
	var dayName;
	var arDate;
	if (strLangue==k_strlng_Fr)
	{
		dayName=new Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
		switch (strType)
		{
			case 'full' :
				monthName= new Array('Janvier', 'Février', 'Mars', 'Avril', 'Mai','Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');
				document.write(dayName[date.getDay()] + " " + date.getDate() + " " + monthName[date.getMonth()] + " " + date.getFullYear());
				break;
			case 'medium' :
				document.write(dayName[date.getDay()] + " " + date.getDate() + "/" + (date.getMonth()+1) + "/" + date.getFullYear());
				break;
		}
	}
	else
	{
	    dayName=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
		switch (strType)
		{
			case 'full' :
				monthName= new Array('January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December');
				arDate = new Array("0th","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st");
				document.write(dayName[date.getDay()] + ", " + monthName[date.getMonth()] + " " + arDate[date.getDate()] + ", " + date.getFullYear());
				break;
			case 'medium' :
				document.write(dayName[date.getDay()] + " " + (date.getMonth()+1) + "/" +  date.getDate() + "/" + date.getFullYear());
				break;
		}

	}
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function servicepopup(strUrl,strId)
{
	newwin=window.open(strUrl,strId,"toolbar=yes,menubar=no,location=no,scrollbars=yes,resizable=yes,directories=no,width=750,height=500");
}		 


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function popup(strUrl,strId)
{
	newwin=window.open(strUrl,strId,"toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,directories=no,width=650,height=400");
}		 


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function popupWithSize(strUrl,strId, width, height)
{
	newwin=window.open(strUrl,strId,"toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,directories=no,width=" + width + ",height=" + height );
}


//*********************************************
// Fonction qui permet de savoir si la fenêtre 
// courante à un opener 
//
// 07/04/2006 - ETE : Création
//*********************************************
function asOpener()
{
	if (window.opener == null || window.opener.closed )
	{
		return false ;
	} else {
	
		return true ;
	}
}


function OpenerDirection(strChemin)
{
	if (window.opener == null || window.opener.closed )
	{
		window.location.href = strChemin ;
	}
	else
	{
		window.opener.location.href = strChemin ;
		window.close() ;
	}
}
//***************************************
// ferme la fenetre courante si la fenetre opener est tjs ouverte
//
// 16/06/2005 - PGU : Création
//***************************************
function OpenerClose(strChemin)
{
	if (!(window.opener == null || window.opener.closed ))
	{
		window.opener.location.reload();
		window.close() ;
	}
}

//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function SendMail(a_strNomAffiche, a_strNom, a_strDomaine, a_style)
{
	var lienMailTo;
	lienMailTo = '<a href=\"mailto:' + a_strNom + '@' + a_strDomaine + '"';
	if ( a_style != "" )
	{
		lienMailTo = lienMailTo + ' class=\"' + a_style + '\"';
	}
	lienMailTo = lienMailTo +'\>';
	if ( a_strNomAffiche == "" )
	{
		lienMailTo = lienMailTo + a_strNom + '@' + a_strDomaine;
	}
	else
	{
		lienMailTo = lienMailTo + a_strNomAffiche;
	}
	lienMailTo = lienMailTo + '</a>';

	document.write ( lienMailTo );
}


//***************************************
// Permet de masquer une adresse mail avec un lien sur une image
//
// 18/01/2006 - SMN : Création
// 02/03/2006 - SMN : Ajout de AlignImage
//***************************************
function SendMailSurImage(a_strUrlImage, a_strNom, a_strDomaine, a_strAlt, a_strAlignImage ) {
	var lienMailTo;
	lienMailTo = '<a title=\"' + a_strAlt + '\" href=\"mailto:' + a_strNom + '@' + a_strDomaine + '"';
	lienMailTo = lienMailTo + '><img align="' + a_strAlignImage + '" alt=\"' + a_strAlt + '\" src=\"' + a_strUrlImage + '\" border=\"0\"></a>';
	document.write ( lienMailTo );
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ftcoOpt(t,v)
{
	oOpt1 = new Option(t, v);
	document.forms[0].LstCont.options[document.forms[0].LstCont.options.length] = new Option(t, v);
	document.forms[0].LstOrg.options[document.forms[0].LstOrg.options.length] = new Option(t, v);
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function verif()
{ 
	if(document.forms[0].datedeb.value == "" && document.forms[0].datefin.value == "" || document.forms[0].datedeb.value == "" && document.forms[0].datefin.value != "" || document.forms[0].titre.value == "")
		alert('Vous n\'avez pas remplis tous les champs obligatoires');
	else
		document.forms[0].submit();
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ftcRecharge(strChemin)
{
	self.location = strChemin ; 
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ftcRechargeParent()
{
  self.location = "indexparent.asp" ; 
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ftcRechargeActu(idx)
{
  self.location = "indexactu.asp?IdxRubriqueparent=" + idx; 
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function ftcRechargeParentActu()
{
  self.location = "indexparent.asp" ; 
  parent.bottom.location = "../vide.htm" 
}


//***************************************
// ???
//
// ??/??/???? - ??? : Création
//***************************************
function AvertirThesaurus(strUrl)
{
	var strUrlAlerte;
	strUrlAlerte = '/01-Bibliotheque/0G-Thesaurus-cancerologie/avertissement-thesaurus.asp?strUrl=' + strUrl;
	window.open(strUrlAlerte,"new_window", 'scrollbars=yes,resizable=yes,width=500,height=330');
}


// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/"; 
// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 1; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape")
{
	if (navigator.appVersion < "5")
	{
		isNav4 = true;
		isNav5 = false;
	}
	else
	{
		if (navigator.appVersion > "4")
		{
			isNav4 = false;
			isNav5 = true;
		}
	}
}
else
{
	isIE4 = true;
}



//*********************************************************
// Fonction qui gère un window.open avec un focus
//
// 15/10/2004 - GBD : Creation
//********************************************************* 
function MM_openBrWindow(theURL,winName,features) { //v2.0
  var w;
  w=window.open(""+theURL+"",""+winName+"",""+features+"");
  if(winName.document){
	  winName.document.close();
	  w.focus();
  }
}


//*********************************************************
// GotoURL
//
// 15/10/2004 - GBD : Creation
//********************************************************* 
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location=\""+args[i+1].replace("'", "\'")+"\"");
}


//*********************************************************
// MM_validateForm
//
// ??/??/???? - ??? : Creation
//********************************************************* 
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}


//*********************************************************
// MM_validateForm
//
// ??/??/???? - ??? : Creation
//********************************************************* 
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+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
  if (errors) {
  alert('Les champs ne sont pas correctement remplis');
  document.MM_returnValue = false; 
  }
  else
  {
  //document.annuaire.submit();
  document.MM_returnValue = true; 
  }
}
//comparaison de date si date 1>date2 renvoie 1, si date1=date2 renvoie 0, si date1<date2 renvoie -1
function CompareDate(a_date1, a_date2)
{

//mois de 0 à 11
var date1 = new Date(Year(a_date1), Month(a_date1)-1, Day(a_date1));
var date2 = new Date(Year(a_date2), Month(a_date2)-1, Day(a_date2));

if (date1 > date2)
	{   return 1; }
if (date2 > date1)
	{   return -1; }
if (date1 == date2)
	{   return 0; }		
}
// extrait l annee dune  date jj/mm/yyyy
function Year(a_date)
{
	return a_date.substring(6,10)
}
// extrait le mois dune  date jj/mm/yyyy
function Month(a_date)
{
	return a_date.substring(3,5)
}
// extrait le jour dune  date jj/mm/yyyy
function Day(a_date)
{
	return a_date.substring(0,2)
}

function findInPage(str) {
	var txt, i, found;
	if (str == "") { return false; }
	if (NS4) {
		if (!win.find(str)) {
			while(win.find(str, false, true)) {
				n++;
			}
		} else {
			n++;
		}
		if (n == 0) { alert(str + " n\'a pas été trouvé sur la page."); }
	}
	if (IE4) {
		txt = win.parent.contenu.document.body.createTextRange();
		for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
			txt.moveStart("character", 1);
			txt.moveEnd("textedit");
		}
		if (found) {
			txt.moveStart("character", -1);
			txt.findText(str);
			txt.select();
			txt.scrollIntoView();
			n++;
		} else {
			if (n > 0) {
				n = 0;
				findInPage(str);
			} else {
 				alert(str + " n\'a pas été trouvé sur la page.");
			}
		}
	}
	return false;
}

function findInPageLocal(str) {

	var txt, i, found;
	if (str == "") { return false; }
	if (NS4) {
		if (!win.find(str)) {
			while(win.find(str, false, true)) {
				n++;
			}
		} else {
			n++;
		}
		if (n == 0) { alert(str + " n\'a pas été trouvé sur la page."); }
	}
	if (IE4) {
		txt = win.document.body.createTextRange();
		for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
			txt.moveStart("character", 1);
			txt.moveEnd("textedit");
		}
		if (found) {
			txt.moveStart("character", -1);
			txt.findText(str);
			txt.select();
			txt.scrollIntoView();
			n++;
		} else {
			if (n > 0) {
				n = 0;
				findInPage(str);
			} else {
 				alert(str + " n\'a pas été trouvé sur la page.");
			}
		}
	}
	return false;
}
function fragmentString(string,size){
var output=new Array();
	if(!size){return output};
	if(string.length<=size){
		output.length++;output[0]=string;
		return output;};
var pieces=((string.length%size))?
	parseInt((string.length/size)+1):(string.length/size);
	var grabPoint=-size;
	var correctSize=0;
	for(var i=0;i < pieces;i++){
	correctSize+=((grabPoint+size)>(string.length+1))?
	(string.length):size;
	grabPoint+=size;
	output[(++output.length)-1]=string.substring(grabPoint,correctSize);
	}
	return output;
} 
//*********************************************************
// Get_Cookie
//
// ??/??/???? - ??? : Creation
//********************************************************* 
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && 
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
//*********************************************************
// Set_Cookie
//
// ??/??/???? - ??? : Creation
//********************************************************* 
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
//*********************************************************
// Delete_Cookie
//
// ??/??/???? - ??? : Creation
// 01/12/2005 - GBE : Attention cette fonction ne fait pas la même chose sous IE et Firefox
// Sous IE : le cookie est mis à la valeur null
// Sous Firefox : le cookie est mis à la valeur ""
//********************************************************* 
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

//*********************************************************
// Permet de récupérer la valeur d'un objet FCKEditor
// instanceName est le nom de l'objet créé
//
// 21/07/2005 - ELS : Creation
//********************************************************* 
function getEditorValue( instanceName ) 
{  
  // Get the editor instance that we want to interact with.
  var oEditor = FCKeditorAPI.GetInstance( instanceName ) ;
  
  // Get the editor contents as XHTML.
  return oEditor.GetXHTML( true ) ;  // "true" means you want it formatted.
}  
//*********************************************************
// Equivalent au trim vb
//
// 03/08/2005 - PGU : Creation (repompage)
// 11/10/2005 - MBE : Il vaut mieux remplacer ce code par une RegExp
//********************************************************* 
function trim(s) {
  /*
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
  */
  return s.replace(/^\s*|\s*$/g, "");
}



function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
function MM_openBrWindowRPC(theURL,winName,features) { //v2.0
  window.open('Cadre.asp?URL=' + escape(theURL),winName,features);
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/"; 
// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 1; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape") {
if (navigator.appVersion < "5") {
isNav4 = true;
isNav5 = false;
}
else
if (navigator.appVersion > "4") {
isNav4 = false;
isNav5 = true;
   }
}
else {
isIE4 = true;
}
function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {
vDateType = dateType;
// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck 
// True  = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
// 1 = mm/dd/yyyy
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
//Enter a tilde sign for the first number and you can check the variable information.
if (vDateValue == "~") {
alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
vDateName.value = "";
vDateName.focus();
return true;
}
var whichCode = (window.Event) ? e.which : e.keyCode;
// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4) {
if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
return true;
}
//Eliminate all the ASCII codes that are not valid
var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
if (alphaCheck.indexOf(vDateValue) >= 1) {
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else {
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
   }
}
if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
return false;
else {
//Create numeric string values for 0123456789/
//The codes provided include both keyboard and keypad values
var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
if (strCheck.indexOf(whichCode) != -1) {
if (isNav4) {
if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
if (vDateValue.length == 6 && dateCheck) {
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
//Turn a two digit year into a 4 digit year
if (mYear.length == 2 && vYearType == 4) {
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30; 
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
}
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
return true;
}
else {
// Reformat the date for validation and set date type to a 1
if (vDateValue.length >= 8  && dateCheck) {
if (vDateType == 1) // mmddyyyy
{
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
}
if (vDateType == 2) // yyyymmdd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(4,2);
var mDay = vDateName.value.substr(6,2);
vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
}
if (vDateType == 3) // ddmmyyyy
{
var mMonth = vDateName.value.substr(2,2);
var mDay = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
//Create a temporary variable for storing the DateType and change
//the DateType to a 1 for validation.
var vDateTypeTemp = vDateType;
vDateType = 1;
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
         }
      }
   }
}
else {
// Non isNav Check
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateName.value = "";
vDateName.focus();
return true;
}
// Reformat date to format that can be validated. mm/dd/yyyy
if (vDateValue.length >= 8 && dateCheck) {
// Additional date formats can be entered here and parsed out to
// a valid date format that the validation routine will recognize.
if (vDateType == 1) // mm/dd/yyyy
{
var mMonth = vDateName.value.substr(0,2);
var mDay = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vDateType == 2) // yyyy/mm/dd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(5,2);
var mDay = vDateName.value.substr(8,2);
}
if (vDateType == 3) // dd/mm/yyyy
{
var mDay = vDateName.value.substr(0,2);
var mMonth = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vYearLength == 4) {
if (mYear.length < 4) {
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateName.value = "";
vDateName.focus();
return true;
   }
}
// Create temp. variable for storing the current vDateType
var vDateTypeTemp = vDateType;
// Change vDateType to a 1 for standard date format for validation
// Type will be changed back when validation is completed.
vDateType = 1;
// Store reformatted date to new variable for validation.
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (mYear.length == 2 && vYearType == 4 && dateCheck) {
//Turn a two digit year into a 4 digit year
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30; 
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
// Store the new value back to the field.  This function will
// not work with date type of 2 since the year is entered first.
if (vDateTypeTemp == 1) // mm/dd/yyyy
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
if (vDateTypeTemp == 3) // dd/mm/yyyy
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
} 
if (!dateValid(vDateValueCheck)) {
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
return true;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (vDateType == 1) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
   }
}
if (vDateType == 2) {
if (vDateValue.length == 4) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 7) {
vDateName.value = vDateValue+strSeperator;
   }
} 
if (vDateType == 3) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
   }
}
return true;
   }
}
if (vDateValue.length == 10&& dateCheck) {
if (!dateValid(vDateName)) {
// Un-comment the next line of code for debugging the dateValid() function error messages
//alert(err);  
alert("La date n'est pas correcte\nVeuillez ressaisir une date");
vDateName.focus();
vDateName.select();
   }
}
return false;
}
else {
// If the value is not in the string return the string minus the last
// key entered.
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else
{
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
         }
      }
   }
}
function dateValid(objName) {
var strDate;

var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
// var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
//strDate = datefield.value;
strDate = objName;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
   }
}
//Adjustment for short years entered
if (strYear.length == 2) {
strYear = '20' + strYear;
}
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
   }
}
else {
if (intday > 28) {
err = 10;
return false;
      }
   }
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

// Bulle d'aide
var hide  = true;

function showhide(obj)
{
	var x = new getObj('testP');
	hide = !hide;
	setLyr(obj,'testP');
	x.style.visibility = (hide) ? 'hidden' : 'visible';
}

function setLyr(obj,lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	// x.style.top = newY-2;
	x.style.top = newY - 50+'px';
	x.style.left = newX + 20+'px';
}

function findPosX(obj)
{
	var curleft = +15;
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	//var printstring = '';
	if (document.getElementById || document.all)
	{
		while (obj.offsetParent)
		{
			//printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (document.layers)
		curtop += obj.y;
	//window.status = printstring;
	return curtop;
}


function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

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_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 SetFocus() {
	window.focus();	
}

function setFocus() {
	focus();	
}

function hasard(mini, maxi)
{
	return (Math.floor(Math.random()*(maxi-mini+1)) + mini);	
}

function monscroll()
{
	vitesse=1000;
	path = "img_index/img";
	change = hasard(0, 4);

	do {
		im0 = hasard(1, 21);
	} while ( (path + im0 + '.jpg' == document.case0.src.substring(document.case0.src.length-(path + im0 + '.jpg').length)) ||
			  (path + im0 + '.jpg' == document.case1.src.substring(document.case1.src.length-(path + im0 + '.jpg').length)) ||
			  (path + im0 + '.jpg' == document.case2.src.substring(document.case2.src.length-(path + im0 + '.jpg').length)) ||
			  (path + im0 + '.jpg' == document.case3.src.substring(document.case3.src.length-(path + im0 + '.jpg').length)) ||
			  (path + im0 + '.jpg' == document.case4.src.substring(document.case4.src.length-(path + im0 + '.jpg').length)) );
	MM_preloadImages(path + im0 + '.jpg');
	eval("document.case" + change + ".src = path + im0 + '.jpg'");

    timerTwo=window.setTimeout("monscroll()",vitesse);
}
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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/*************************************************************
  retourne le nom de fichier d'un chemin d'accès
  ex : basename( 'c:\dir1\dir2\test.txt' ) ===> test.txt
**************************************************************/
function basename(path){
	var path_elems = path.split("/");
	if(path_elems.length <2){
		path_elems = path.split('\\');
	}
	return path_elems[(path_elems.length-1)];
}		

/*************************************
fonction qui n’affiche pas la bordure d un flash sous IE

09/05/2006 : PGU - Creation
***************************************/
function AfficheFlashSansBordure(swf, hauteur, largeur, couleur, nom) {
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+hauteur+"\" height=\""+largeur+"\" id=\""+nom+"\" align=\"middle\">\n");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n");
	document.write("<param name=\"movie\" value=\""+swf+"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\""+couleur+"\" /><embed src=\""+swf+"\" quality=\"high\" bgcolor=\""+couleur+"\" width=\""+hauteur+"\" height=\""+largeur+"\" name=\""+nom+"\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n");
	document.write("</object>\n");
}

/***********************************************************
Fonction pour donner le focus au premier champ de formulaire
Ne renvoie pas d'erreur s'il n'y a pas de formulaire

10/05/2006 - ERU : Création
29/05/2006 - ERU : Compatibilité Netscape 4.7
01/06/2006 : ERU - Modification pour prendre en compte uniquement les champs de type text, textarea ou password
************************************************************/
function SetFormFocus () {
	var booFocus = false
	if (document.forms.length > 0) {
		for (i = 0; i < document.forms[0].length; i++) {
			if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "textarea" || document.forms[0].elements[i].type == "password") {
				if (booFocus == false) {
					document.forms[0].elements[i].focus()
					booFocus = true
				}
			}
		}
	}
}

/***********************************************************
Dit si la chaine est tout en majuscules (nb en parametre)

15/05/2006 - ETE : Création
29/05/2006 - SMN : Ajout entete de fonction
************************************************************/
function GetContientMajuscule(strChaine, intNbreMajusculeAVerifier) {
	// TEST SI TITRE EN MAJUSCULE
	var intNbreMajuscule = 0; 
	var aFragment = fragmentString(strChaine,1)
	for (var i=0;i < aFragment.length;i++){
		var regEx = /[A-ZÑÁÉÍÓÚ]/
		if (regEx.test(aFragment[i])) {
			intNbreMajuscule ++ ; 
		}
	}
	if (intNbreMajuscule >= intNbreMajusculeAVerifier)	{ 	
		return true; 
	} else {
		return false; 
	} 
}

/***********************************************************
  Valide un numéro de telephone francais, il peut contenir des . (point), ' ' (espace), / (slash), \ (anti-slash)

  29/05/2006 - SMN : Création
  07/06/2006 - SMN : Modif pour que le numéro contienne des espaces
************************************************************/
function ValidTelFr (a_strTel)
{
	// un telephone français commence par 01,02, ... et suivi de 8 chiffres
	var re = /^(01|02|03|04|05|06|08|09) \d{2} \d{2} \d{2} \d{2}$/;
	if ( re.test( ReformateTelFr(a_strTel) ) )
		return k_intOk;
	else
		return k_intTelFrIncorrect;
}

/***********************************************************
  Reformate un téléphone français, suppression des . (point), ' ' (espace), / (slash), \ (anti-slash)

  29/05/2006 - SMN : Création
  07/06/2006 - SMN : Ajout du reformatage avec des espaces entre les numéros
************************************************************/
function ReformateTelFr (a_strTel)
{
	var tmp = a_strTel.replace( /\.| |\/|\\/gi, "");
	var resultat = '';

	for ( i = 0; i <= tmp.length; i += 2 ) {
		resultat = resultat + tmp.substr( i, 2 ) + ' ';
	}

	return resultat.replace(/(^\s*)|(\s*$)/g,"");
}


/***********************************************************
  Reformate un téléphone étranger

  10/07/2006 - ELS : Création
  22/08/2006 - ELS : Correction quand aucun pays ne correspond au code pays
************************************************************/
function ReformateTel (a_strTel, a_strCodePays)
{
	var strTel, strIndice;
	
	switch (a_strCodePays) {
		case "ALG":
			strIndice = "+213" ;
			break;
		case "MAR":
			strIndice = "+212" ;
			break;
		case "TUN":
			strIndice = "+216" ;
			break;
		default :
			strIndice = "";
			break;
	}
	if (strIndice != ""){
		if (a_strTel == ""){
			strTel = a_strTel;
		}else{
			if (a_strTel.indexOf(strIndice, 0)<0){
				strTel = strIndice + ' ' + a_strTel;
			}else{
				if (a_strTel.indexOf(strIndice + ' ', 0)<0){
					strTel = a_strTel.substr(a_strTel.indexOf(strIndice, 0), 4) + ' ' + a_strTel.substr(a_strTel.indexOf(strIndice, 0) + 4, a_strTel.length);
				}else{
					strTel = a_strTel;
				}
			}
		}
	}else{
		strTel = a_strTel;
	}
	return strTel;
}
/***********************************************************
  Popup image et retaille

  28/06/2006 - TRR : Création
  28/06/2006 - SMN : Mise aux normes
************************************************************/
function PopupImageEtRetaille(strChemin, strTitle, strAlt, booOnBlurClose )
{
	if ( typeof strTitle == 'undefined' ) strTitle = '';
	if ( typeof strAlt == 'undefined' ) strAlt = '';
	if ( typeof booOnBlurClose == 'undefined' ) booOnBlurClose = false;
	
	var strHtml = '<html><head><title>' + strTitle + '</title><link href="/style/style.css" rel="stylesheet" type="text/css" /></head><body onclick="javascript:window.close();"'
	if ( booOnBlurClose )
		strHtml = strHtml + ' onblur="top.close()"';
	strHtml = strHtml + '><div class="imageRetaillee"><img src="' + strChemin + '" border="0" name="ImageMax" onload="window.resizeTo(document.ImageMax.width+50, document.ImageMax.height+100)" alt="' + strAlt + '" /></div></body></html>';
	var objPopupImage = window.open( '', 'objPopupImage', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,width=1,height=1');
	objPopupImage.document.open();
	objPopupImage.document.write(strHtml);
	objPopupImage.document.close();
	
	return;
}; 

/********************************************************
Vérifie que l'âge de la personne ne dépasse pas l'âge limite à une certaine date.

05/07/2006 - ERU : Création 	
*********************************************************/
function CheckAge(a_strDateNaissance, a_datDateAnniversaireLimite, a_intAgeLimite) {
	var datDate=ConvertStringToDate(a_strDateNaissance, "fr");
	if (!datDate )
	{ 
		return k_intStructureDateInvalide;
	}

	var datTestDate=a_datDateAnniversaireLimite;
	var strTestAnnee = datTestDate.getFullYear();
	var strTestMois = datTestDate.getMonth() + 1;
	var strTestJour = datTestDate.getDate();

	var intAgeAnnees=0;var intAgeMois=0;

	if (datDate.getTime()>datTestDate.getTime()) {
		return k_intDateNaissanceSuperieureJour;
	}
	intAgeAnnees = datTestDate.getFullYear()-datDate.getFullYear();
	datTestDate.setYear(datDate.getYear());
	if ((datDate.getTime()>datTestDate.getTime())&&(datDate.getMonth()-datTestDate.getMonth()!=0)) {intAgeAnnees--;}
	else {
		datTestDate.setMonth(datDate.getMonth());
		if ((datDate.getTime()>datTestDate.getTime())&&(datDate.getDate()-datTestDate.getDate()!=0)) {intAgeAnnees--;}
	}
	if (datDate.getMonth() >= datTestDate.getMonth()) {
		intAgeMois = 12 - (datDate.getMonth()-datTestDate.getMonth())
	} else {
		intAgeMois = (datTestDate.getMonth()-datDate.getMonth())
	}
	if (intAgeMois==12) {intAgeMois=0;}
	
	intAgeJours = (datDate.getDate()-datTestDate.getDate())
	// Ne prends en compte l'âge qu'une fois révolu
	if (intAgeMois==0&&intAgeJours==0) {intAgeAnnees--;}
	
	// On remets la date limite à sa valeur originelle pour éviter le passage par référence.
	// Infos : http://www.tddsworld.com/blogs/eapc/?2006/03/10/439-javascript-contextes
	datTestDate.setFullYear(strTestAnnee, strTestMois-1, strTestJour);
	
	if (intAgeAnnees>=a_intAgeLimite) { 
		return k_intAgeLimiteDepasse;
	}

	return k_intOk;
}

/*************************************************************
Convertit une string type JJ/MM/YYYY en datetime JS
10/07/2006 - ERU : Création
*************************************************************/

function ConvertStringToDate (a_strDate, a_strCodeLangue) {
	var a_datDate;

	intRet = IsDate(a_strDate, a_strCodeLangue);
	if (intRet != k_intOk )
	{ 
		alert(AffErr("Fr", intRet)); 
		return false;
	}
	else
	{
		switch (a_strCodeLangue)
		{
			case "Fr" : case "fr" :
				intJour=parseInt(a_strDate.substring(0,2),10);
				intMois=parseInt(a_strDate.substring(3,5),10);
				break;
			default :
				intMois=parseInt(a_strDate.substring(0,2),10);
				intJour=parseInt(a_strDate.substring(3,5),10);
				break;
		}
		intAnnee=parseInt(a_strDate.substring(6,10),10);
		
		a_datDate = new Date();
		a_datDate.setFullYear(intAnnee, intMois-1, intJour);
		return a_datDate;
	}
}

/**************************************************************
Retourne un tableau d'éléments à partir de leur classe
17/07/2006 - ERU : Création (Reprise : http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/)
***************************************************************/

function getElementsByClassName(objElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : objElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var objRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var objElement;
    for(var i=0; i<arrElements.length; i++){
        objElement = arrElements[i];      
        if(objRegExp.test(objElement.className)){
            arrReturnElements.push(objElement);
        }   
    }
    return (arrReturnElements)
}

/***************************************************************
Retourne true si la valeur recherchée est dans le tableau
17/07/2006 - ERU : Création (Reprise : http://code.mikebrittain.com/?p=8)
****************************************************************/
Array.prototype.inArray = function (value)
{
    var i;
    for (i=0; i < this.length; i++) {
        // Matches identical (===), not just similar (==) -> 003 <> 3.
        if (this[i] === value) {
            return true;
        }
    }
    return false;
};

/***************************************************************
Retourne la position si la valeur recherchée est dans le tableau, sinon -1
17/07/2006 - ERU : Création
****************************************************************/
Array.prototype.getPosInArray = function (value)
{
    var i;
    for (i=0; i < this.length; i++) {
        // Matches identical (===), not just similar (==) -> 003 <> 3.
        if (this[i] === value) {
            return i;
        }
    }
    return -1;
};
function MM_showHideLayersByDisplay()
{ //v3.0
  var i,p,v,obj,args=MM_showHideLayersByDisplay.arguments;
  for (i=0; i<(args.length-2); i+=3)
  	if ((obj=MM_findObj(args[i]))!=null)
		{
			v=args[i+2];
			if (obj.style)
				{
					obj.style.display = v;
				}
	    }
}
/****************************************************************************************************
 Fonction qui permet le tri sur une liste

 ??/??/???? - ??? : Création
'****************************************************************************************************/
function sortResult(a_strForm, a_strOrderField, a_strActionForm) {
	var objForm = document.forms[a_strForm];

	if (objForm.strOrderBy.value != a_strOrderField){
		objForm.strSensOrder.value = "ASC";	
	}else{
		if (objForm.strSensOrder.value == "ASC"){
			objForm.strSensOrder.value = "DESC";	
		}else{
			objForm.strSensOrder.value = "ASC";	
		}
	}
	objForm.strOrderBy.value = a_strOrderField;
	objForm.action = a_strActionForm;
	objForm.submit();

}

