function addToFavorites(url, titre) {
	if ( navigator.appName != 'Microsoft Internet Explorer' ){ 
		window.sidebar.addPanel(titre, url, ""); 
	} else { 
		window.external.AddFavorite(url, titre); 
	} 	
}

function add(object)
{
	this.length++;
	this[this.length] = object;
}

function suppr()
{
	this[this.length] =  null;
	this.length--;
	if (this.length<0) this.length=0;
}

function EnTabField()
{
	this.length = 0;
	this.add = add;
	this.suppr = suppr;
	return this;
}

//TheField=Nom du champ obligatoire
//Lib = message associé
//Val = valeur de comparaison
function TabField(TheField,Lib,Val)
{
	this.TheField = TheField;
	this.Lib = Lib;
	this.Val = Val;
	return this;
}

//Cette fonction vérifie si les champs obligatoires du formulaire courant
// figurant dans le tableau tabListe sont non nuls.
function champObligatoire(tabListe)
{
	var   strMsg, theSelected,cpt,TheValue;
		strMsg = "Les champs suivants doivent être renseignés :";
		theSelected=new String();
	for (cpt=1; cpt<=tabListe.length; cpt++)
	{
		TheValue=Trim(window.document.frmMain.item(tabListe[cpt].TheField).value);
		window.document.frmMain.item(tabListe[cpt].TheField).value=TheValue;
		if (window.document.frmMain.item(tabListe[cpt].TheField).value==tabListe[cpt].Val)
		{	strMsg=strMsg + "\n " + tabListe[cpt].Lib ;
			if (theSelected.length==0)
			{
				theSelected = theSelected.concat(tabListe[cpt].TheField);
			}
		}

	}

	if (theSelected.length!=0)
		{
			alert(strMsg );
			window.document.frmMain.item(theSelected.substr(0, theSelected.length)).focus();
			return true;
		}
		else{return false;}

}

//Cette fonction vérifie si les champs du formulaire courant
// figurant dans le tableau tabListe sont nuls
function TestChampNull(tabListe)
{
	var   strMsg, theSelected,cpt,cptField,TheValue;
		strMsg = "Les champs suivants doivent être renseignés :";
		cptField=0;
		theSelected=new String();
	for (cpt=1; cpt<=tabListe.length; cpt++)
	{
		TheValue=Trim(window.document.frmMain.item(tabListe[cpt].TheField).value);
		window.document.frmMain.item(tabListe[cpt].TheField).value=TheValue;
		if (window.document.frmMain.item(tabListe[cpt].TheField).value=="")
		{
			strMsg=strMsg + "\n " + tabListe[cpt].Lib ;
			cptField++;
			if (theSelected.length==0)
				{
					theSelected = theSelected.concat(tabListe[cpt].TheField);
				}
		}

	}

	if ((cptField != tabListe.length)&&(cptField!=0))
		{
			alert(strMsg );
			window.document.frmMain.item(theSelected.substr(0, theSelected.length)).focus();
			return true;
		}
		else{return false;}

}

//Cette fonction teste si les champs du formulaire courant
// figurant dans le tableau tabListe ne sont pas nuls
function TestChampNonNull(tabListe)
{
	var   strMsg, theSelected,cpt,cptField,TheValue;
		strMsg = "Les champs suivants doivent être renseignés :";
		cptField=0;
		theSelected=new String();
	for (cpt=1; cpt<=tabListe.length; cpt++)
	{
		TheValue=Trim(window.document.frmMain.item(tabListe[cpt].TheField).value);
		window.document.frmMain.item(tabListe[cpt].TheField).value=TheValue;
		if (window.document.frmMain.item(tabListe[cpt].TheField).value!="")
		{
			strMsg=strMsg + "\n " + tabListe[cpt].Lib ;
			cptField++;
			if (theSelected.length==0)
				{
					theSelected = theSelected.concat(tabListe[cpt].TheField);
				}
		}

	}

	if ((cptField != tabListe.length)&&(cptField!=0))
		{
			alert(strMsg );
			window.document.frmMain.item(theSelected.substr(0, theSelected.length)).focus();
			return true;
		}
		else{return false;}

}

//Cette fonction supprime les espaces à gauche et à droite d'une chaine de caractère
function Trim(TheValue)
{
	var strValue,strReturn,cptL,cptR;
	strValue=new String();
	strValue = strValue.concat(TheValue);
	cptL=0;
	cptR=strValue.length;
	while(strValue.charAt(cptL)==" ")
	{
		cptL++;
	}
	while(strValue.charAt(cptR)==" ")
	{
		cptR--;
	}
	strReturn = strValue.substr(cptL,cptR);

	return strReturn;
}


/**
 * Vérifie si la valeur paramètre est une date valide
 * (formats j ou jj / m ou mm / aa ou aaaa)
 * si oui : retourne cette date au format jj/mm/aaaa
 * sinon : retourne ''
 */
function sDateValide( sDate ) {
	sDate = Trim(sDate);
	var rDateMotif = /^(\d{1,2})[ \/\|\.-]?(\d{1,2})[ \/\|\.-]?(\d{2,4})$/;
	var aMatch = sDate.match( rDateMotif );
	if ( aMatch == null )
		return '';
	if ( isNaN( Date.parse( aMatch[2]+'/'+aMatch[1]+'/'+aMatch[3] ) ) )
		return '';
	oEnglishDate = new Date(aMatch[2]+'/'+aMatch[1]+'/'+aMatch[3]);
	sDay = '00'+oEnglishDate.getDate();
	sDay = sDay.substr( sDay.length-2 );
	iMonth = oEnglishDate.getMonth()+1;
	sMonth = '00'+iMonth;
	sMonth = sMonth.substr( sMonth.length-2 );
	sYear = '0000'+oEnglishDate.getFullYear();
	sYear = sYear.substr( sYear.length-4 );
	return sDay+'/'+sMonth+'/'+sYear;
}

function ShowOrHideMenu(id2process) {
	if (id2process!="") {
		var obj2process=document.getElementById("CAT"+id2process);
		var objimage=document.getElementById("IMG"+id2process);
		if (obj2process) {
			if (obj2process.style.display=="none") {
				obj2process.style.display="";
				objimage.src="../images/reduire.gif";
			} else {
				obj2process.style.display="none";
				objimage.src="../images/developpe.gif";
			}
		}
	}
}

function showMenu(id2process) {
	if (id2process!="") {
		var obj2process=document.getElementById("CAT"+id2process);
		var objimage=document.getElementById("IMG"+id2process);
		obj2process.style.display="";
		objimage.src="../images/reduire.gif";
	}
}

