 /*-----------------------------------------------------------------------------------------
fonction 	: VerifReel
Auteur		: EJN
Date		: 04/02/02
Argument	: valeur
Return		: retourne vrai si valeur est un réel faux sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifReel(reel) {
	var indexPoint;
	var indexVirgule;
	var reg = /^-?\d+$/
	if (reg.exec(reel)){ return true; }
	else {
		indexVirgule = reel.indexOf(",");
		indexPoint = reel.indexOf(".");
		if((indexPoint == -1) && (indexVirgule == -1)){
			return false;
		}else{
			var regInt = /^\d*$/;
			if(indexPoint != -1){
				var partieG = reel.substring(0,indexPoint);
				var partieD = reel.substring(indexPoint+1,reel.length);
				if ((regInt.exec(partieG)!=null) && (regInt.exec(partieD)!=null)){
					return true;
				}else{
					return false;
				}
			}
			if(indexVirgule != -1){
				var partieG = reel.substring(0,indexVirgule);
				var partieD = reel.substring(indexVirgule+1,reel.length);
				if ((regInt.exec(partieG)!=null) && (regInt.exec(partieD)!=null)){
					return true;
				}else{
					return false;
				}
			}
		}
	}
}

function IsReel(objText)
{
if (!VerifReel(objText.value) && (objText.value != ""))
{
	alert("Vous devez saisir un numérique !")
	objText.focus()
	objText.select()
}
else
{
	valeur = objText.value
	valeur = valeur.replace(",",".")
	objText.value = valeur
}
}
 /*-----------------------------------------------------------------------------------------
fonction 	: verifEmail
Auteur		: SMN
Date		: 21/12/01
Argument	: email : adresse email
Return		: retourne vrai si l'adresse est correcte faux sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function verifEmail(email) {
    //var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
    var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
    return (reg.exec(email)!=null)
}
 /*-----------------------------------------------------------------------------------------
fonction 	: VerifstrMail
Auteur		: MHX
Date		: 25/02/02
Argument	: email
Return		: alerte si email valide et retourne false sinon true

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/



function VerifstrMail(email) {
	ret = true;
	reFocusField=email;
	if (!(email.value == "")){
		if (!(verifEmail(email.value))){
			ret = false;
			alert("Vous devez saisir une adresse mail valide !");
			email.select();
			email.focus();

		}
	}
	return ret;
}

/*-----------------------------------------------------------------------------------------
fonction 	: verifUrl
Auteur		: EMR
Date		: 03/06/04
Argument	: url : adresse internet
Return		: retourne vrai si l'adresse est correcte faux sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
	- NHR      17/11/2006 Ajout https dans la regex et des 3 www
-----------------------------------------------------------------------------------------*/
function verifUrl(url) {
	//var reg = /^http[s]?:\/\/[a-zA-Z0-9.-]{2,}[.][a-zA-Z.]{2,5}$/
	//var reg = /^http[s]?:\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/
	var reg = /^http[s]?:\/\/([a-zA-Z0-9.#.?_+=&%\-\/])*$/

	return (reg.exec(url)!=null)
}
 /*-----------------------------------------------------------------------------------------
fonction 	: VerifstrUrl
Auteur		: EMR
Date		: 03/06/04
Argument	: url
Return		: alerte si adresse internet valide et retourne false sinon true

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifstrUrl(url) {
	ret=true;
	if (!(url.value == "")){
		if (!(verifUrl(url.value))){
			ret=false;
			alert("Vous devez saisir une adresse internet valide !");
			url.focus();
			url.select();
		}
	}
	return ret;
}

/*-----------------------------------------------------------------------------------------
fonction 	: verifTel
Auteur		: EMR
Date		: 03/06/04
Argument	: tel : numero de tel ou de fax
Return		: retourne vrai si le numero de tel (non obligatoire)ou de fax est correcte faux sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function verifTel(tel) {
	ret = true
	var reg = /^[0-9]*$/
	if(tel.value!=""){
		if (tel.value.length != 10 || !( reg.exec(tel.value))) {
		alert("Le format du numéro est invalide (vous devez rentrer 10 entiers successifs).");
		tel.focus();
		tel.select();

		ret = false;
		}
	}
	return ret
}
 /*-----------------------------------------------------------------------------------------
fonction 	: VerifstrTel
Auteur		: EMR
Date		: 03/06/04
Argument	: tel
Return		: alerte si numero de tel ou de fax(non obligatoire) non valide et retourne false sinon true

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifstrTel(tel) {
	ret = true
	if (!(tel.value == "")){
		if (!(verifTel(tel.value))){
			alert("Vous devez saisir un numéro valide !");
			tel.focus();
			tel.select();

			ret = false
		}
	}
	return ret
}


/*-----------------------------------------------------------------------------------------
fonction 	: VerifstrMailDiv
Auteur		: MHX
Date		: 25/02/02
Argument	: email
Return		: alerte si email valide

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifstrMailDiv(email) {
	ret=true;
	if (!(email.value == "")){
		if (!(verifEmail(email.value))){
			ret=false;
			alert("Vous devez saisir une adresse mail valide !");
			email.focus();
			email.select();
		}
	}
	return ret;
}
 /*-----------------------------------------------------------------------------------------
fonction 	: VerifNum
Auteur		: SMN
Date		: 07/01/02
Argument	: numerique
Return		: retourne vrai si numerique est un numérique faux sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifNum(numerique) {
	var reg = /^-?\d+$/
	if (reg.exec(numerique)) return true
	else return false
}

 /*-----------------------------------------------------------------------------------------
fonction 	: VerifInt
Auteur		: MHX
Date		: 07/02/02
Argument	: num
Return		: alerte si num n'est pas un entier et return false sinon return true

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
	-  dcu		07/06/04	Ajout du renvoi d'un booléen
-----------------------------------------------------------------------------------------*/
function VerifInt(num) {
	ret = true;
	if (!(num.value == "")){
		if (!(VerifNum(num.value))){
			alert("Vous devez saisir un entier !");
			num.focus();
			num.select();
			ret = false;
		}
	}
	return ret;
}

//lbt fonction plus précise pour le controle du cp
function checkCP(objText)
{
	bRetour = true;
	val = objText.value;
	if (val != "")
	{
		var reg = /^\d+$/
		if (!reg.exec(val) || val.length != 5)
		{
			alert("Vous devez saisir un code postal valide !")
			objText.select();
			objText.focus();

			bRetour = false;
		}
	}
	return bRetour;
}

//jbs 04/10/4 fonction plus précise pour le controle du cp
function checkCP2(objText,europe)
{
	bRetour = true;
	val = objText.value;

	if (val != "")
	{
		var reg = /^\d+$/
		if (!reg.exec(val) || val.length != 5)
		{
			if (europe == 1){
				alert("Vous devez saisir un code postal valide !")
			}
			else{
				alert("Vous devez saisir un code postal français valide !")
			}
			objText.select();
			objText.focus();
			bRetour = false;
		}
	}
	return bRetour;
}


//jbs 04/10/4 fonction plus précise pour le controle du cp
function checkCP3(objText,europe)
{
	bRetour = true;
	val = objText.value;

	if (val != "")
	{
		var reg = /^\d+$/
		if (!reg.exec(val) || val.length==1 || val.length==3 || val.length==4)
		{
			if (europe == 1){
				alert("Vous devez saisir soit un département, soit un code postal valide !")
			}
			else{
				alert("Vous devez saisir soit un département, soit un code postal valide !")
			}
			objText.select();
			objText.focus();
			bRetour = false;
		}
	}
	return bRetour;
}


 /*-----------------------------------------------------------------------------------------
fonction 	: VerifCP
Auteur		: MHX
Date		: 12/04/02
Argument	: num
Return		: alerte si num n'est pas un entier

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifCP(num) {
	if (!(num.value == "")){
		if (isNaN(num.value)){
			alert("Vous devez saisir un code postal valide !");
			num.focus();
			num.select();
		}
	}
}


 /*-----------------------------------------------------------------------------------------
fonction 	: CheckAdrCp
Auteur		: DCU
Date		: 07/06/04
Argument	: cp, voie
Return		: alerte et return faux si cp mais lieu (nom de voie) n'est pas saisi, vrai sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function CheckAdrCp(cp,voie) {
	ret = true;
	if(cp.value != ""){
		if(voie.value == ""){
			alert("Veuillez d'abord saisir le lieu");
			cp.value="";
			voie.focus();
			ret = false;
		}
	}
	return ret;
}

/*-----------------------------------------------------------------------------------------
fonction 	: ClearCpVille
Auteur		: DCU
Date		: 07/06/04
Argument	: cp, ville
Return		: vide les champs cp et ville si le lieu (nom de voie ) n'est pas saisi, toujours vrai
Complément d'info : nom de voie est le seul à être obligatoire, sans lui, ni cp ni ville ne peuvent exister
			Cette fonction est utile dans le cas ou l'utilisateur rempli  le nom de la voie (le lieu) puis le cp
			puis la ville et alors retourne dans le champ 'nom de voie' pour le supprimer...
			(dans certains cas uniquement: Lieu d'exécution, de livraison, lieu commun)
-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function ClearCpVille(lieu,cp,ville) {
	ret = true;
	if(lieu.value==""){
		cp.value = "";
		ville.value = "";
	}
	return ret;
}

 /*-----------------------------------------------------------------------------------------
fonction 	: CheckAdrVille
Auteur		: DCU
Date		: 07/06/04
Argument	: cp, voie
Return		: alerte et return faux si ville mais lieu (nom de voie) n'est pas saisi, vrai sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function CheckAdrVille(ville,voie) {
	ret = true;
	if(ville.value!=""){
		if(voie.value == ""){
			alert("Veuillez d'abord saisir le lieu");
			ville.value="";
			voie.focus();
			ret = false;
		}
	}
	return ret;
}


 /*-----------------------------------------------------------------------------------------
fonction 	: CheckAdrVilleCP
Auteur		: JBS
Date		: 04/10/04
Argument	: cp, voie, Ville
Return		: alerte et return faux si CP non saisi ou si ville mais lieu (nom de voie) n'est pas saisi, vrai sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function CheckAdrVilleCP(ville,voie,CP) {
	ret = true;
	if (CP.value == "") {
		alert("Le code postal est obligatoire");
		CP.focus();
		ret = false;
	}
	else if (CP.value != "" && voie.value == "" && ville.value ==""){
		ret=true;
	}
	else if (CP.value != "" && voie.value != "" && ville.value ==""){
		alert("Vous devez saisir la ville et le lieu");
		ville.focus();
		ret = false;
	}
	else if (CP.value != "" && voie.value == "" && ville.value !=""){
		alert("Vous devez saisir la ville et le lieu");
		voie.focus();
		ret = false;
	}

	return ret;
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckAdrVilleCP
Auteur		: JBS
Date		: 04/10/04
Argument	: cp, voie, Ville
Return		: alerte et return faux si CP non saisi ou si ville mais lieu (nom de voie) n'est pas saisi, vrai sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function CheckAdrVilleCP2(ville,voie,CP) {
	ret = true;
	if (CP.value == "") {
		alert("Le code postal est obligatoire");
		CP.focus();
		ret = false;
	}
	else if (CP.value != "" && voie.value == "" && ville.value ==""){
		ret=true;
	}
	else if (CP.value != "" && voie.value != "" && ville.value ==""){
		alert("Vous devez saisir la ville et le lieu");
		ville.focus();
		ret = false;
	}
	else if (CP.value != "" && voie.value == "" && ville.value !=""){
		alert("Vous devez saisir la ville et le lieu");
		voie.focus();
		ret = false;
	}

	return ret;
}


/*-----------------------------------------------------------------------------------------
fonction 	: VerifDate
Auteur		: SMN
Date		: 19/02/01
Argument	:
		  - Du : Date de début (JJ/MM/AAAA)
		  - Au : Date de fin (JJ/MM/AAAA)
Return		: cette fonction compare deux dates et renvoie vrai si Du < Au, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifDate(Du,Au) {
if (Du == "" && Au == "") {
	return true;
}
else {
	aDateDu = Du.split("/");
	aDateAu = Au.split("/");
	if (aDateDu.length > 2) {
		if (aDateDu[2].length != 4) {
			return "Form";
		}
	}
	if (aDateAu.length > 2) {
	if (aDateAu[2].length != 4) {
		return "Form";
	}
	}
	DateDu = new Date(aDateDu[2], aDateDu[1] - 1, aDateDu[0])
	DateAu = new Date(aDateAu[2], aDateAu[1] - 1, aDateAu[0])
//alert(DateDu + " / " + DateAu)
	if (DateDu < DateAu) {
	  return true;
	}
	else {
	  if (Du == Au) {
		//return "Egale";
		// emr 02/12/04 pour date de debut et date de fin de marche pour les marches publics
		return false;
      }
	  else {
		return false;
 	  }
	}
}
}

/*-----------------------------------------------------------------------------------------
fonction 	: VerifDateBOAMP
Auteur		: EMR
Date		: 19/10/04
Argument	:
		  - Du : Date de début (JJ/MM/AAAA)
		  - Au : Date de fin (JJ/MM/AAAA)
Return		: cette fonction compare deux dates et renvoie vrai si Du < Au + 2, Faux sinon;
			Il faut une difference d'au moins 3 jours entre 2 dates (ex : 01 et 03 valide, pas 01 et 02)

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifDateBOAMP(Du,Au) {
if (Du == "" && Au == "") {
	return true;
}
else {
	aDateDu = Du.split("/");
	aDateAu = Au.split("/");
	if (aDateDu.length > 2) {
		if (aDateDu[2].length != 4) {
			return "Form";
		}
	}
	if (aDateAu.length > 2) {
		if (aDateAu[2].length != 4) {
			return "Form";
		}
	}
//alert("2 : " + aDateDu[2] + " , 1 : " +  aDateDu[1] - 1 + ", 0 : " + aDateDu[0])
	DateDu = new Date(aDateDu[2], aDateDu[1] - 1, aDateDu[0])
	DateAu = new Date(aDateAu[2], aDateAu[1] - 1, aDateAu[0])
//alert(DateDu + " / " + DateAu)

//alert("du : " + DateDu + " au " + DateAu);

	if (DateDu < DateAu) {
	  return true;
	}
	else {
	  if (Du == Au) {
		//return "Egale";
		// emr 02/12/04 pour date de debut et date de fin de marche pour les marches publics
		return false;
      }
	  else {
		return false;
 	  }
	}
}
}

/*-----------------------------------------------------------------------------------------
fonction 	: VerifDateAnte
Auteur		: DCU
Date		: 02/06/04
Argument	:
		  - maDate : Date à comparer avec la date du jour (JJ/MM/AAAA)

Return		: cette fonction compare deux dates et renvoie vrai si Date < date en cours, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifDateAnte(maDate) {
	var dayDate = new Date();
	var jour = dayDate.getDate()
	var mois = dayDate.getMonth() //(mois = 0 si mois de janvier)
	var an = dayDate.getFullYear()
	var d = jour + "/" + mois + "/" + an

	if (maDate == "") {
		return true;
	}
	else {
		aMaDate = maDate.split("/");
		aD = d.split("/");
		DateMaDate = new Date(aMaDate[2], aMaDate[1] - 1, aMaDate[0]);
		DateD = new Date(aD[2], aD[1], aD[0]);
		//alert(DateMaDate + "\n" + DateD);
		if (DateMaDate < DateD) {
			return true;
		}
		else {
			return false;
		}
	}
}


/*-----------------------------------------------------------------------------------------
fonction 	: VerifDatePost
Auteur		: DCU
Date		: 02/06/04
Argument	:
		  - maDate : Date à comparer avec la date du jour (JJ/MM/AAAA)

Return		: cette fonction compare deux dates et renvoie vrai si Date > date en cours, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function VerifDatePost(maDate) {
	var dayDate = new Date();
	var jour = dayDate.getDate()
	var mois = dayDate.getMonth() //(mois = 0 si mois de janvier)
	var an = dayDate.getFullYear()
	var d = jour + "/" + mois + "/" + an

	if (maDate == "") {
		return true;
	}
	else{
		aMaDate = maDate.split("/");
		aD = d.split("/");
		DateMaDate = new Date(aMaDate[2], aMaDate[1] - 1, aMaDate[0])
		DateD = new Date(aD[2], aD[1], aD[0])
		//alert(DateMaDate + "\n" + DateD);
		if (DateMaDate > DateD) {return true;}
		else {return false;}
	}
}

/*-----------------------------------------------------------------------------------------
Fonction 	: CompareDate
Auteur		: JPV
Date		: 04/12/2006
Arguments 	:
				- sDate1 : chaine contenant la 1ère date à comparer (JJ/MM/AAAA) (si null ou vide => date du jour)
				- sDate2 : chaine contenant la 2nde date à comparer avec la 1ère (JJ/MM/AAAA) (si null ou vide => date du jour)
				- sParam : chaine contenant l'opérateur de comparaison ("<", "<=", ">", ">=", "==", "!=") (si null ou vide => "==")

Return : cette fonction compare deux dates selon le paramètre sParam et renvoie le résultat de la comparaison (vrai ou faux)
-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function CompareDate(sDate1,sDate2,sParam)
{
	// Date du jour
	var dayDate = new Date();
	var jour = dayDate.getDate()
	var mois = dayDate.getMonth() + 1 //(getMonth() renvoie 0 pour le mois de janvier donc on ajoute 1)
	var an = dayDate.getFullYear()
	var d = jour + "/" + mois + "/" + an

	// Construction des objets Date
	oDate1 = new Object;
	oDate1.value = sDate1;
	oDate2 = new Object;
	oDate2.value = sDate2;

	if(oDate1.value == null || oDate1.value == '' || chkdate(oDate1) == false) oDate1.value = d;
	if(oDate2.value == null || oDate2.value == '' || chkdate(oDate2) == false) oDate2.value = d;

	aDate1 = oDate1.value.split("/");
	aDate2 = oDate2.value.split("/");

	dDate1 = new Date(aDate1[2],aDate1[1] - 1,aDate1[0]);
	dDate2 = new Date(aDate2[2],aDate2[1] - 1,aDate2[0]);

	var sToEval = 'dDate1 ' + sParam + ' dDate2';

	if(eval(sToEval) === true) 	return true;
	else 						return false;
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckLongueur
Auteur		: DCU
Date		: 03/06/04
Argument	:
		  - controle: objet champ dont on controle la longueur min et max
		  - min : longueur minimum
		  - max : longueur maximum

Return		: cette fonction vérifie que la longueur du champ est < au max et > au min et retourne Vrai, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function CheckLongueur(controle,min,max) {
	if (controle.value != "") {
		var longueurChaine;
		var longueurAajouter;
		longueurAajouter = 0;


		//NHR 1/12/2006 on trim la valeur du controle

		controle.value = controle.value.replace(/(^\s*)|(\s*$)/g,'');

		longueurChaine = controle.value.length;
		var caractere;
		for (var i=0;i<longueurChaine;i++) {
			caractere = controle.value.substr(i,1);

			switch (caractere) {
				case "'"://'=&#039;
					longueurAajouter += 5;
					break;
				case "\""://"=&quot;
					longueurAajouter += 5;
					break;
				case ">"://>=&gt;
					longueurAajouter += 3;
					break;
				case "<"://<=&lt;
					longueurAajouter += 3;
					break;
				case "€": //€=euro(s)
					longueurAajouter += 6;
					break;
			}
		}

		longueurChaine += longueurAajouter
		if (longueurChaine<min || longueurChaine>max) {
			alert("Le texte doit avoir un nombre de caractères supérieur à " + min + " et inférieur à " + max + ".");
			controle.select();
			controle.focus();
			return false;
		}
		else {
			return true;
		}
	}
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckLongueurFixe
Auteur		: DCU
Date		: 15/06/04
Argument	:
		  - controle: objet champ dont on controle la longueur
		  - p_long: longueur à respecter

Return		: cette fonction vérifie que la longueur du champ est égale à long et retourne Vrai, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function CheckLongueurFixe(controle,p_long,p_var) {
	if (controle.value != "") {
		if (controle.value.length != p_long) {
			alert("Pour la rédaction, les " + p_long + " premiers chiffres du code " + p_var + " sont nécessaires.");
			controle.select();
			controle.focus();
			return false;
		}
		else {
			return true;
		}
	}
}

/*-----------------------------------------------------------------------------------------
fonction 	: Replace_apos
Auteur		: EMR
Date		: 07/12/04
Argument	:
		  - controle: objet champ dont on remplace la simple quote par un " \' " pour affichage dans bloc dynamique


Return		: cette fonction retourne la chaine modifiée

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function Replace_apos(sChaineATraiter) {
	var sChaineTraitee
	sChaineTraitee = sChampATraiter
	if (sChampATraiter != "") {
		sChaineTraitee = sChaineATraiter.replace("&apos","'");
	}
	return sChampATraiter
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckClassSup
Auteur		: DCU
Date		: 15/06/04
Argument	:

Return		: cette fonction vérifie que la longueur du champ respecte le
			  format [A...Z][A..Z][0...9][0...9] (exemple "TA51") et
			  retourne Vrai, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function CheckClassSup(controle) {
	var ret = true;
	var val = controle.value;

	if (val != "") {
		if (val.length != 4) {
			alert("Le code de la classification supplémetaire saisi n'est pas correctement formaté (2 lettres suivis de 2 chiffre (exemple : AA01)).");
			controle.select();
			controle.focus();
			ret = false;
		}
	}
	return ret;
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckEntier
Auteur		: EMR
Date		: 03/06/04
Argument	:
		  - controle: objet  dont on controle la validite

Return		: cette fonction vérifie que le champ est un entier non nul(pour numéro de tel) et retourne Vrai, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function CheckEntier(controle) {
// Fonction de verification d'entree d'un entier non nul
	var valide = true;

	if (controle.value != "") {
		if (isNaN(controle.value)){
			valide = false;
			alert("Vous devez rentrer une suite de nombres entiers.");
		}
		if ((controle.value < 1) && (valide == true)) {
			valide = false;
			alert("Vous devez rentrer une suite de nombres entiers. '0000000000' n'est pas valide");
		}
		if ((controle.value != Math.floor(controle.value)) && (valide == true)) {
			valide = false;
			alert("Vous devez rentrer une suite de nombres entiers.");
		}
		if (!valide ){
			controle.select();
			controle.focus();
		}
	}
	return valide;
}

/*-----------------------------------------------------------------------------------------
fonction 	: VerifEntier
Auteur		: dcu
Date		: 15/06/04
Argument	:
		  - val: valeur dont on controle la validite

Return		: cette fonction vérifie que la valeur en paramètre est un entier et retourne Vrai, Faux sinon;
			  pas de message d'erreur

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function VerifEntier(val) {
// Fonction de verification d'entree d'un entier non nul
	var valide = true;

	if (val != "") {
		if (isNaN(val)) valide = false;
		if ((val != Math.floor(val)) && valide) valide = false;
	}
	return valide;
}


/*-----------------------------------------------------------------------------------------
fonction 	: trim
Auteur		: NHE
Date		: 17/04/07
Argument	:
		  - chaine de caractere à trimer

Return		: cette fonction trim une chaine de carecatere

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function trim(string){
  return string.replace(/(^\s*)|(\s*$)/g,'');
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckPourcentage
Auteur		: DCU
Date		: 09/06/04
Argument	:
		  - controle: objet  dont on controle la validite

Return		: cette fonction vérifie que le champ (non obligatoire) est un entier non nul entre 1 et 99 et retourne Vrai, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function CheckPourcentage(controle) {
	ret = true;
	if(controle.value!=""){

		if(!VerifEntier(controle.value)){
			alert("Vous devez saisir un nombre entier");
			ret = false;
			controle.select();
			controle.focus();
		}else{
			if((controle.value<1)||(controle.value>99)){
				alert("Vous devez saisir une valeur entre 1 et 99");
				ret = false;
				controle.select();
				controle.focus();
			}
		}
	}
	return ret;
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckEntierHeure
Auteur		: EMR
Date		: 03/06/04
Argument	:
		  - controle: parametre  dont on controle la validite (parametre de type string)

Return		: cette fonction vérifie que le parametre (string) est un entier et retourne Vrai, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function CheckEntierHeure(controle) {
// Fonction de verification d'entree d'un entier
	var valide;
	valide = true;

	if (controle != "") {
		if (isNaN(controle)){
			valide = false;
		}
		if ((controle < 0) && (valide == true)) {
			valide = false;
		}
		if ((controle != Math.floor(controle)) && (valide == true)) {
			valide = false;
		}
		if (valide == true) {
			return true;
		}
		else {
			return false;
		}
	}
}

/*-----------------------------------------------------------------------------------------
fonction 	: CheckHeure
Auteur		: EMR
Date		: 03/06/04
Argument	:
		  - controle: objet dont on controle la validite

Return		: cette fonction vérifie que le champ est une heure (entree sous la forme hh:mm) et retourne Vrai, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function CheckHeure(controle) {
	if (controle.value != "") {
		if (controle.value.length == 5) {
			if (controle.value.indexOf(":") >= 0) {
				if (controle.value.substring(controle.value.length-1,controle.value.length) != ":") {
					var tableau;
					tableau = controle.value.split(":");
					if (CheckEntierHeure(tableau[0]) && CheckEntierHeure(tableau[1])) {
						if ((tableau[0]<0) || (tableau[0]>23) || (tableau[1]<0) || (tableau[1]>59)) {
							alert("Format d'heure invalide.(exemple pour 9:30 saisissez : '09:30')");
							controle.focus();
							controle.select();
						}
					}
					else {
						alert("Format de l'heure invalide.(exemple pour 9:30 saisissez : '09:30')");
						controle.focus();
						controle.select();
					}
				}
				else {
					alert("Format de l'heure invalide.(exemple pour 9:30 saisissez : '09:30')");
					controle.focus();
					controle.select();
				}
			}
			else {
				alert("Format de l'heure invalide.(exemple pour 9:30 saisissez : '09:30')");
				controle.focus();
				controle.select();
			}
		}
		else {
			alert("Format de l'heure invalide.(exemple pour 9:30 saisissez : '09:30')");
			controle.focus();
			controle.select();
		}
	}
}

/*-----------------------------------------------------------------------------------------
fonction 	: checkDateAnte (utilise VerifDateAnte et checkdate)
Auteur		: DCU
Date		: 02/06/04
Argument	:
		  - maDate : Objet Date dont on verifie le format et que l'on compare avec la date du jour (JJ/MM/AAAA)

Return		: cette fonction vérifie que le format de la date est correct et compare une date avec la date du
			jour et renvoie vrai si Date < date en cours, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function checkDateAnte(maDate){
	//si une date d'avis de pré-info existe
	if (maDate.value != ""){
		//si le format de cette date est valide
		if (checkdate(maDate)){
			//si cette date est antérieur à la date en cours
			if (VerifDateAnte(maDate.value)){return true;}else{return false;}
		}else{return false;}
	}else{return true;}
}

/*-----------------------------------------------------------------------------------------
fonction 	: checkDatePost (utilise VerifDatePost et checkdate)
Auteur		: DCU
Date		: 09/06/04
Argument	:
		  - maDate : Objet Date dont on verifie le format et que l'on compare avec la date du jour (JJ/MM/AAAA)

Return		: cette fonction vérifie que le format de la date est correct et compare une date avec la date du
			jour et renvoie vrai si Date > date en cours, Faux sinon;

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function checkDatePost(maDate){
	//si une date d'avis de pré-info existe
	if (maDate.value != ""){
		//si le format de cette date est valide
		if (checkdate(maDate)){
			//si cette date est postérieur à la date en cours
			if (VerifDatePost(maDate.value)){return true;}else{return false;}
		}else{return false;}
	}else{return true;}
}


/*-----------------------------------------------------------------------------------------
fonction 	: checkdate
Auteur		: MHX
Date		: 07/02/02
Argument	: num
Return		: alerte si num n'est pas un entier

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/


function f_determineJour(p_dateSaisie) {
            //p_dateSaisie est de la forme "14/01/2007"
            var jour;
            var mois;
            var annee;
            var tabDateSaisie = new Array();
            //On traite le paramètre de la fonction de facon a initialiser les variabales jour, mois et année
            tabDateSaisie = p_dateSaisie.split("/");
            jour = tabDateSaisie[0];
            //Les mois sont numéroté de 0 à 11 (exemple : mois de (janvier = 1) = 0 pour créer la date en javascript)
            mois = tabDateSaisie[1]-1;
            annee = tabDateSaisie[2];
            dateSaisie = new Date(annee,mois,jour);
            jour = dateSaisie.getDay();
            return jour; // 0-6 0= dimanche

}

function paques(annee) {
   annee = parseInt(annee);
   var date_paques = null;
   var b = annee - 1900;
   var c = annee % 19;
   var d = Math.floor((7*c+1)/19);
   var e = (11*c+4-d) % 29;
   var f = Math.floor(b/4);
   var g = (b+f+31-e) % 7;
   var avril = 25-e-g;
   if (avril > 0) date_paques = new Date(annee, 3, avril);
   else date_paques = new Date(annee, 2, avril + 31);
   return date_paques;
}

function f_determineDateEstFerie(p_dateSaisie) {
            // gere que les dates fixes pour le moment les autres dependent de paques
            //("01/01", "01/05", "14/07", "15/08", "01/11", "11/11", "25/12");
            var jour;
            var mois;
            var annee;
            var tabDateSaisie = new Array();
            //On traite le paramètre de la fonction de facon a initialiser les variabales jour, mois et année
            tabDateSaisie = p_dateSaisie.split("/");
            jour = tabDateSaisie[0];
            //Les mois sont numéroté de 1 à 12
            mois = tabDateSaisie[1];
            annee = tabDateSaisie[2];

            if(mois=="1" && jour=="1"){
              return true;
            }
            if(mois=="5" && jour=="1"){
              return true;
            }
            if(mois=="5" && jour=="8"){
              return true;
            }
            if(mois=="11" && jour=="1"){
              return true;
            }
            if(mois=="11" && jour=="11"){
              return true;
            }
            if(mois=="12" && jour=="25"){
              return true;
            }

            //en fonction de paques
           /* mois = mois -1; // Convertion en JS du mois
            dateSaisie = new Date(annee,mois,jour);
            jourpaques = paques(annee);
            //paques
            if (jourpaques.getDate() == dateSaisie.getDate()){
              return true;
            }
            //lundi de paques
            if (jourpaques.getDate()+1==dateSaisie.getDate()){
              return true;
            }*/
            /*
            //ascension
            if (jourpaques.getDate()+39==dateSaisie.getDate()){
              return true;
            }
            //dimanche pentecote
             if (jourpaques.getDate()+48==dateSaisie.getDate()){
              return true;
            }
            //lundi de pentecote

             if (jourpaques.getDate()+49==dateSaisie.getDate()){
              return true;
            }*/
            return false;
}




<!-- Begin
function checkdate(objName) {
var datefield = objName;
if (chkdate(objName) == false) {
  datefield.select();
  alert("Le format de date est invalide.");
  datefield.focus();
  return false;
}

if (datefield.value != '' && f_determineJour(datefield.value)==0){
  alert("Le jour saisi est un dimanche.");
  datefield.focus();
  return false;
}
if (datefield.value != '' && f_determineDateEstFerie(datefield.value)){
  alert("Le jour saisi est un jour férié.");
  datefield.focus();
  return false;
}

  return true;
}


function chkdate(objName) {
//var strDatestyle = "US"; //United States date style
var strDatestyle = "EU";  //European date style
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;
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;
booFound = false;
alert("Le format de date est invalide.");
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);

   }
}
// US style
if (strDatestyle == "US") {
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;
   }
}
if (!(isNaN(strYear)) && (strYear.length == 2))
{
	if (strYear > 30) strYear = "19" + strYear;
	else strYear = "20" + strYear;
	strYear = Math.floor(strYear)
}
intYear = parseInt(strYear, 10);
if (isNaN(strYear) || strYear.length<4) {
err = 4;
return false;
}
else{
	if (intYear<1800) {
	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;
}
}
}
if (strDatestyle == "US") {
datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
//datefield.value = intday + "/" + strMonthArray[intMonth-1] + "/" + strYear;
datefield.value = intday + "/" + intMonth + "/" + strYear;
}
return true;
}

function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

function doDateCheck(from, to) {
if (Date.parse(from.value) <= Date.parse(to.value)) {
alert("Le format de date est invalide");
}
else {
   }
}
//  End -->

function checkHeure(objName){
	var heureValue = objName.value;
	if((heureValue<0) || (heureValue>=25)){
		objName.select;
		alert("Le format de l'heure est invalide.");
		objName.focus();
		return false;
	}
	else {
		return true;
   }
}

function checkMinute(objName){
	var minuteValue = objName.value;
	if((minuteValue<0) || (minuteValue>=60)){
		objName.select;
		alert("Le format des minutes est invalide.");
		objName.focus();
		return false;
	}
	else {
		return true;
   }
}

/* ********************************************************************
Softricks Popup Date Picker Calendar
Author : Kedar R. Bhave
************************************************************************ */

function name_values(instring) {
	// Assumption: ';' is a restricted character in a value.
	// Returns an array of variable names set by this function.
	var vars = new Array();
	rc = "\235";
	instring = instring.replace(/\\\;/g, rc);

	var pattern = /[a-zA-Z0-9]+\=[\/:#a-zA-Z0-9\. \235]+/gi;
	var y = instring.match(pattern);
	for (i=0; i<y.length; i++) {
		var s = y[i].split("=");
		s[1] = s[1].replace(rc, ";");
		vars[i] = "v_" + s[0];
		eval(vars[i] + " = '" + s[1] + "'");
	}
	return vars;
}

var onClickFnCode = "";
var orig_onClickFnCode = "";

// This is a Dynamic function. Its function code is constructed
// in onclickfn method and set in the show method.
// This function is here in the same way as the function we
// construct in the calendar window in case of POPUP calendar.
// This is for the INLINE calendar - used to append selected dates

function onClickFn(pday) {
	var re = /pday/;
	onClickFnCode = orig_onClickFnCode;
	onClickFnCode = onClickFnCode.replace(re, "'" + pday + "'");
	eval(onClickFnCode);
}

// Custom parameters set by the 6th argument to show_calendar function.
// CUSTOM STRING
var v_CloseOnSelect, v_AppendOrReplace, v_AppendChar, v_ReturnData;
var v_InlineX, v_InlineY, v_Title, v_CurrentDate, v_AllowWeekends;
var v_Resizable, v_Width, v_Height, v_SelectAfter, v_NSHierarchy;
var v_SelectBefore, v_CallFunction, v_PopupX, v_PopupY;

var weekend = [0,6];

var fontface = "Arial, Helvetica, sans-serif";
var fontsize = 2;

var gNow = new Date();
var ggWinCal;           // Really global variable pointing to the calendar window

// Drag-n-Drop Variables
var theLayer;
var theLayerStyle;		// Style used for positioning in IE.

var currX, currY;
var cx, cy;				// Client co-ords
var x, y;				// Co-ords of the point at first click
var incrX, incrY;

var mDown, mUp;

// Custom parameters set by the 7th argument to show_calendar function.
// ENVIRONNEMENT
var p_env;

// ----------- VARIABLE DECLARATIONS END -----------

isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;

// Month names in YOUR Language (French/Spanish..)
Calendar.Months = ["Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin",
	"Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"];
// Month names in English
Calendar.EMonths = ["Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin",
	"Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"];

// Non-Leap year Month days..
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

Calendar.DOW = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

Calendar.supportedFormats = ["MM/DD/YYYY", "MM/DD/YY", "MM-DD-YYYY", "MM-DD-YY", "DD/MON/YYYY", "DD/MON/YY", "DD-MON-YYYY", "DD-MON-YY", "DD/MONTH/YYYY", "DD/MONTH/YY", "DD-MONTH-YYYY", "DD-MONTH-YY", "MONTH DD, YYYY", "DD/MM/YYYY", "DD/MM/YY", "DOW, DD-MON-YY", "YYYY-MM-DD"];

Calendar.count = 0;
Calendar.Format = null;

// For inline calendar, the default contents of the layer. (v1.3)
Calendar.gInitText = "Resoceane.com Calendar";

function Calendar(p_item, p_WinCal, p_month, p_year, p_format, p_type) {

	// Argument p_type defines if the calendar is popup or inline
	// If p_type is INLINE,
	//    you must pass p_inline parameter which specifies the name of the layer
	//    which displays the calendar inline.
	//    --->

	if ((p_month == null) && (p_year == null))      return;

	if (p_WinCal == null)
		this.gWinCal = ggWinCal;
	else
		this.gWinCal = p_WinCal;

	if (p_month == null) {
		this.gMonthName = null;
		this.gMonth = null;
		this.gYearly = true;
	} else {
		this.gMonthName = Calendar.get_month(p_month);
		this.gMonth = new Number(p_month);
		this.gYearly = false;
	}

	if (p_type == null)
		this.gType = "POPUP";		// Default is popup
	else
		this.gType = p_type;

	if (this.gType == "INLINE") {
		this.WHO = "";
		this.INLINE = "Calendar";	// Inline Calendar Layer name
		this.codeINLINE = "";		// Calendar code will be constructed in this var
	} else
		this.WHO = "window.opener.";

	this.gYear = p_year;
	this.gFormat = p_format;
	this.gBGColor = "white";
	this.gFGColor = "black";
	this.gTextColor = "black";
	this.gHeaderColor = "black";
	this.gReturnItem = p_item;
	this.gTitle = "Softricks.com Calendar";
}

Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.get_dow = Calendar_get_dow;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.print = Calendar_print;
Calendar.CreateCalendarLayer = Calendar_CreateCalendarLayer;
Calendar.Close = Calendar_Close;
Calendar.Lwwrite = Calendar_Lwwrite;
Calendar.MoveTo = Calendar_MoveTo;
Calendar.isWeekend = Calendar_isWeekend;

function Calendar_get_month(monthNo, pLanguage) {
if (!pLanguage || pLanguage=="E")
	return Calendar.EMonths[monthNo];
else
	return Calendar.Months[monthNo];
}

function Calendar_get_dow(dayNo) {
	return Calendar.DOW[dayNo];
}

function Calendar_get_daysofmonth(monthNo, p_year) {
	/*
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for...
	2.Years also evenly divisible by 100 are not leap years, except for...
	3.Years also evenly divisible by 400 are leap years.
	*/
	if ((p_year % 4) == 0) {
			if ((p_year % 100) == 0 && (p_year % 400) != 0)
					return Calendar.DOMonth[monthNo];

			return Calendar.lDOMonth[monthNo];
	} else
			return Calendar.DOMonth[monthNo];
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	/*
	Will return an 1-D array with 1st element being the calculated month
	and second being the calculated year
	after applying the month increment/decrement as specified by 'incr' parameter.
	'incr' will normally have 1/-1 to navigate thru the months.
	*/
	var ret_arr = new Array();

	if (incr == -1) {
		// B A C K W A R D
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		// F O R W A R D
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}

	return ret_arr;
}

function Calendar_print() {
	ggWinCal.print();
}

function Calendar_isWeekend(pday) {
	var i;

	for (i=0; i<weekend.length; i++) {
		if (pday == weekend[i])
			return true;
	}
	return false;
}

// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
new Calendar();

Calendar.prototype.setFormat = function(pFormat) {
	var j;
	for (j=0; j<Calendar.supportedFormats.length; j++) {
		if (Calendar.supportedFormats[j] == pFormat)
			Calendar.Format = pFormat;
	}
}

Calendar.prototype.getMonthlyCalendarCode = function() {
	var vCode = "";
	var vHeader_Code = "";
	var vData_Code = "";

	// Begin Table Drawing code here..
	// PMED-200902 09/10/2009
	if (p_env != "/EFL")
		vCode = vCode + "<TABLE WIDTH='237' BORDER=0 bgcolor='#E0E0E0' Cellpadding='1'>";
	else
		vCode = vCode + "<TABLE WIDTH='237' BORDER=0 bgcolor='#94A4B3' CELLPADDING='0' CELLSPACING='0'>";

	vHeader_Code = this.cal_header();
	vData_Code = this.cal_data();
	vCode = vCode + vHeader_Code + vData_Code;

	vCode = vCode + "</TABLE>";

	return vCode;
}

Calendar.prototype.onclickfn = function() {
	// This should return the code string for the onclickfn in the calendar document.

	// This is the reference to the return object
	// window.opener.document. / window.document. ... .value
	var whois = this.WHO +
				((this.gType == "POPUP") ?
				"document." + v_NSHierarchy :
				"window.document." + v_NSHierarchy) +
				this.gReturnItem + ".value";

	// apchar will turn out to be either " = " or " += ''" or " += ';'"
	var apchar = (this.returnMode == "Replace") ? " = " : " += ";

	var retCode = "apchar = ''" +
					((this.returnMode == "Replace") ? ";" : " + ") +
					"((" + whois + " == '') ? '' : '" + this.appendChar + "');\n" +
				whois + apchar + "apchar + pday;\n";

	return retCode;
}

Calendar.prototype.show = function() {
	var vCode = "";

	if (this.gType == "POPUP")
		this.gWinCal.document.open();

	// Setup the page...
	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");

	if (this.gType == "POPUP")
		this.wwrite("<script language='javascript'>" +
			"function onClickFn(pday) {\n" +
			this.onclickfn() + "}\n<\/script>");
	else
		orig_onClickFnCode = this.onclickfn();

	this.wwrite("</head>");

	this.wwrite("<body " +
			"link=\"" + this.gLinkColor + "\" " +
			"vlink=\"" + this.gLinkColor + "\" " +
			"alink=\"" + this.gLinkColor + "\" " +
			"text=\"" + this.gTextColor + "\" LANGUAGE=javascript onload=\"window.focus();\">");

	// PMED-200902 09/10/2009
	if (p_env != "/EFL")
	{
		this.wwrite("<TABLE WIDTH='237' BORDER=0  bgcolor='black' BORDERCOLOR='black'><TR><TD>")  ;

		//Line Calendrier
		this.wwrite("<TABLE BORDER=0 WIDTH='100%' CELLPADDING=0>");
		this.wwrite("<TR BGCOLOR='#FFCC00'><TD BGCOLOR='#FFCC00'>" );
		this.wwrite("<FONT COLOR=black FACE='" + fontface + "' SIZE=2><B>" + this.gTitle + "</B></FONT>" );
		this.wwrite("</TD><TD BGCOLOR='#FFCC00' ALIGN=CENTER>" );
		this.wwrite("<FONT COLOR=white FACE='" + fontface + "' SIZE=2><B>" );
		this.wwrite("<A HREF='javascript:" );
		this.wwrite(this.WHO + "Calendar.Close(\"" + this.gType + "\", \"" + this.INLINE + "\");' " );
		this.wwrite("STYLE='color:blck;text-decoration:none'>" );
		this.wwrite("X</A></B></FONT></TD></TR></TABLE>");

		//Ligne Mois
		this.wwrite("<TABLE WIDTH='237' BORDER=0 WIDTH='100%' CELLPADDING=0><TR >");
		this.wwrite("<TD BGCOLOR='#808080' COLSPAN=2>");
		this.wwriteA("<FONT FACE='" + fontface + "' COLOR='white' SIZE=2><B>");
		this.wwriteA(this.gMonthName + " " + this.gYear);
		this.wwriteA("</B></TD></TR></TABLE>");

		// Show navigation buttons
		var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
		var prevMM = prevMMYYYY[0];
		var prevYYYY = prevMMYYYY[1];

		var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
		var nextMM = nextMMYYYY[0];
		var nextYYYY = nextMMYYYY[1];

		this.wwrite("<TABLE WIDTH='237' CELLSPACING=0 CELLPADDING=0><TR bgcolor=white><TD bgcolor=white ALIGN=center>");
		//<<
		this.wwrite("<FONT COLOR=#DE9900 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"[<A COLOR=#DE9900 HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#DE9900><b><<</b></FONT><\/A>]</FONT></TD><TD ALIGN=center>");
		//<
		this.wwrite("<FONT COLOR=#DE9900 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"[<A COLOR=#DE9900 HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#DE9900><b><</b></FONT><\/A>]</FONT></TD><TD bgcolor=white ALIGN=center>");
		//Date
		this.wwrite("<FONT COLOR=#DE9900 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"[<A  HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + gNow.getMonth() + "', '" + gNow.getFullYear() + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#DE9900><b> Date du jour </b></FONT><\/A>]</FONT></TD><TD bgcolor=white ALIGN=center>");
		//>
		this.wwrite("<FONT COLOR=#DE9900 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"[<A COLOR=#DE9900 HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#DE9900><b>></b></FONT><\/A>]</FONT></TD><TD ALIGN=center>");
		//>>
		this.wwrite("<FONT COLOR=#DE9900 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"[<A COLOR=#DE9900 HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#DE9900><b>>></b></FONT><\/A>]</FONT></TD></TR></TABLE>");

		//Ligne vide
		this.wwrite("<TABLE WIDTH='237' BORDER=0 WIDTH='100%' CELLPADDING=0><TR>");
		this.wwrite("<TD BGCOLOR='#808080' COLSPAN=2>");
		this.wwriteA("&nbsp;</TD></TR></TABLE>");
	}
	else
	{
		this.wwrite("<TABLE WIDTH='237' BORDER=0 CELLPADDING=0 CELLSPACING=0 ><TR><TD>")  ;

		//Line Calendrier
		this.wwrite("<TABLE BORDER=0 WIDTH='100%' CELLPADDING=0 CELLSPACING=0>");
		this.wwrite("<TR BGCOLOR='#A4B6C6'><TD BGCOLOR='#A4B6C6' ALIGN='CENTER' style='width: 19px;' HEIGHT='22'>" );
		this.wwrite("</TD><TD BGCOLOR='#A4B6C6' ALIGN=CENTER HEIGHT='22'>" );
		this.wwrite("<FONT COLOR=black FACE='" + fontface + "' SIZE=2><B>" + this.gTitle + "</B></FONT>" );
		this.wwrite("</TD><TD BGCOLOR='#A4B6C6' ALIGN=CENTER style='width: 19px;' HEIGHT='22'>" );
		this.wwrite("<A HREF='javascript:" );
		this.wwrite(this.WHO + "Calendar.Close(\"" + this.gType + "\", \"" + this.INLINE + "\");' " );
		this.wwrite("STYLE='color:blck;text-decoration:none'>" );
		this.wwrite("<IMG SRC='/Images/EFL/icone_fermeture.gif' BORDER=0></A></TD></TR></TABLE>");

		//Ligne Mois
		this.wwrite("<TABLE WIDTH='237' BORDER=0 WIDTH='100%' CELLPADDING=0 CELLSPACING=0><TR >");
		this.wwrite("<TD BGCOLOR='#94A4B3' COLSPAN=2 ALIGN='center' HEIGHT='22'>");
		this.wwriteA("<FONT FACE='" + fontface + "' COLOR='white' SIZE=2>");
		this.wwriteA(this.gMonthName + " " + this.gYear);
		this.wwriteA("</TD></TR></TABLE>");

		// Show navigation buttons
		var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
		var prevMM = prevMMYYYY[0];
		var prevYYYY = prevMMYYYY[1];

		var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
		var nextMM = nextMMYYYY[0];
		var nextYYYY = nextMMYYYY[1];

		this.wwrite("<TABLE WIDTH='237' CELLSPACING=0 CELLPADDING=0><TR bgcolor='D8E3EE'><TD bgcolor='D8E3EE' ALIGN=center>");
		//<<
		this.wwrite("<FONT COLOR=#2687E8 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"<A COLOR=#2687E8 STYLE='text-decoration:none;' HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#2687E8>&lt;&lt;</FONT><\/A></FONT> <FONT COLOR=#505D69 FACE='" + fontface + "' SIZE=2>|</FONT> </TD><TD ALIGN=center>");
		//<
		this.wwrite("<FONT COLOR=#2687E8 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"<A COLOR=#2687E8 STYLE='text-decoration:none;' HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#2687E8>&lt;</FONT><\/A></FONT></TD><TD bgcolor='D8E3EE' ALIGN=center>");
		//Date
		this.wwrite("<FONT COLOR=#2687e8 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"<A STYLE='text-decoration:none;' HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + gNow.getMonth() + "', '" + gNow.getFullYear() + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#2687E8>Date du jour</FONT><\/A></FONT></TD><TD bgcolor='D8E3EE' ALIGN=center>");
		//>
		this.wwrite("<FONT COLOR=#2687E8 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"<A COLOR=#2687E8 STYLE='text-decoration:none;' HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#2687E8>&gt;</FONT><\/A></FONT> <FONT COLOR=#505D69 FACE='" + fontface + "' SIZE=2>|</FONT> </TD><TD ALIGN=center>");
		//>>
		this.wwrite("<FONT COLOR=#2687E8 FACE='" + fontface + "' SIZE=2>" );
		this.wwrite(		"<A COLOR=#2687E8 STYLE='text-decoration:none;' HREF=\"" );
		this.wwrite(		"javascript:" + this.WHO + "Build(" );
		this.wwrite(		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "', '" + this.gType + "'" );
		this.wwrite(		");\"><FONT COLOR=#2687E8>&gt;&gt;</FONT><\/A></FONT></TD></TR></TABLE>");
	}
	//fin PMED-200902 09/10/2009

	// Get the complete calendar code for the month..
	vCode = this.getMonthlyCalendarCode();
	this.wwrite(vCode);

	this.wwrite("</TD></TR></TABLE>");

	this.wwrite("</body></html>");

	if (this.gType == "POPUP")
		this.gWinCal.document.close();

	if (this.gType == "INLINE")
		Calendar.Lwwrite(this.codeINLINE, this.INLINE);
}

function Calendar_Close(pType, pINLINE) {
	if (pType == "POPUP")
		ggWinCal.close();
	if (pType == "INLINE")
		Calendar.Lwwrite(Calendar.gInitText, pINLINE)
}

Calendar.prototype.showY = function() {
	var vCode = "";
	var i;
	var vr, vc, vx, vy;             // Row, Column, X-coord, Y-coord
	var vxf = 285;                  // X-Factor
	var vyf = 200;                  // Y-Factor
	var vxm = 10;                   // X-margin
	var vym;                                // Y-margin
	if (isIE)       vym = 75;
	else if (isNav) vym = 25;

	this.gWinCal.document.open();

	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("<style type='text/css'>\n<!--");
	for (i=0; i<12; i++) {
		vc = i % 3;
		if (i>=0 && i<= 2)      vr = 0;
		if (i>=3 && i<= 5)      vr = 1;
		if (i>=6 && i<= 8)      vr = 2;
		if (i>=9 && i<= 11)     vr = 3;

		vx = parseInt(vxf * vc) + vxm;
		vy = parseInt(vyf * vr) + vym;

		this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
	}
	this.wwrite("-->\n</style>");

	if (this.gType == "POPUP")
		this.wwrite("<script language='javascript'>" +
			"function onClickFn(pday) {\n" +
			this.onclickfn() + "}\n<\/script>");
	else
		orig_onClickFnCode = this.onclickfn();

	this.wwrite("</head>");

	this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");

	this.wwrite("Year : " + this.gYear);
	this.wwrite("</B><BR>");

	// Show navigation buttons
	var prevYYYY = parseInt(this.gYear) - 1;
	var nextYYYY = parseInt(this.gYear) + 1;

	this.wwrite("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0 ><TR><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
			"javascript:window.opener.Build(" +
			"'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
			");" +
			"\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
			"javascript:window.opener.Build(" +
			"'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
			");" +
			"\">>><\/A>]</TD></TR></TABLE><BR>");

	// Get the complete calendar code for each month..
	var j;
	for (i=11; i>=0; i--) {
		if (isIE)
				this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
		else if (isNav)
				this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

		this.gMonth = i;
		this.gMonthName = Calendar.get_month(this.gMonth);
		vCode = this.getMonthlyCalendarCode();
		this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
		this.wwrite(vCode);

		if (isIE)
				this.wwrite("</DIV>");
		else if (isNav)
				this.wwrite("</LAYER>");
	}

	this.wwrite("</font><BR></body></html>");
	this.gWinCal.document.close();
}


Calendar.prototype.cal_header = function() {
	var vCode = "";

	// PMED-200902 09/10/2009
	if (p_env != "/EFL")
	{
		vCode = vCode + "<TR bgcolor='white'>";
		vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' align='center' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Dim</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' align='center' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Lun</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' align='center' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mar</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' align='center' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mer</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' align='center' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Jeu</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' align='center' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Ven</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' align='center' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sam</B></FONT></TD>";
	}
	else
	{
		vCode = vCode + "<TR bgcolor='#94A4B3'>";
		vCode = vCode + "<TD WIDTH='14%' align='center' HEIGHT='22'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Dim</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%' align='center' HEIGHT='22'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Lun</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%' align='center' HEIGHT='22'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mar</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%' align='center' HEIGHT='22'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mer</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%' align='center' HEIGHT='22'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Jeu</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='14%' align='center' HEIGHT='22'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Ven</B></FONT></TD>";
		vCode = vCode + "<TD WIDTH='16%' align='center' HEIGHT='22'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sam</B></FONT></TD>";
	}
	vCode = vCode + "</TR>";

	return vCode;
}

Calendar.prototype.cal_data = function() {
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(this.gMonth);
	vDate.setFullYear(this.gYear);

	var vFirstDay = vDate.getDay();
	var vDay=1;
	var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
	var vOnLastDay=0;
	var vCode = "";

	var linkText = "";
	var linkCloseText = "";

	/*
	Get day for the 1st of the requested month/year..
	Place as many blank cells before the 1st day of the month as necessary.
	*/

	// PMED-200902 09/10/2009
	if (p_env != "/EFL")
		vCode = vCode + "<TR bgcolor='white'>";
	else
		vCode = vCode + "<TR bgcolor='#D8E3EE'>";

	for (i=0; i<vFirstDay; i++) {
		// PMED-200902 09/10/2009
		if (p_env != "/EFL")
			vCode = vCode + "<TD ALIGN='center' WIDTH='14%'" + this.write_weekend_string(i, 0) + "><FONT SIZE='2' FACE='" + fontface + "'>&nbsp;</FONT></TD>";
		else
			vCode = vCode + "<TD ALIGN='center' WIDTH='14%' HEIGHT='20'" + this.write_weekend_string(i, 1) + "><FONT SIZE='2' FACE='" + fontface + "'>&nbsp;</FONT></TD>";
	}

	// If closeable...
	if (this.closeable) {
		closecodeP = ((this.gType=="POPUP") ? "window.close();" : "");
		closecodeI = "Calendar.Close(\"" + this.gType + "\", \"" + this.INLINE + "\"); ";
	} else {
		closecodeP = "";
		closecodeI = "void(0);' ";
	}

	var whois = this.WHO +
				((this.gType == "POPUP") ? "document." : "window.document.") +
				this.gReturnItem + ".value";

	// Write rest of the 1st week
	for (j=vFirstDay; j<7; j++) {
		vDate.setDate(vDay);
		if ((this.gAllowWeekends == "No" && Calendar.isWeekend(j)) ||
			(vDate < v_SelectAfter || vDate > v_SelectBefore)) {
					linkText = "";
					linkCloseText = "";
		} else {
			// PMED-200902 09/10/2009
			if (p_env != "/EFL") {
			linkText = "<A HREF='javascript:" + closecodeI + "' " +
				"onClick=\"onClickFn('" +

				((this.returnData == "Date") ?
				this.format_data(vDay) :
				this.format_dow(vDay)) +

				"');" +
				((this.CallFunction != "") ? (this.WHO + this.CallFunction + "();") : "") +
				closecodeP +
				"\">";
			linkCloseText = "<\/A>";
			}
			else
			{
			linkText = "<A STYLE='color:#2687e8;text-decoration:none;' HREF='javascript:" + closecodeI + "' " +
				"onClick=\"onClickFn('" +

				((this.returnData == "Date") ?
				this.format_data(vDay) :
				this.format_dow(vDay)) +

				"');" +
				((this.CallFunction != "") ? (this.WHO + this.CallFunction + "();") : "") +
				closecodeP +
				"\">";
			linkCloseText = "<\/A>";
			}
		}

		// PMED-200902 09/10/2009
		if (p_env != "/EFL")
			vCode = vCode + "<TD ALIGN='center' WIDTH='14%'" + this.write_weekend_string(j, 0) +
				"><FONT SIZE='2'  FACE='" + fontface + "'>" +
				linkText + this.format_day(vDay) + linkCloseText + "</FONT></TD>";
		else
			vCode = vCode + "<TD ALIGN='center' WIDTH='14%' HEIGHT='20'" + this.write_weekend_string(j, 1) +
				"><FONT SIZE='2'  FACE='" + fontface + "'>" +
				linkText + this.format_day(vDay) + linkCloseText + "</FONT></TD>";

		vDay = vDay + 1;
	}
	vCode = vCode + "</TR>";

	// Write the rest of the weeks
	for (k=2; k<7; k++) {

		// PMED-200902 09/10/2009
		if (p_env != "/EFL")
			vCode = vCode + "<TR bgcolor='white'>";
		else
			vCode = vCode + "<TR bgcolor='#D8E3EE'>";

		for (j=0; j<7; j++) {
			vDate.setDate(vDay);
			if ((this.gAllowWeekends == "No" && Calendar.isWeekend(j)) ||
				(vDate < v_SelectAfter || vDate > v_SelectBefore)) {
					linkText = "";
					linkCloseText = "";
			} else {
				// PMED-200902 09/10/2009
				if (p_env != "/EFL") {
				linkText = "<A HREF='javascript:" + closecodeI + "' " +
					"onClick=\"onClickFn('" + ((this.returnData == "Date") ? this.format_data(vDay) : this.format_dow(vDay)) + "');" +
					((this.CallFunction != "") ? (this.WHO + this.CallFunction + "();") : "") +
					closecodeP + "\">";
				linkCloseText = "<\/A>";
				} else {
				linkText = "<A STYLE='color:#2687e8;text-decoration:none;' HREF='javascript:" + closecodeI + "' " +
					"onClick=\"onClickFn('" + ((this.returnData == "Date") ? this.format_data(vDay) : this.format_dow(vDay)) + "');" +
					((this.CallFunction != "") ? (this.WHO + this.CallFunction + "();") : "") +
					closecodeP + "\">";
				linkCloseText = "<\/A>";
				}
			}

			// PMED-200902 09/10/2009
			if (p_env != "/EFL")
				vCode = vCode + "<TD ALIGN='center' WIDTH='14%'" + this.write_weekend_string(j, 0) +
					"><FONT SIZE='2' FACE='" + fontface + "'>" +
					linkText + this.format_day(vDay) + linkCloseText + "</FONT></TD>";
			else
				vCode = vCode + "<TD ALIGN='center' WIDTH='14%' HEIGHT='20'" + this.write_weekend_string(j, 1) +
					"><FONT SIZE='2' FACE='" + fontface + "'>" +
					linkText + this.format_day(vDay) + linkCloseText + "</FONT></TD>";

			vDay = vDay + 1;
			if (vDay > vLastDay) {
				vOnLastDay = 1;
				break;
			}
		}

		if (j == 6)
			vCode = vCode + "</TR>";
		if (vOnLastDay == 1)
			break;
	}

	// Fill up the rest of last week with proper blanks, so that we get proper square blocks
	for (m=1; m<(7-j); m++) {
	  // PMED-200902 09/10/2009
	  if (p_env != "/EFL") {
		if (this.gYearly)
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m, 0) +
				"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>&nbsp;</FONT></TD>";
		else
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m, 0) +
				"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
	  }
	  else
	  {
		if (this.gYearly)
			vCode = vCode + "<TD ALIGN='CENTER' WIDTH='14%' HEIGHT='20'" + this.write_weekend_string(j+m, 1) +
				"><FONT SIZE='2' FACE='" + fontface + "' COLOR='#959595'>&nbsp;</FONT></TD>";
		else
			vCode = vCode + "<TD ALIGN='CENTER' WIDTH='14%' HEIGHT='20'" + this.write_weekend_string(j+m, 1) +
				"><FONT SIZE='2' FACE='" + fontface + "' COLOR='#959595'>" + m + "</FONT></TD>";
	  }
	}

	return vCode;
}

Calendar.prototype.format_day = function(vday) {
	var highDate;
	if (this.gCurrentDate != "NONE")
		highDate = this.gCurrentDate;
	else
		highDate = gNow;

	var vNowDay = highDate.getDate();
	var vNowMonth = highDate.getMonth();
	var vNowYear = highDate.getFullYear();

	if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
			return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
	else
			return (vday);
}

// Return special formatting for the weekend day.
Calendar.prototype.write_weekend_string = function(vday, v_env) {

	if (Calendar.isWeekend(vday))
		// PMED-200902 09/10/2009
		if (v_env != "1")
			return (" BGCOLOR=\"#e0e0e0\"");
		else
			return (" BGCOLOR=\"E8EFF5\"");
	return "";
}

Calendar.prototype.format_data = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vY2 = new String(this.gYear.substr(2,2));
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
	var vDOW = Calendar.get_dow(new Date(vMonth + "/" + vDD + "/" + vY4).getDay());

	switch (this.gFormat) {
			case "MM\/DD\/YYYY" :
				vData = vMonth + "\/" + vDD + "\/" + vY4;
				break;
			case "MM\/DD\/YY" :
				vData = vMonth + "\/" + vDD + "\/" + vY2;
				break;
			case "MM-DD-YYYY" :
				vData = vMonth + "-" + vDD + "-" + vY4;
				break;
			case "MM-DD-YY" :
				vData = vMonth + "-" + vDD + "-" + vY2;
				break;

			case "DD\/MON\/YYYY" :
				vData = vDD + "\/" + vMon + "\/" + vY4;
				break;
			case "DD\/MON\/YY" :
				vData = vDD + "\/" + vMon + "\/" + vY2;
				break;
			case "DD-MON-YYYY" :
				vData = vDD + "-" + vMon + "-" + vY4;
				break;
			case "DD-MON-YY" :
				vData = vDD + "-" + vMon + "-" + vY2;
				break;

			case "DD\/MONTH\/YYYY" :
				vData = vDD + "\/" + vFMon + "\/" + vY4;
				break;
			case "DD\/MONTH\/YY" :
				vData = vDD + "\/" + vFMon + "\/" + vY2;
				break;
			case "DD-MONTH-YYYY" :
				vData = vDD + "-" + vFMon + "-" + vY4;
				break;
			case "DD-MONTH-YY" :
				vData = vDD + "-" + vFMon + "-" + vY2;
				break;
			case "MONTH DD, YYYY" :
				vData = vFMon + " " + vDD + ", " + vY4;
				break;
			case "DD\/MM\/YYYY" :
				vData = vDD + "\/" + vMonth + "\/" + vY4;
				break;
			case "DD\/MM\/YY" :
				vData = vDD + "\/" + vMonth + "\/" + vY2;
				break;
			case "DD-MM-YYYY" :
				vData = vDD + "-" + vMonth + "-" + vY4;
				break;
			case "DD-MM-YY" :
				vData = vDD + "-" + vMonth + "-" + vY2;
				break;
			case "DOW, DD-MON-YY" :
				vData = vDOW + ", " + vDD + "-" + vMon + "-" + vY2;
				break;
			case "YYYY-MM-DD" :
				vData = vY4 + "-" + vMonth + "-" + vDD;
				break;
			default :
				vData = vMonth + "\/" + vDD + "\/" + vY4;
	}

	return vData;
}

Calendar.prototype.format_dow = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;

	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;

	var vDate = new Date(vMonth + "\/" + vDD + "\/" + vY4);
	vData = Calendar.get_dow(vDate.getDay());

	return vData;
}

/*
Calendar Writing Functions
*/
Calendar.prototype.wwrite = function(wtext) {
	if (this.gType == "POPUP")
		this.gWinCal.document.writeln(wtext);
	else {
		// Keep adding to the codeINLINE variable.
		this.codeINLINE += wtext;
	}
}

Calendar.prototype.wwriteA = function(wtext) {
	if (this.gType == "POPUP")
		this.gWinCal.document.write(wtext);
	else {
		// Keep adding to the codeINLINE variable.
		this.codeINLINE += wtext;
	}
}

function Calendar_CreateCalendarLayer(pLeft, pTop, pInitText) {
	/* IMPORTANT :
	If you use relative positioning of this layer, use LAYER Tag for Netscape.
	If you want absolute positioning, use DIV tag for Netscape.
	*/
	if (pInitText == null)
		pInitText = Calendar.gInitText;
	else
		Calendar.gInitText = pInitText;

	v_InlineX = pLeft;
	v_InlineY = pTop;

	var Calendar_ID = "Calendar";

	if (isIE)
		document.writeln("<DIV ID=\"" + Calendar_ID + "\" STYLE=\"" +
		"position:absolute;top:" + pTop + ";left:" + pLeft + ";" +
		"\">" + pInitText + "<\/DIV>");
	else if (isNav)
		document.writeln("<DIV ID=\"" + Calendar_ID + "\" STYLE=\"" +
		"position:absolute;top:" + pTop + ";left:" + pLeft + ";" +
		"\">" + pInitText + "<\/DIV>");
}

function Calendar_Lwwrite(pText, pINLINE) {
	if (isIE) {
		document.all[pINLINE].innerHTML = pText;
	} else if (isNav) {
		var lyr = document.layers[pINLINE].document;
		lyr.open();
		lyr.write(pText);
		lyr.close();
	}
}

function Calendar_MoveTo(pX, pY, pINLINE) {
	if (isIE) {
		document.all[pINLINE].style.top = pY;
		document.all[pINLINE].style.left = pX;
	} else if (isNav) {
		document.layers[pINLINE].top = pY;
		document.layers[pINLINE].left = pX;
	}
}
/* ******************************************************************************* */
/*
Drag-n-Drop Functions
*/
mDown = false;
mUp = false;

function click(e) {
	mUp = false;
	mDown = true;
	if (isIE) {
		// Internet Explorer -
		x = event.clientX;
		y = event.clientY;
		cx = event.clientX - event.offsetX;
		cy = event.clientY - event.offsetY;
	} else if (isNav) {
		// Netscape Navigator -
		x = e.pageX;
		y = e.pageY;
		cx = theLayer.x;
		cy = theLayer.y;
	}
}

function unclick(e) {
	mUp = true;
	mDown = false;
}

function handleMove(e) {
	// Get page co-ords
	if (isIE) {
		// Internet Explorer -
		currX = event.clientX;
		currY = event.clientY;
	} else if (isNav) {
		// Netscape Navigator -
		currX = e.pageX;
		currY = e.pageY;
	}
	// Find out the shift in page co-ords
	incrX = currX - x;
	incrY = currY - y;

	// If it is dragging, move the layer by the same shift..
	if (mDown) {
		// Re-assign the v_Inline? co-ords so that the calendar layer
		// maintains it's new position later.
		v_InlineX = cx + incrX;
		v_InlineY = cy + incrY;

		window.status = "DRAGGGGGG : X=" + v_InlineX + ", Y=" + v_InlineY;
		MoveLayer(v_InlineX, v_InlineY, "myLayer");
	} else
		window.status = "X=" + currX + ", Y=" + currY;
}

function CalResize() {
	// Store these values
	// so that subsequent calendar windows keep the same settings.
	v_Height = ggWinCal.innerHeight;
	v_Width = ggWinCal.innerWidth;
}

function initEvents() {
	if (isNav) {
		theLayer.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE);
	}

	// Assign handlers for mouse activity
	theLayer.onmousemove = handleMove;
	theLayer.onmousedown = click;
	theLayer.onmouseup = unclick;

	if (isIE) window.event.cancelBubble=true;
}

function MoveLayer(pX, pY) {
	theCSSLayer.top = pY;
	theCSSLayer.left = pX;
}

function drag_init(Leyer) {
	if (isIE) {
		theCSSLayer = document.all[Leyer].style;
		theLayer = document.all[Leyer];
	} else if (isNav) {
		theCSSLayer = document.layers[Leyer];
		theLayer = document.layers[Leyer];
	}

	initEvents();
}

/* ******************************************************************************* */
/*
 * Calendar Build Function
 *
 * Modif PMED-200902 ECA 09/10/2009 : add p_env
 */
function Build(p_item, p_month, p_year, p_format, p_type, p_custom) {
	// Read Custom parameters from the custom string here..
	if (p_custom && p_custom != "") {
		// Reset the name/value variables
		// which should not be carried forward to the next calendar..
		v_CurrentDate = "";

		var vvars = name_values(p_custom);
	} else
		v_CurrentDate = "";

	// If the current date is specified,
	// split it & send it to the calendar...
	var vCurrentDate;
	if (v_CurrentDate || v_CurrentDate != "") {
		vCurrentDate = new Date(v_CurrentDate);
		p_month = vCurrentDate.getMonth();
		p_year = vCurrentDate.getFullYear().toString();
	} else
		vCurrentDate = "NONE";

	v_Resizable = (v_Resizable && v_Resizable != "") ? v_Resizable : "No";
	v_SelectAfter = new Date((v_SelectAfter && v_SelectAfter != "") ? v_SelectAfter : "01/01/0001");
	v_SelectBefore = new Date((v_SelectBefore && v_SelectBefore != "") ? v_SelectBefore : "01/01/3000");
	v_NSHierarchy = isNav ?
					((v_NSHierarchy && v_NSHierarchy != "") ? (v_NSHierarchy + ".document.") : "")
					: "";
	v_CallFunction = (v_CallFunction && v_CallFunction != "") ? v_CallFunction : "";

	var vHeight, vWidth;
	if (p_type == "POPUP") {
		vWidth = (v_Width && v_Width != "") ? v_Width : 260;

		if (isIE) vHeight = (v_Height && v_Height != "") ? v_Height : 265;
		else if (isNav) vHeight = (v_Height && v_Height != "") ? v_Height : 250;

		v_PopupX = v_PopupX ? v_PopupX : -1;
		v_PopupY = v_PopupY ? v_PopupY : -1;

		if (v_PopupX >= 0 && v_PopupY >= 0)
		vWinCal = window.open("", "Calendar",
				"width=" + vWidth + ",height=" + vHeight +
				",status=no,resizable=" + v_Resizable +
				",screenX=" + v_PopupX + ",screenY=" + v_PopupY +
				",left=" + v_PopupX + ",top=" + v_PopupY);
		else
		vWinCal = window.open("", "Calendar",
				"width=" + vWidth + ",height=" + vHeight +
				",status=no,resizable=" + v_Resizable);

		vWinCal.opener = self;
		ggWinCal = vWinCal;
		var p_WinCal = ggWinCal;

		if (isNav) ggWinCal.captureEvents(Event.RESIZE);
		ggWinCal.onresize = CalResize;
	}

	gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format, p_type);

	gCal.gCurrentDate = vCurrentDate;
	gCal.gAllowWeekends =
		(v_AllowWeekends && v_AllowWeekends != "" &&
		v_AllowWeekends == "Yes") ? "Yes" : "No";

	// ############ CUSTOMIZE #############
	// Customize your Calendar here..
	gCal.gBGColor="white";
	gCal.gLinkColor="black";
	gCal.gTextColor="black";

	// PMED-200902 09/10/2009
	if (p_env != "/EFL")
		gCal.gHeaderColor="#808080";
	else
		gCal.gHeaderColor="#FFFFFF";

	gCal.closeable = v_CloseOnSelect ?
		((v_CloseOnSelect == "Yes") ? true : false)
		: false;

	gCal.returnMode = v_AppendOrReplace ?
		v_AppendOrReplace : "Replace";

	gCal.returnData = v_ReturnData ?
		v_ReturnData : "Date";

	// Character to be added For Append mode
	gCal.appendChar = (gCal.returnMode == "Append") ?
		v_AppendChar ? v_AppendChar : ";"
		: "";

	gCal.CallFunction = v_CallFunction ? v_CallFunction : "";

	// Position for INLINE Calendar
	// It either comes from the Calendar_CreateCalendarLayer function or
	// from the
	gCal.InlineX = v_InlineX ? v_InlineX : 100;
	gCal.InlineY = v_InlineY ? v_InlineY : 100;

	// Re-position INLINE Calendar now
	if (gCal.gType == "INLINE") {
		Calendar.MoveTo(gCal.InlineX, gCal.InlineY, gCal.INLINE);
	}

	gCal.gTitle = v_Title ? v_Title : gCal.gMonthName + "/" + gCal.gYear;
	// ############ CUSTOMIZE #############

	// Choose appropriate show function
	if (gCal.gYearly)	gCal.showY();
	else	gCal.show();

	if (gCal.gType == "INLINE") {
		// Initialize INLINE Calendar for drag-n-drop functionality
		drag_init(gCal.INLINE);
	}
}

/* ******************************************************************************* */
/*
Monthly Calendar Code Starts here
*/
function show_calendar() {
	/*
		p_item  : Return Item.
		p_month : 0-11 for Jan-Dec; 12 for All Months.
		p_year  : 4-digit year
		p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
		p_type	: POPUP/INLINE Calendar
		p_custom: String of customizable name/value pair parameters
					v_CloseOnSelect
					v_AppendOrReplace
					v_AppendChar
					v_ReturnData
					v_InlineX
					v_InlineY
					v_Title
					v_CurrentDate
					v_AllowWeekends
					v_Height
					v_Width
					v_Resizable
					v_SelectAfter
					v_NSHierarchy	: If the form calling calendar is in a layer
										(reqd only for Netscape)
					v_SelectBefore
					v_CallFunction	: Name of the void function to be called
										after the date is populated
										in the return item
					v_PopupX
					v_PopupY
		p_env	: Environment: EFL or empty (added PMED-200902 09/10/2009)
	*/
	/* Gestion du bloc div */
	//alert(document.layers.length);

	ne = false;
	ie = false;
	ne7 = false;
	if (document.layers) ne = true;
	else if (document.all) ie = true;
	else if (document.getElementById) ne7 = true;

	if (ie || ne7){
		p_item = arguments[0];}
	else{
		if (document.layers.length !=0){
			p_item = "Layer10.document."+arguments[0];
		}
		else{
			p_item = arguments[0];
		}
	}
	//PMED-200902 ECA 09/10/2009 : add arguments[ ] == ""
	if (arguments[1] == "" || arguments[1] == null)
		p_month = new String(gNow.getMonth());
	else
		p_month = (typeof(arguments[1]) == "number") ?
						arguments[1].toString()
						:
						arguments[1];
	if (arguments[2] == "" || arguments[2] == null)
		p_year = new String(gNow.getFullYear().toString());
	else
		p_year = (typeof(arguments[2]) == "number") ?
						arguments[2].toString()
						:
						arguments[2];
	if (arguments[3] == "" || arguments[3] == null)
		p_format = "DD/MM/YYYY";
	else
		p_format = (typeof(arguments[3]) == "string") ?
						arguments[3]
						:
						"DD/MM/YYYY";
	if (arguments[4] == "" || arguments[4] == null)
		p_type = "POPUP";
	else
		p_type = (typeof(arguments[4]) == "string" &&
					(arguments[4] == "POPUP" || arguments[4] == "INLINE")) ?
						arguments[4]
						:
						"POPUP";
	if (arguments[5] == "" || arguments[5] == null)
		p_custom = "CloseOnSelect=Yes;AppendOrReplace=Replace;AppendChar=';';ReturnData=Date;Title=Calendrier;AllowWeekends=Yes;Resizable=No";
	else
		p_custom = typeof(arguments[5]) == "string" ?
					arguments[5]
					:
					"CloseOnSelect=Yes;AppendOrReplace=Replace;AppendChar=';';ReturnData=Date;Title=Calendrier;AllowWeekends=Yes;Resizable=No";

	//debut PMED-200902 09/10/2009
	if (arguments[6] == null)
		p_env = "";
	else
		p_env = typeof(arguments[6]) == "string" ? arguments[6]:"";
	//fin PMED-200902 09/10/2009

	Build(p_item, p_month, p_year, p_format, p_type, p_custom, p_env);
}

/* ******************************************************************************* */
/*
Yearly Calendar Code Starts here
*/
function show_yearly_calendar(p_item, p_year, p_format) {
	// Load the defaults..
	if (p_year == null || p_year == "")
		p_year = new String(gNow.getFullYear().toString());
	else
		p_year = (typeof(p_year) == "number") ?
					p_year.toString()
					:
					p_year;

	if (p_format == null || p_format == "")
			p_format = "DD/MM/YYYY";

	var vWinCal = window.open("", "Calendar", "scrollbars=yes");
	vWinCal.opener = self;
	ggWinCal = vWinCal;

	Build(p_item, null, p_year, p_format);
}
/* *********************************EOF********************************* */
 /*-----------------------------------------------------------------------------------------
fonction 	: GestionDiv
Auteur		: MHX
Date		: 26/03/02
Argument	: nom du formulaire
Return		: retourne "FormLayer"

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function GestionDiv(FormulaireDiv) {
	if (document.all){
		LayerForm = FormulaireDiv;}
	else{
		LayerForm = document.Layer10.FormulaireDiv;
		alert (LayerForm);}
	return LayerForm
}

/*-----------------------------------------------------------------------------------------
fonction 	: RadioCheck
Auteur		: SMN
Date		: 06/03/01
Argument	:
		  - Objet Radio
Return		: Renvoie la valeur si il y a un bouton radio de coché, -1 sinon

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/
function RadioCheck(objRadio) {
	select = -1;

	bRadio = false
	if (objRadio) {
	for (i=0;i<objRadio.length;i++) {

		bRadio = true
	  	if (objRadio[i].checked == true) {
	    	select = i;
	  	}

	}
	//cas 1 seul bouton radio
	if (!bRadio) if (objRadio.checked) select = 1;
		return(select);
	}else{
		return -1;
	}
}

/* *********************************EOF********************************* */
 /*-----------------------------------------------------------------------------------------
fonction 	: Fonction du menu
Auteur		: MHX
Date		: 02/10/03
Argument	:
Return		:

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.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;
}

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];}
}

 /*-----------------------------------------------------------------------------------------
fonction 	: Fonction du menu
Auteur		: EMR
Date		: 18/08/04
Argument	:
Return		:

-------------------------------------------------------------------------------------------
Modifications:
	-  Auteur	Date		Commentaires
-----------------------------------------------------------------------------------------*/

/*
Prend 2 dates en parametre et renvoi la difference en jours entre ces 2 dates
*/
function DateDiff(DateDeb,DateFin) {

    var intervalle = 0;
    var number;
    var bufferRC;
    var bufferDE;
    var tabDeb = DateDeb.split("/");
    var tabFin = DateFin.split("/");

    if (tabDeb[2]<1900) {
		tabDeb[2] = parseInt(tabDeb[2]) + 1900
    }

     if (tabFin[2]<1900) {
		tabFin[2] = parseInt(tabFin[2]) + 1900
    }

    bufferDeb = Date.parse(ReturnMois(tabDeb[1]) + " " + tabDeb[0] + "," +  tabDeb[2] + " GMT") ;
    bufferFin = Date.parse(ReturnMois(tabFin[1]) + " " + tabFin[0] + "," +  tabFin[2] + " GMT") ;

    number = (bufferDeb-bufferFin) ;

    intervalle = parseInt(number / 86400000) ;

    return intervalle ;

}

/*
Renvoi la valeur string d'un mois
Necessaire pour la fonction "parse()"
*/
function ReturnMois(mois) {
	switch(mois) {
		case "01":
			return "Jan";
			break;
		case "1":
			return "Jan";
			break;
		case "02":
			return "Feb";
			break;
		case "2":
			return "Feb";
			break;
		case "03":
			return "Mar";
			break;
		case "3":
			return "Mar";
			break;
		case "04":
			return "Apr";
			break;
		case "4":
			return "Apr";
			break;
		case "05":
			return "May";
			break;
		case "5":
			return "May";
			break;
		case "06":
			return "Jun";
			break;
		case "6":
			return "Jun";
			break;
		case "07":
			return "Jul";
			break;
		case "7":
			return "Jul";
			break;
		case "08":
			return "Aug";
			break;
		case "8":
			return "Aug";
			break;
		case "09":
			return "Sep";
			break;
		case "9":
			return "Sep";
			break;
		case "10":
			return "Oct";
			break;
		case "11":
			return "Nov";
			break;
		case "12":
			return "Dec";
			break;

	}
}

function Compter(Target, max) {
	var bvalue
	var longueurChaine;
	var longueurAajouter;

	longueurAajouter = 0;
	longueurChaine = Target.value.length;
	var caractere;
	for (var i=0;i<longueurChaine;i++) {
		caractere = Target.value.substr(i,1);

		switch (caractere) {
			case "'"://'=&#039;
				longueurAajouter += 5;
				break;
			case "\""://"=&quot;
				longueurAajouter += 5;
				break;
			case ">"://>=&gt;
				longueurAajouter += 3;
				break;
			case "<"://<=&lt;
				longueurAajouter += 3;
				break;
			case "€": //€=euro(s)
				longueurAajouter += 6;
				break;
		}
	}

	longueurChaine += longueurAajouter

	if (longueurChaine > max ) {
		Target.value = Target.value.substring(0,max-longueurAajouter);
		alert("Vous ne pouvez saisir que " + max + " caractères dans ce champ.")
	}
}

//GESTION de La taille limite de chaque champ de formulaire récupéré dans l'objet Request : 102,399 bytes.
//CAS rencontré lors d'un copier / coller dans l'éditeur HTML lors de la saisie d'une annonce en modèle LIBRE
function BreakItUp(objet)
{
  //Set the limit for field size.
  var FormLimit = 102399

  //Get the value of the large input object.
  var TempVar = new String
  TempVar = document.getElementById(objet).value

  if (TempVar.length > FormLimit)
  {
    document.getElementById(objet).value = TempVar.substr(0, FormLimit)
    TempVar = TempVar.substr(FormLimit)

    while (TempVar.length > 0)
    {
      var objTEXTAREA = document.createElement("TEXTAREA")
      objTEXTAREA.name = objet
      objTEXTAREA.value = TempVar.substr(0, FormLimit)
      document.theForm.appendChild(objTEXTAREA)

      TempVar = TempVar.substr(FormLimit)
    }
  }
}


/**
* @name EstSiretValide
* 
* @param 	Le code SIRET dont on veut vérifier la validité.
* 
* @return 	Un booléen qui vaut 'true' si le code SIRET passé en
*                           paramètre est valide, false sinon.
*/
function EstSiretValide(siret) {
  var estValide;
  if ((siret.length != 14) || (isNaN(siret)) )
    estValide = false;
  else {
    // Donc le SIRET est un numérique à 14 chiffres
    // Les 9 premiers chiffres sont ceux du SIREN (ou RCS), les 4 suivants
    // correspondent au numéro d'établissement
    // et enfin le dernier chiffre est une clef de LUHN. 
    var somme = 0;
    var tmp;
    for (var cpt = 0; cpt<siret.length; cpt++) {
      if ((cpt % 2) == 0) { // Les positions impaires : 1er, 3è, 5è, etc... 
        tmp = siret.charAt(cpt) * 2; // On le multiplie par 2
        if (tmp > 9) 
          tmp -= 9;	// Si le résultat est supérieur à 9, on lui soustrait 9
      }
      else
        tmp = siret.charAt(cpt);
      somme += parseInt(tmp);
    }
    if ((somme % 10) == 0)
      estValide = true; // Si la somme est un multiple de 10 alors le SIRET est valide 
    else
      estValide = false;
  }
  return estValide;
}


/* *********************************EOF********************************* */

