/**************************************/
/* Ficher de script regroupant les    */
/* fonctions JS courantes (utilisées  */
/* par toutes les pages)              */
/**************************************/

/*******************************************/
/*                                         */
/*              ajax.js                    */
/*                                         */
/*******************************************/
function processAjaxScripts( data )
{
	var start = data.toUpperCase().indexOf("<SCRIPT>");
	var stop = data.indexOf( "</" );
	
	if (start>=0 && stop> start)
	{
		var evalStr = strTrim( data.substr( start+8, stop-start-8 ) );
		eval( evalStr );
		return true;
	}
	return false;
}
function strTrim(s) 
{
    return s.replace(/^\s+/, '').replace(/\s+$/, '');
}

/*******************************************/
/*                                         */
/*              navigateur.js              */
/*                                         */
/*******************************************/
var ns4=(document.layers)?true:false;//NS 4
var ie4=(document.all)?true:false;//IE 4
var dom=(document.getElementById)?true:false;//DOM
var imageFermerBloc="";
var imageOuvrirBloc="";

function setImageFermerBloc(strImageFermerBloc)
{
	imageFermerBloc=strImageFermerBloc;
}
function setImageOuvrirBloc(strImageOuvrirBloc)
{
	imageOuvrirBloc=strImageOuvrirBloc;
}

/**
 * Par rapport à l'utilisation faite de cette fonction, le comportement à implémenter est le suivant :
 * - Si le paramètre correspond au nom d'une zone de formulaire, la fonction retourne cet élément de formulaire
 * - Si le paramètre correspond au nom d'une zone multiple de formulaire (radio, multibox), la fonction retourne 
 * un tableau contenant tous les éléments correspondant
 * - Si la paramètre correspond au nom d'un conteneur HTML (TD, DIV, SPAN... avec un attribut ID égal au paramètre), 
 * la fonction retourne cet élément HTML.
 * L'ordre dans lequel les fonctions de l'objet document sont testées doit garantir le type de retour décrit ci dessus...
 **/
function getElementFromDocument(elementName)
{
	var result;
	// On va éviter d'utiliser document.all en premier, ce n'est pas vraiment le plus performant. En plus cette fonction 
	// peut être problématique avec certaines versions de firefox je pense (implémentée, mais la syntaxe 
	// document.all[elementName] n'est pas valide).
	// On va utiliser en priorité getElementsByName, reconnu au moins par IE6 et Firefox. 
	if (document.getElementsByName)
	{
		// Remarques sur cette fonction :
		// - Elle retourne systématiquement un tableau d'éléments (c'est la norme !), donc si le tableau contient un seul 
		// élément on le retourne directement. Si le tableau contient plusieurs éléments, on retourne le tableau entier.
		// - Différence de comportement entre IE et Firefox : sous IE on peut retrouver également un DIV ou un autre conteneur 
		// HTML dont l'attribut ID est égal à elementName. Sous Firefox, ce n'est pas le cas (respect strict de la norme)
		var tmp = document.getElementsByName(elementName);
		if (tmp && tmp.length)
		{
			if (tmp.length==1)
			{
				result = tmp[0];
			}
			else
			{
				result = tmp;
			}
		}
	}
	// On entre dans le bloc suivant uniquement si on n'a rien trouvé avec le code ci dessus !
	if (!result)
	{
		if(document.getElementById) // Standard W3C, supporté par IE6, Firefox, Mozilla, NS6+... 
		{
			result = document.getElementById(elementName);
		}
		else if(document.layers)// Netscape 4.x
		{
			result = document.layers[elementName];
		}
		else if(document.all)// IE 4.x, 5.x
		{
			result = document.all[elementName];
		}
	}
	return result;
}

function getElementFromForm(form,elementName)
{
	if(document.layers)// Netscape 4.x
	{
		return form.elements(elementName);
	}
	else if(document.all)// IE 4.x, 5.x
	{
		return form.elements(elementName);
	}
	else if(document.getElementById)
	{
		return form.elements[elementName];
	}
	return null;
}

function getForm(formName)
{
	if(document.layers)// Netscape 4.x
	{
		return document.forms(formName);
	}
	else if(document.all)// IE 4.x, 5.x
	{
		return document.forms(formName);
	}
	else if(document.getElementById)
	{
		return document.forms[formName];
	}
	return null;
}

function getTopWindowLeftPosition()
{
	return top.screenLeft;
}
	
function getWindowLeftPosition(currentWindow)
{
	var version = parseInt(navigator.appVersion);
	// Il faut bien utiliser currentWindow.screenX pour firefox
	var ns=((navigator.appName=="Netscape")&&(version>=4));
	if(ns)
	{
		return currentWindow.screenX;
	}
	else if(document.getElementById)
	{
		return currentWindow.screenLeft;
	}
	else if(document.all)
	{
		return currentWindow.screenLeft;
	}
	else if(document.layers)
	{
		return currentWindow.pageXOffset;
	}
	else
	{
		return currentWindow.screenLeft;
	}
}

function getWindowTopPosition(currentWindow)
{
	var version = parseInt(navigator.appVersion);
	// Il faut bien utiliser currentWindow.screenY pour firefox
	var ns=((navigator.appName=="Netscape")&&(version>=4));
	if(ns)
	{
		return currentWindow.screenY;
	}
	else if(document.getElementById)
	{
		return currentWindow.screenTop;
	}
	else if(document.all)
	{
		return currentWindow.screenTop;
	}
	else if(document.layers)
	{
		return currentWindow.pageYOffset;
	}
	else
	{
		return currentWindow.screenTop;
	}
}

function setPixelTopOnObjectStyle(styleObjet,nouvellePosition)
{
	if(styleObjet.pixelTop)
	{
		styleObjet.pixelTop=nouvellePosition;
	}
	else
	{
		styleObjet.top=nouvellePosition+"px";
	}
}

function getPixelTopOfObjectStyle(styleObjet)
{
	if(styleObjet.pixelTop)
	{
		return styleObjet.pixelTop;
	}
	else
	{
		return parseInt(styleObjet.top);
	}
}

/******************************************************
Cette fonction permet d'obtenir la largeur de la fenêtre. 
On ne tient en compte que la partie affichage de la page 
HTML. On ne tient pas compte du menu ou de la barre d'état 
de la fenêtre.
*******************************************************/
function getWindowWidth(currentWindow)
{
	var version = parseInt(navigator.appVersion);
	var nav4=((navigator.appName=="Netscape")&&(version>=4)&&(version<5));
	if(nav4)
		return currentWindow.outerWidth;
	else if(currentWindow.innerWidth)
		return currentWindow.innerWidth;
	else
		return currentWindow.document.body.clientWidth;
}

/******************************************************
Cette fonction permet d'obtenir la hauteur de la fenêtre. 
On ne tient en compte que la partie affichage de la page 
HTML. On ne tient pas compte du menu ou de la barre d'état 
de la fenêtre.
*******************************************************/
function getWindowHeight(currentWindow)
{

	var version = parseInt(navigator.appVersion);
	var nav4=((navigator.appName=="Netscape")&&(version>=4)&&(version<5));
	if(nav4)
		return currentWindow.outerHeight;
	else if(currentWindow.innerHeight)
		return currentWindow.innerHeight;
	else
		return currentWindow.document.body.clientHeight;
}

function hideIt(element)
{
	if(element) element.style.display='none';
}
function showIt(element)
{
	if(element)element.style.display='InLine';
}
function hideElement(nomElement)
{
	hideIt(getElementFromDocument(nomElement));
}
function showElement(nomElement)
{
	showIt(getElementFromDocument(nomElement));
}
function showHideElement(element,nomImage)
{
	var image=nomImage;
	if (element.style.display=='none')
	{
		showIt(element);
		getElementFromDocument(image).src=imageFermerBloc;
	}
	else
	{
		hideIt(element);
		getElementFromDocument(image).src=imageOuvrirBloc;
	}
}
function isItHidden(element)
{
	if(element)
		return (element.style.display=='none');
	else
		return true;
}
function isItShown(element)
{
	if(element)
		return (element.style.display=='InLine');
	else
		return false;
}
function isHidden(nomElement)
{
	isItHidden(getElementFromDocument(nomElement));
}
function isShown(nomElement)
{
	isItShown(getElementFromDocument(nomElement));
}

function setItVisible(element)
{
	if(element) element.style.visibility="visible";
}
function setItInvisible(element)
{
	if(element) element.style.visibility="hidden";
}
function setVisible(nomElement)
{
	setItVisible(getElementFromDocument(nomElement));
}
function setInvisible(nomElement)
{
	setItInvisible(getElementFromDocument(nomElement));
}

function isItVisible(element)
{
	if(element)
		return (element.style.visibility=="visible");
	else
		return false;
}
function isItInvisible(element)
{
	if(element)
		return (element.style.visibility=="hidden");
	else
		return true;
}
function isVisible(nomElement)
{
	isItVisible(getElementFromDocument(nomElement));
}
function isItInvisible(nomElement)
{
	isItInvisible(getElementFromDocument(nomElement));
}
/*******************************************/
/*                                         */
/*             info-bulle.js               */
/*                                         */
/*******************************************/
var sknLeft=0;
var sknTop=0;
var browser=navigator.appName;

var nava=(document.layers);
var iex=(document.all);

var layerInfoBullesObject;
var skn;
var frameInfoBullesObject;
var sknFrame;

if(browser=="Netscape")
	document.captureEvents(Event.MOUSEMOVE);

document.onmousemove=get_mouse;

function initInfoBulle()
{
	layerInfoBullesObject=getElementFromDocument("layerInfoBulles");
	skn=layerInfoBullesObject.style;
	frameInfoBullesObject=getElementFromDocument("frameInfoBulles");
	if(frameInfoBullesObject) sknFrame=frameInfoBullesObject.style;
}

function afficheInfoBulle(msg)
{
	if(skn)
	{
		if(skn.visibility!="visible")
		{
			if((msg)&&(msg!=""))
			{
				if(layerInfoBullesObject)
				{
					// tables imbriquées pour simuler une bordure fine
					var content="<table class=\"zoneInfoBulle\"><tr><td>";
					content+=""+msg+"</td></tr></table>";
					layerInfoBullesObject.innerHTML=content;
				}
				// on compte le nombre de lignes du message
				// pour être sur d'avoir toue l'info-bulle
				// visible
				var splitArray=msg.split("<br>");
				var nbLignes=splitArray.length;
				for(var i=0;i<splitArray.length;i++)
				{
					var ligneI=splitArray[i];
					var nbSousLignes=parseInt(ligneI.length/(56));
					nbLignes+=nbSousLignes;
				}
				var heightMsg=nbLignes*15;
				var heightWindow=getWindowHeight(top);
				var widthWindow=getWindowWidth(top);
				
				skn.left=sknLeft;
				skn.top=sknTop;
				if((heightWindow-sknTop)<heightMsg)
				{
					skn.top = heightWindow - heightMsg;
					if (skn.top<0)
					{
						skn.top=0
					}
					
				}
				if((widthWindow-sknLeft)<300)
				{
					skn.left = widthWindow - 300;
					if (skn.left<0)
					{
						skn.left=0
					}
				}
				
				skn.visibility="visible";
				if(sknFrame)
				{
					sknFrame.top=skn.top;
					sknFrame.left=skn.left;
					sknFrame.width=layerInfoBullesObject.offsetWidth;
				    sknFrame.height=layerInfoBullesObject.offsetHeight;
					sknFrame.visibility="visible";
			}
		}
	}
}
}

function get_mouse(e)
{
	sknLeft=(browser=="Netscape")?e.pageX:event.x+document.body.scrollLeft;
	sknTop=(browser=="Netscape")?e.pageY:event.y+document.body.scrollTop;	
}

function masqueInfoBulle()
{
	if(skn)
	{
		if(skn.visibility=="visible")
		{
			if(layerInfoBullesObject) layerInfoBullesObject.innerHTML="";
			skn.left=0;
			skn.top=0;
			skn.visibility="hidden";
			if(sknFrame)
			{
				sknFrame.left=0;
				sknFrame.top=0;
				sknFrame.visibility="hidden";
		}
	}
}
}
/*******************************************/
/*                                         */
/*             evenement.js                */
/*                                         */
/*******************************************/
function getEvt(e)
{
	if(!e)
	{
		return window.event;
	}
	else
	{
		return e;
	}
}

function getSourceEvent(e)
{
	if(window.Event)
	{
		return e.target;// Netscape
	}
	else
	{
		return event.srcElement;// Internet Explorer
	}
}

function getEventMouseButton(e)
{
	return getEvt(e).button;
}

function getEventYPosition(e)
{
	if(window.Event)
	{
		return e.pageY;// Netscape
	}
	else
	{
		return event.clientY;// Internet Explorer
	}
}

function getEventXPosition(e)
{
	if(window.Event)
	{
		return e.pageX;// Netscape
	}
	else
	{
		return event.clientX;// Internet Explorer
	}
}

function getMouseButtonLeft()
{
	if(window.Event)
	{
		return 0;// Netscape
	}
	else
	{
		return 1;// Internet Explorer
	}
}
/*******************************************/
/*                                         */
/*          affichage-popups.js            */
/*                                         */
/*******************************************/
//////////////////////////////////////////////////////////////////
// Gestion de l'affichage des popup modales
//////////////////////////////////////////////////////////////////
var winPopupWindow;
var windowAppelante;

// Variables utilisees pour les popups des popups
// Sinon la deuxieme popup remplace la premiere (sous Netscape)
var winPopupWindowOfPopup;
var windowAppelanteOfPopup;

//Variable de la popup d'éditique
var parametresServletEditique;
var urlServletEditique;

function setParametresServletEditique(parametresServletEditiqueParam)
{
	parametresServletEditique=parametresServletEditiqueParam;
}
function setUrlServletEditique(urlServletEditiqueParam)
{
	urlServletEditique=urlServletEditiqueParam;
}

function blockEvents()
{
	if(windowAppelante)
	{
		windowAppelante.captureEvents(Event.CLICK|Event.MOUSEDOWN|Event.MOUSEUP|Event.FOCUS);
		windowAppelante.onclick=deadend;
		windowAppelante.onfocus=checkModal;
	}
}

// As dialog closes, restore the main window's original event mechanisms.
function unblockEvents()
{
	if(windowAppelante)
	{
		windowAppelante.releaseEvents(Event.CLICK|Event.MOUSEDOWN|Event.MOUSEUP|Event.FOCUS);
		windowAppelante.onclick=null;
		windowAppelante.onfocus=null;
	}
}

// Event handler to inhibit Navigator form element and Internet Explorer
// link activity when dialog window is active.
function deadend()
{
	if(winPopupWindow && !winPopupWindow.closed)
	{
		winPopupWindow.focus();
		return false;
	}
}

function checkModal()
{
	if(winPopupWindow && !winPopupWindow.closed)
	{
		winPopupWindow.focus();
	}
}

function afficherPopupCentree(url,callerWindow,popupWidth,popupHeight,popupScroll,popupResizable)
{
	windowAppelante=callerWindow;
	
	var heightWindow=getWindowHeight(top);
	var widthWindow=getWindowWidth(top);

	var topWindow=getWindowTopPosition(top);
	var leftWindow=getWindowLeftPosition(top);

	var topPopup=topWindow+(heightWindow-popupHeight)/2;
	var leftPopup=leftWindow+(widthWindow-popupWidth)/2;

	if(!popupScroll) popupScroll="No";
	if(!popupResizable) popupResizable="No";

	if(windowAppelante.showModalDialog)
	{
		var resultat=windowAppelante.showModalDialog(url,windowAppelante,"help:0;toolbar:0;location:0;directories:0;status:0;scroll:"+popupScroll+";resizable:"+popupResizable+";dialogWidth:"+popupWidth+"px;dialogHeight:"+popupHeight+"px;dialogLeft:"+leftPopup+";dialogTop:"+topPopup);
		return resultat;
	}
	else
	{
		winPopupWindow=windowAppelante.open(url,"","toolbar=0,location=0,directories=0,modal=yes,menuBar=0,scrollbars="+popupScroll+",resizable="+popupResizable+",width="+popupWidth+",height="+popupHeight+",left="+leftPopup+",top="+topPopup);
		winPopupWindow.focus();
		return null;
	}
}

function afficherPopupCentreeEnLargeur(url,callerWindow,popupWidth,popupHeight,popupScroll,popupResizable,topPopup)
{
	windowAppelante=callerWindow;

	var widthWindow=getWindowWidth(top);
	var leftWindow=getWindowLeftPosition(top);
	var leftPopup=leftWindow+(widthWindow-popupWidth)/2;

	if(!popupScroll) popupScroll="No";
	if(!popupResizable) popupResizable="No";

	if(windowAppelante.showModalDialog)
	{
		var resultat=windowAppelante.showModalDialog(url,windowAppelante,"help:0;toolbar:0;location:0;directories:0;status:0;scroll:"+popupScroll+";resizable:"+popupResizable+";dialogWidth:"+popupWidth+"px;dialogHeight:"+popupHeight+"px;dialogLeft:"+leftPopup+";dialogTop:"+topPopup);
		return resultat;
	}
	else
	{
		winPopupWindow=windowAppelante.open(url,"","toolbar=0,location=0,directories=0,menuBar=0,scrollbars="+popupScroll+",resizable="+popupResizable+",width="+popupWidth+",height="+popupHeight+",left="+leftPopup+",top="+topPopup);
		winPopupWindow.focus();
		return null;
	}
}

function afficherPopupNonModaleCentree(url,callerWindow,popupWidth,popupHeight,popupScroll,popupResizable)
{
	windowAppelante=callerWindow;

	var heightWindow=getWindowHeight(top);
	var widthWindow=getWindowWidth(top);

	var topWindow=getWindowTopPosition(top);
	var leftWindow=getWindowLeftPosition(top);

	var topPopup=topWindow+(heightWindow-popupHeight)/2;
	var leftPopup=leftWindow+(widthWindow-popupWidth)/2;

	if(!popupScroll) popupScroll="No";
	if(!popupResizable) popupResizable="No";

	windowAppelante.open(url,"","toolbar=0,location=0,directories=0,menuBar=0,scrollbars="+popupScroll+",resizable="+popupResizable+",width="+popupWidth+",height="+popupHeight+",left="+leftPopup+",top="+topPopup);
	return null;
}

function afficherPopupNonModaleCentreeEnLargeur(url,callerWindow,popupWidth,popupHeight,popupScroll,popupResizable,topPopup)
{
	windowAppelante=callerWindow;

	var widthWindow=getWindowWidth(top);
	var leftWindow=getWindowLeftPosition(top);
	var leftPopup=leftWindow+(widthWindow-popupWidth)/2;

	if(!popupScroll) popupScroll="No";
	if(!popupResizable) popupResizable="No";

	windowAppelante.open(url,"","toolbar=0,location=0,directories=0,menuBar=0,scrollbars="+popupScroll+",resizable="+popupResizable+",width="+popupWidth+",height="+popupHeight+",left="+leftPopup+",top="+topPopup);
	return null;
}

var urlServletSupportPresentation;
function setUrlServletSupportPresentation(urlServletSupportPresentationParam){urlServletSupportPresentation=urlServletSupportPresentationParam;}
function afficherSupportPresentation(nomFiche)
{
	afficherSupportPresentationSelonMode(nomFiche,false);
}
function afficherSupportPresentationPleinEcran(nomFiche)
{
	afficherSupportPresentationSelonMode(nomFiche,true);
}
function afficherSupportPresentationSelonMode(nomFiche,modePleinEcran)
{
 	var windowHeight=Math.min(screen.availHeight,600);
	var windowWidth=Math.min(screen.availWidth,800);
  	var leftWindow=(screen.availHeight-600)/2;
  	var topWindow=(screen.availWidth-800)/2;
	if(modePleinEcran)
	{
		if(self.screen)// for NN4 and IE4
		{
			windowWidth=screen.width-5; // 5=>décalage pour la scroll barre
			windowHeight=screen.height*0.95; //0.95=> décalage pour la barre de tâches
			topWindow=0;
			leftWindow=screen.width-windowWidth-5; // 5=>décalage pour la scroll barre
		}
		else
		{
			topWindow=0;
			leftWindow=500;
		}
	}
	var options='width='+windowWidth+',height='+windowHeight+',status=no,scrollbars=yes,resizable=yes,top='+topWindow+',left='+leftWindow;
	fenetreAide=window.open(urlServletSupportPresentation+escape(nomFiche),'',options);
}

function ouvrePDFSimulation(simulationId)
{
	var paramCompletsServletEditique=parametresServletEditique+"&displayPdf=true&type=.pdf";
	var urlServletEditiqueComplete=urlServletEditique+"?"+"simulationId="+simulationId+"&"+paramCompletsServletEditique;
	window.open(urlServletEditiqueComplete,"Edition","height=600,width=420,status=no,toolbar=no,menubar=no,location=no,resizable=yes");
}
/*******************************************/
/*                                         */
/*          affichage-messages.js          */
/*                                         */
/*******************************************/
//////////////////////////////////////////////////////////////////
// Gestion des messages d'erreurs
//////////////////////////////////////////////////////////////////
var messageErreur="";
var messageErreurNB="";// Message qui s'affiche en bas de la fenetre
var messageNote="";
var messageNoteNB="";// Message qui s'affiche en bas de la fenetre
var messageConfirmation="";
var messageConfirmationNB="";// Message qui s'affiche en bas de la fenetre

var fonction="";

// Objet window sur lequel on doit afficher la popup 
var objectWindow;

var urlPopupErreur;
var urlPopupNote;
var urlPopupInfo;
var urlPopupConfirmation;
var urlPopupConfirmationAnnulable;

function setURLPopupErreur(newURL)
{
	urlPopupErreur=newURL;
}

function setURLPopupNote(newURL)
{
	urlPopupNote=newURL;
}

function setURLPopupInfo(newURL)
{
	urlPopupInfo=newURL;
}

function setURLPopupConfirmation(newURL)
{
	urlPopupConfirmation=newURL;
}

function setURLPopupConfirmationAnnulable(newURL)
{
	urlPopupConfirmationAnnulable=newURL;
}

function setWindowObject(windowElement)
{
	if(windowElement)
		objectWindow=windowElement;
	if(!objectWindow)
	{
		if(window.parent)
			objectWindow=window.parent;
		else
			objectWindow=window;
	}
}

function afficherNote(windowElement)
{
	afficherNoteOuInfo(urlPopupNote,windowElement);
}
function afficherInfo(windowElement)
{
	afficherNoteOuInfo(urlPopupInfo,windowElement);
}
function afficherNoteOuInfo(urlPopupNoteOuInfo,windowElement)
{
	setWindowObject(windowElement);

	var splitArray=messageNote.split("<br>");
	var nbLignes=splitArray.length;
	// Attention aux lignes qui prennent plus qu'une ligne dans la popup
	for(var i=0;i<splitArray.length;i++)
	{
		var ligneI=splitArray[i];
		var nbSousLignes=parseInt(ligneI.length/(50));
		nbLignes+=nbSousLignes;
	}

	// NB:
	if(messageNoteNB)
	{
		var splitNBArray=messageNoteNB.split("<br>");
		// Attention aux lignes qui prennent plus qu'une ligne dans la popup
		for(var i=0;i<splitNBArray.length;i++)
		{
			var ligneI=splitNBArray[i];
			var nbSousLignes=parseInt(ligneI.length/(50));
			nbLignes+=nbSousLignes;
		}
	}

	var heightPopup=nbLignes*15;
	heightPopup+=200;

	var scroll=0;
	if(heightPopup>600)
	{
		heightPopup=600;
		scroll=1;
	}
	else if(heightPopup<300)
	{
		heightPopup=300;
	}
	
	var widthPopup=300;

	var url;
	var today=new Date();
	if(messageNoteNB)
	{
		url=urlPopupNoteOuInfo+"?date="+escape(today)+"&message="+escape(messageNote)+"&messageNB="+escape(messageNoteNB);
	}
	else
	{
		url=urlPopupNoteOuInfo+"?date="+escape(today)+"&message="+escape(messageNote);
	}
	afficherPopupCentree(url,objectWindow,widthPopup,heightPopup,scroll,1);
}

function afficherErreur(windowElement)
{
	setWindowObject(windowElement);

	var splitArray=messageErreur.split("<br>");
	var nbLignes=splitArray.length;
	// Attention aux lignes qui prennent plus qu'une ligne dans la popup
	for(var i=0;i<splitArray.length;i++)
	{
		var ligneI=splitArray[i];
		var nbSousLignes=parseInt(ligneI.length/(50));
		nbLignes+=nbSousLignes;
	}

	// NB:
	if(messageErreurNB)
	{
		var splitNBArray=messageErreurNB.split("<br>");
		// Attention aux lignes qui prennent plus qu'une ligne dans la popup
		for(var i=0;i<splitNBArray.length;i++)
		{
			var ligneI=splitNBArray[i];
			var nbSousLignes=parseInt(ligneI.length/(50));
			nbLignes+=nbSousLignes;
		}
	}

	var heightPopup=nbLignes*15;
	heightPopup+=200;

	var scroll=0;
	if(heightPopup>600)
	{
		heightPopup=600;
		scroll=1;
	}
	else if(heightPopup<300)
	{
		heightPopup=300;
	}
	var widthPopup=300;

	var url;
	var today=new Date();
	if(messageErreurNB)
	{
		url=urlPopupErreur+"?date="+escape(today)+"&message="+escape(messageErreur)+"&messageNB="+escape(messageErreurNB);
	}
	else
	{
		url=urlPopupErreur+"?date="+escape(today)+"&message="+escape(messageErreur);
	}
	if(url.length>2083)//Max IE
	{
		var nbCarASupprimer=url.length-2000;// pour rajouter le <br>...
		var messageErreurEscape=escape(messageErreur);
		if(messageErreurEscape.length>nbCarASupprimer)
		{
			messageErreurEscape=messageErreurEscape.substring(0,messageErreurEscape.length-nbCarASupprimer);
			//De plus, on coupe au dernier <br> pour ne pas avoir d'erreur JS
			var indexBR=messageErreurEscape.lastIndexOf("%3Cbr%3E");
			if(indexBR!=-1) messageErreurEscape=messageErreurEscape.substring(0,indexBR)+"%3Cbr%3E...";
		}
		if(messageErreurNB)
		{
			url=urlPopupErreur+"?date="+escape(today)+"&message="+messageErreurEscape+"&messageNB="+escape(messageErreurNB);
		}
		else
		{
			url=urlPopupErreur+"?date="+escape(today)+"&message="+messageErreurEscape;
		}
	}
	afficherPopupCentree(url,objectWindow,widthPopup,heightPopup,scroll,1);
}

function afficherConfirmation(windowElement)
{
	setWindowObject(windowElement);

	var splitArray=messageConfirmation.split("<br>");
	var nbLignes=splitArray.length;
	// Attention aux lignes qui prennent plus qu'une ligne dans la popup
	for(var i=0;i<splitArray.length;i++)
	{
		var ligneI=splitArray[i];
		var nbSousLignes=parseInt(ligneI.length/(50));
		nbLignes+=nbSousLignes;
	}

	// NB:
	if(messageConfirmationNB)
	{
		var splitNBArray=messageConfirmationNB.split("<br>");
		// Attention aux lignes qui prennent plus qu'une ligne dans la popup
		for(var i=0;i<splitNBArray.length;i++)
		{
			var ligneI=splitNBArray[i];
			var nbSousLignes=parseInt(ligneI.length/(50));
			nbLignes+=nbSousLignes;
		}
	}

	var heightPopup=nbLignes*15;
	heightPopup+=200;

	var scroll=0;
	if(heightPopup>600)
	{
		heightPopup=600;
		scroll=1;
	}
	else if(heightPopup<300)
	{
		heightPopup=300;
	}
	var widthPopup=300;

	var url;
	var today=new Date();
	if(messageConfirmationNB)
	{
		url=urlPopupConfirmation+"?date="+escape(today)+"&message="+escape(messageConfirmation)+"&messageNB="+escape(messageConfirmationNB);
	}
	else
	{
		url=urlPopupConfirmation+"?date="+escape(today)+"&message="+escape(messageConfirmation);
	}

	var resultatConfirmation=afficherPopupCentree(url,objectWindow,widthPopup,heightPopup,scroll,1);

	// IE
	if((resultatConfirmation)&&(resultatConfirmation!=null))
	{
		return traitementConfirmation(resultatConfirmation);
	}
	else
	{
		return false;
	}
}


function afficherConfirmationAnnulable(windowElement)
{
	setWindowObject(windowElement);

	var splitArray=messageConfirmation.split("<br>");
	var nbLignes=splitArray.length;
	// Attention aux lignes qui prennent plus qu'une ligne dans la popup
	for(var i=0;i<splitArray.length;i++)
	{
		var ligneI=splitArray[i];
		var nbSousLignes=parseInt(ligneI.length/(50));
		nbLignes+=nbSousLignes;
	}

	// NB:
	if(messageConfirmationNB)
	{
		var splitNBArray=messageConfirmationNB.split("<br>");
		// Attention aux lignes qui prennent plus qu'une ligne dans la popup
		for(var i=0;i<splitNBArray.length;i++)
		{
			var ligneI=splitNBArray[i];
			var nbSousLignes=parseInt(ligneI.length/(50));
			nbLignes+=nbSousLignes;
		}
	}

	var heightPopup=nbLignes*15;
	heightPopup+=200;

	var scroll=0;
	if(heightPopup>600)
	{
		heightPopup=600;
		scroll=1;
	}
	else if(heightPopup<300)
	{
		heightPopup=300;
	}
	var widthPopup=300;

	var url;
	var today=new Date();
	if(messageConfirmationNB)
	{
		url=urlPopupConfirmationAnnulable+"?date="+escape(today)+"&message="+escape(messageConfirmation)+"&messageNB="+escape(messageConfirmationNB);
	}
	else
	{
		url=urlPopupConfirmationAnnulable+"?date="+escape(today)+"&message="+escape(messageConfirmation);
	}

	var resultatConfirmationAnnulable=afficherPopupCentree(url,objectWindow,widthPopup,heightPopup,scroll,1);

	// IE
	if((resultatConfirmationAnnulable)&&(resultatConfirmationAnnulable!=null))
	{
		return traitementConfirmationAnnulable(resultatConfirmationAnnulable);
	}
	else
	{
		return -1;//Click sur la croix
	}
}

// Traitement a effectuer en retour de l'affichage d'une popup de confirmation:
// Si confirmation vaut "oui", on effectue la fonction demandee.
// Sinon rien ne se passe
function traitementConfirmation(confirmation)
{
	if((confirmation=="oui")||(confirmation=="non"))
	{
		if(confirmation=="oui")
		{
			eval(fonction);
			return true;
		}
		else
		{
			fonction="";
			return false;
		}
	}
	else
	{
		return false;
	}
}

// Traitement a effectuer en retour de l'affichage d'une popup de confirmation annulable:
// Si confirmation vaut "oui", on effectue la fonction demandee.
// Sinon rien ne se passe
function traitementConfirmationAnnulable(confirmation)
{
	if((confirmation=="oui")||(confirmation=="non"))
	{
		if(confirmation=="oui")
		{
			eval(fonction);
			return 1;
		}
		else
		{
			fonction="";
			return 0;
		}
	}
	else
	{
		return -1;
	}
}

function afficherAlerte(type,message,windowElement,notaBene)
{
	if((type=="erreur")||(type=="missingData"))
	{
		if(message!="")
			messageErreur=message;
		if(notaBene)
			messageErreurNB=notaBene;
		afficherErreur(windowElement);
	}
	else if(type=="note")
	{
		if(message!="")
			messageNote=message;
		if(notaBene)
			messageNoteNB=notaBene;
		afficherNote(windowElement);
	}
	else if(type=="info")
	{
		if(message!="")
			messageNote=message;
		if(notaBene)
			messageNoteNB=notaBene;
		afficherInfo(windowElement);
	}
	else if(type=="confirmation")
	{
		if(message!="")
			messageConfirmation=message;
		if(notaBene)
			messageConfirmationNB=notaBene;
		return afficherConfirmation(windowElement);
	}
	else if(type=="confirmationAnnulable")
	{
		if(message!="")
			messageConfirmation=message;
		if(notaBene)
			messageConfirmationNB=notaBene;
		return afficherConfirmationAnnulable(windowElement);
	}
}

function confirmationOuiNon(messageConfirmation,actionOui,actionNon)
{
	fonction=actionOui;
	if(!afficherAlerte("confirmation",messageConfirmation))
	{
		eval(actionNon);
	}
}

function confirmationOuiNonAnnuler(messageConfirmation,actionOui,actionNon)
{
	fonction=actionOui;
	if(afficherAlerte("confirmationAnnulable",messageConfirmation)==0)
	{
		eval(actionNon);
	}
}
/*******************************************/
/*                                         */
/*          formatage-nombres.js           */
/*                                         */
/*******************************************/
/////////////////
// Remove spaces
/////////////////
function trim(data)
{
	data=data.replace(/\s/g,"");
	data=data.replace(" ","");
	data=unescape(escape(data).replace("%A0",""));
	return data;
}

// mapping avec le formattage automatique
function formatCurrency(data)
{
	return decimalCurrencyFormat(data.value);
}
function formatCurrencyPositive(data)
{
	var value = data.value;
	value=numberFormatPositive(value);
	return decimalCurrencyFormat(value);
}


function formatCurrencyRound(data)
{
	return currencyFormat(data.value);
}
function formatCurrencyRoundPositive(data)
{
	return currencyFormatPositive(data.value);
}
function formatShortRate(data)
{
	return decimalFormatRate(data.value,2);
}
function formatShortRatePositive(data)
{
	var value = data.value;
	value=numberFormatPositive(value);
	return decimalFormatRate(value,2);
}
function formatMiddleRate(data)
{
	return decimalFormatRate(data.value,4);
}
function formatLongRate(data)
{
	return decimalFormatRate(data.value,5);
}
function formatNumeric(data)
{
	var dataFormattee=numberFormat(data.value);
	if(dataFormattee.indexOf(".")>0)
		dataFormattee=dataFormattee.substring(0,dataFormattee.indexOf("."));
	if(dataFormattee.indexOf(",")>0)
		dataFormattee=dataFormattee.substring(0,dataFormattee.indexOf(","));
	return dataFormattee;
}
function formatPercentage(data)
{
	return roundPercentageFormat(data);
}
function formatRate(data)
{
	return decimalFormatRate(data.value,3);
}
function formatTime(data)
{
	return formatDate(data);
}
function formatDate(fieldObject)
{
	if(fieldObject==null||fieldObject.value==""||fieldObject.value==" ")
		return "";
	if(StrToDate(fieldObject.value)==null)
		return "";
	else
		return DateToStr(StrToDate(fieldObject.value),"DD/MM/YYYY");
}

/////////////////
// decimalFormat
/////////////////
function decimalFormat(data,nbDec)
{
	data=numberDecimalFormat(data);
	dec="";
	sep="";
	if(data.indexOf(".")>0)
		data=data.replace(".",",");
	if(data.indexOf(",")>0)
	{
		dec =data.substring(data.indexOf(",")+1,data.length);
		sep=data.substring(data.indexOf(","),data.indexOf(",")+1);
		dec=dec.replace(",","")
		data=data.substring(0,data.indexOf(","));
	}

	var R=data.substring(0,(data.length%3));
	var POS=R.length;
	var L=data.length-POS;
	while(L>0)
	{
		R+=" "+data.substring(POS,POS+3);
		POS+=3;
		L-=3;
	 }

	if(dec.length>nbDec)
		dec=dec.substring(0,nbDec)
	if(dec.length==1)
		dec=dec+"0"
	if((dec.length==0)&&(data!=""))
	{
		dec=dec+"00"
		sep=","
	}
	if(R.substring(0,1)==" ")
		return R.substring(1)+sep+dec;
	else
		return R+sep+dec;
}

function decimalFormatRate(data,nbDec)
{
	data=numberDecimalFormat(data);
	dec="";
	sep="";
	if(data.indexOf(".")>0)
		data=data.replace(".",",");
	if(data.indexOf(",")>0)
	{
		dec =data.substring(data.indexOf(",")+1,data.length);
		sep=data.substring(data.indexOf(","),data.indexOf(",")+1);
		dec=dec.replace(",","");
		data=data.substring(0,data.indexOf(","));
	}

	if(dec.length>nbDec)
	{
		dec=dec.substring(0,nbDec);
	}
	else
	{	
		if(nbDec>0 && data!="")
		{
			if(dec.length==0)
			{
				sep=",";
			}
			while(dec.length!=nbDec)
			{
				dec=dec+"0";
			}
		}	
	}
	return data+sep+dec;
}


/////////////////
// currencyFormat
/////////////////
function currencyFormat(data)
{
	data=numberFormat(data);
	if(data.indexOf(".")>0)
		data=data.substring(0,data.indexOf("."));
	else if(data.indexOf(",")>0)
		data=data.substring(0,data.indexOf(","));

	var R=data.substring(0,(data.length%3));
	var POS=R.length;
	var L=data.length-POS;

	while(L>0)
	{
		R+=" "+data.substring(POS,POS+3);
		POS+=3;
		L-=3;
	}

	if(R.substring(0,1)==" ")
		return R.substring(1);
	else
		return R;
}

function decimalCurrencyFormat(data)
{
	return decimalFormat(data,2);
}


function currencyFormatPositive(data)
{
	data=numberFormatPositive(data);

	if(data.indexOf(".")>0)
		data=data.substring(0,data.indexOf("."));
	else if(data.indexOf(",")>0)
		data=data.substring(0,data.indexOf(","));

	var R=data.substring(0,(data.length%3));
	var POS=R.length;
	var L=data.length-POS;
	while(L>0){
		R+=" "+data.substring(POS,POS+3);
		POS+=3;
		L-=3;
	}

	if(R.substring(0,1)==" ")
		return R.substring(1);
	else
		return R;
}

/////////////////
// numberFormat
/////////////////
function numberFormat(data)
{
	if(data=="")return "";
	data=trim(data);
	var prefix="";
	if(data.substring(0,1)=="-")
		prefix="-";  //on sauvegarde le signe
	re=new RegExp("[^0-9.,]","gi");
	data=data.replace(re,"");
	if(data.substring(0,1)==".")data=0+data;
	return prefix+data;
}

function numberDecimalFormat(data)
{
	if(data=="")return "";
	data=trim(data);
	var prefix="";
	if(data.substring(0,1)=="-")
		prefix="-"; //on sauvegarde le signe
	re=new RegExp("[^0-9.,]","gi");
	data=data.replace(re,"");
	if(data.substring(0,1)==".")data=0+data;
	return prefix+data;
}

function numberDecimalFormatPositive(data)
{
	if(data=="")return "";
	data=trim(data);
	var prefix="";
	re=new RegExp("[^0-9.,]","gi");
	data=data.replace(re,"");
	if(data.substring(0,1)==".")data=0+data;
	return data;
}

function numberFormatPositive(data)
{
	if(data=="")return "";
	data=trim(data);
	re=new RegExp("[^0-9.,]","gi");
	data=data.replace(re,"");
	if(data.substring(0,1)==".")data=0+data;
	return data;
}

/////////////////
// numberUnFormat
/////////////////
/*Déformatage des montants financiers et des taux avant envoi serveur*/
function numberUnFormat(number)
{
	unFormatRules=/\s+/g;
	unFormatRules2=/,+/g;
	result=number.replace(unFormatRules,'');
	result=result.replace(unFormatRules2,'.');
	result=result.replace(new RegExp(String.fromCharCode(160),"g"),"");
	result=result.replace(new RegExp(String.fromCharCode(32),"g"),"");
	return result;
}

/////////////////
// roundCurrencyFormat
/////////////////
/**********Formatage des montants utilisateur******************/
function roundCurrencyFormat(fieldObject)
{
	if(fieldObject)
	{
		var val=fieldObject.value;
		val=numberFormat(val);
		if(val!=""&&val!="-")
		{
			val=Math.round(val);
			val=currencyFormat(val+"");
			if(val!=fieldObject.value)
				fieldObject.value=val;
		}
	}
}

function roundDecimalCurrencyFormat(fieldObject)
{
	if(fieldObject)
	{
		var val=fieldObject.value;
		val=numberFormat(val);
		if(val!=""||val!="-")
		{
			val=Math.round(val);
			val=decimalCurrencyFormat(val+"");
			if(val!=fieldObject.value)
				fieldObject.value=val;
		}
	}
}

function roundCurrencyFormatPositive(fieldObject)
{
	if(fieldObject)
	{
		var val=fieldObject.value;
		val=numberFormatPositive(val);
		if(val==""||val=="-")
			fieldObject.value="";
		else
		{
			val=Math.round(val);
			val=currencyFormatPositive(val+"");
			if(val!=fieldObject.value)
				fieldObject.value=val;
		}
	}
}

function roundDecimalCurrencyFormatPositive(fieldObject)
{
	if(fieldObject)
	{
		var val=fieldObject.value;
		val=numberDecimalFormat(val);
		if(val.substring(0,1)=="-")
			val=val.substring(1)
		if(val==""||val=="-")
			fieldObject.value="";
		else
		{
			val=decimalCurrencyFormat(val+"");
			if(val!=fieldObject.value)
				fieldObject.value=val;
		}
	}
}

/*****************************************************************************************************************/
/**********Formatage des taux utilisateur : acceptation de la,ou du . comme séparateur décimal******************/
/*****************************************************************************************************************/
function compareIndex(number1,number2)
{
	var index;
	if(number1==-1&&number2==-1){return -1}
 	else 
 	{
 		if(number1>0&&number2>0)
 			index=Math.min(number1,number2);
 		else 
 		{
 			if(number1==-1){index=number2}
 			else index=number1;
 		}
 		return index;
 	}
}

function checkPercentage(percentage)
{
	re=/[^0-9,.]/gi;
	re2=/[,.]/gi;

	firstComma=percentage.indexOf(",");
	firstPoint=percentage.indexOf(".");
	firstSeparator=compareIndex(firstComma,firstPoint);
	if(firstSeparator!=-1)
	{
		secondComma=percentage.indexOf(",",firstSeparator+1);
		secondPoint=percentage.indexOf(".",firstSeparator+1);
		secondSeparator=compareIndex(secondComma,secondPoint);

		if(secondSeparator!=-1)
 		{
			percentageSecondPart=percentage.substring(secondSeparator,percentage.length);
			percentage=percentage.substring(0,secondSeparator)+percentageSecondPart.replace(re2,"");
		}
	}
	percentage=percentage.replace(re,"");
	return percentage;
}

/////////////////
// roundRateFormatNegative
/////////////////
function roundRateFormatNegative(fieldObject)
{
	if(fieldObject)
	{
		if(fieldObject.value=="")
		return "";

		var svgValue=trim(fieldObject.value);
		var signe;

		var positiveValue;
		if(svgValue.substring(0,1)=="-")
		{
			signe="-";
			positiveValue=svgValue.substring(1,svgValue.length);
		}
		else
		{
			signe="";
			positiveValue=svgValue;
		}

		var newPositiveValue=checkPercentage(positiveValue);
		if(newPositiveValue.substring(0,1)=="."||newPositiveValue.substring(0,1)==",")
			newPositiveValue=0+newPositiveValue;

		fieldObject.value=signe+newPositiveValue;
		return fieldObject.value;
	}
}

/////////////////
// roundPercentageFormat
/////////////////
function roundPercentageFormat(fieldObject)
{
	if(fieldObject)
	{
		if(fieldObject.value=="")
			return "";
		fieldObject.value=trim(fieldObject.value);
		fieldObject.value=checkPercentage(fieldObject.value);
		if(fieldObject.value.indexOf(".")>0)
			fieldObject.value=fieldObject.value.replace(".",",");
		if(fieldObject.value.substring(0,1)=="."||fieldObject.value.substring(0,1)==",")
			fieldObject.value=0+fieldObject.value;
		return fieldObject.value;
	}
}

var enumLongDay=new Array('Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi');
var enumShortDay=new Array('Di','Lu','Ma','Me','Je','Ve','Sa');
var enumLongMonth=new Array('Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Decembre');
var enumShortMonth=new Array('Jan','Fev','Mar','Avr','Mai','Jui','Juil','Aou','Sep','Oct','Nov','Dec');
var changeYear=30;

function lpad(pInStr,pPadStr,pLength)
{
	if(pInStr.length>=pLength)return pInStr;

	var tmpStr=""
	do
	{
		tmpStr+=pPadStr;
	} while(tmpStr.length<pLength);
	return tmpStr.slice(0,pLength-pInStr.length)+pInStr;
}

function trimDate(pInStr)
{
	var startTmp=pInStr.search(/\S/);
	var endTmp=pInStr.search(/\S\s*$/);
	return pInStr.slice(startTmp,endTmp+1);
}

function DateToStr(pDate,pStrFormat)
{
	if(pDate==null)return "";
	var mySecond=""+pDate.getSeconds();
	var myMinute=""+pDate.getMinutes();
	var myHour=""+pDate.getHours();
	var myPMIndicator="AM";
	var isAMPM=(new RegExp("AM\/PM","")).test(pStrFormat);
	if((isAMPM)&&(myHour>=12))
	{
		myHour =""+(pDate.getHours()-12);
		myPMIndicator="PM";
	}
	var myDay=""+pDate.getDate();
	var myMonth=""+(pDate.getMonth()+1);
	var myYear="";
	if((pDate.getYear()>=0)&&(pDate.getYear()<100))
		myYear=""+(pDate.getYear()+1900);
	else
		myYear=""+(pDate.getFullYear());
	var myNewStr=pStrFormat;
	myNewStr=myNewStr.replace(/AM\/PM([^\w|\b]*)/,"@1@$1");
	myNewStr=myNewStr.replace(/hh([^\w|\b]*)/,lpad(myHour,"0",2)+"$1");
	myNewStr=myNewStr.replace(/h([^\w|\b]*)/,myHour+"$1");
	myNewStr=myNewStr.replace(/mm([^\w|\b]*)/,lpad(myMinute,"0",2)+"$1");
	myNewStr=myNewStr.replace(/m([^\w|\b]*)/,myMinute+"$1");
	myNewStr=myNewStr.replace(/ss([^\w|\b]*)/,lpad(mySecond,"0",2)+"$1");
	myNewStr=myNewStr.replace(/s([^\w|\b]*)/,mySecond+"$1");
	myNewStr=myNewStr.replace(/DDDD([^\w|\b]*)/,"@2@$1");
	myNewStr=myNewStr.replace(/DDD([^\w|\b]*)/,"@3@$1");
	myNewStr=myNewStr.replace(/DD([^\w|\b]*)/,lpad(myDay,"0",2)+"$1");
	myNewStr=myNewStr.replace(/D([^\w|\b]*)/,myDay+"$1");
	myNewStr=myNewStr.replace(/MMMM([^\w|\b]*)/,"@4@$1");
	myNewStr=myNewStr.replace(/MMM([^\w|\b]*)/,"@5@$1");
	myNewStr=myNewStr.replace(/MM([^\w|\b]*)/,lpad(myMonth,"0",2)+"$1");
	myNewStr=myNewStr.replace(/M([^\w|\b]*)/,myMonth+"$1");
	myNewStr=myNewStr.replace(/YYYY([^\w|\b]*)/,myYear+"$1");
	myNewStr=myNewStr.replace(/YY([^\w|\b]*)/,myYear.substr(2,2)+"$1");
	myNewStr=myNewStr.replace(/@1@/,myPMIndicator);
	myNewStr=myNewStr.replace(/@2@/,enumLongDay[pDate.getDay()]);
	myNewStr=myNewStr.replace(/@3@/,enumShortDay[pDate.getDay()]);
	myNewStr=myNewStr.replace(/@4@/,enumLongMonth[pDate.getMonth()]);
	myNewStr=myNewStr.replace(/@5@/,enumShortMonth[pDate.getMonth()]);
	return myNewStr;
}

function isValidDate(pStrDate)
{
	pStrDate=trimDate(pStrDate);
	// Check against format,valid date format are:
	// D/M/YY,DD/MM/YY,D/M/YYYY,DD/MM/YYYY
	// D-M-YY,DD-MM-YY,D-M-YYYY,DD-MM-YYYY
	// D.M.YY,DD.MM.YY,D.M.YYYY,DD.MM.YYYY
	// D M YY,DD MM YY,D M YYYY,DD MM YYYY
	// valid time format are:
	// h:m:s,hh:mm:ss
	// h:m:s AM/PM,hh:mm:ss AM/PM
	strTokens=pStrDate.match(/^([0-3]?[0-9]?)[-\/\.\s]+([0-1]?[0-9]?)[-\/\.\s]+([0-9]{2,4})[-\/\.\s]*([0-3]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*(AM|PM)?/)
	if(strTokens==null)
	{
		// alternative formats
		// DDMMYY,DDMMYYYY
		if(pStrDate.length>8)
			return false;
		strTokens=pStrDate.match(/^([0-3][0-9])([0-1][0-9])([0-9]{2,4})[-\/\.\s]*([0-3]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*(AM|PM)?/)
	}
	if(strTokens==null)return false;
	// Check that the date is a valid date(exists in the calendar)
	myDay=parseInt("0"+strTokens[1],10);
	myMonth=parseInt("0"+strTokens[2],10);
	myYear=parseInt("0"+strTokens[3],10);
	if(strTokens[3].length==3||strTokens[3].length==1)return false;
	if(myYear<changeYear)myYear=myYear+2000;
	var myHour=parseInt("0"+strTokens[4],10);
	var myMinute=parseInt("0"+strTokens[5],10);
	var mySecond=parseInt("0"+strTokens[6],10);
	if(((strTokens[7]=="AM")||(strTokens[7]=="PM"))&&(myHour>12))return false;
	if(strTokens[7]=="PM")myHour+=12;
	var myNewDate=new Date(myYear,myMonth-1,myDay,myHour,myMinute,mySecond);
	if(!myNewDate)return false;
	if(((myNewDate.getMonth()+1)!=myMonth)||(myNewDate.getDate()!=myDay))return false;
	return true;
}

function showError()
{
	this.focus();
	this.select();
}

function StrToDate(pStrDate)
{
	pStrDate=trim(pStrDate);
	if(pStrDate=="")
		return "";

	var myDay;
	var myMonth;
	var myYear;
	var myHour;
	var myMinute;
	var mySecond;

	if(pStrDate.length != 4 )
	{
	// Check if the input string is a valid date
	if(!isValidDate(pStrDate))return null;
	strTokens=pStrDate.match(/^([0-3]?[0-9]?)[-\/\.\s]+([0-1]?[0-9]?)[-\/\.\s]+([0-9]{2,4})[-\/\.\s]*([0-3]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*(AM|PM)?/)
	// alternative formats
	// DDMMYY,DDMMYYYY
	if(strTokens==null)
		strTokens=pStrDate.match(/^([0-3][0-9])([0-1][0-9])([0-9]{2,4})[-\/\.\s]*([0-3]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*([0-5]?[0-9]?)[:!,;%-\/\.\s]*(AM|PM)?/)
	if(strTokens==null)return "";
	// Check that the date is a valid date(exists in the calendar)
	var myDay=parseInt("0"+strTokens[1],10);
	var myMonth=parseInt("0"+strTokens[2],10);
	var myYear=parseInt("0"+strTokens[3],10);
	if(myYear<changeYear)myYear=myYear+2000;
	var myHour=parseInt("0"+strTokens[4],10);
	var myMinute=parseInt("0"+strTokens[5],10);
	var mySecond=parseInt("0"+strTokens[6],10);
	if(strTokens[7]=="PM")myHour+=12;
	}
	else if(pStrDate.length == 4)
	{
		//It is only the year, transform into 01/01/YEAR 00:00:00
		strTokens=pStrDate.match(/^([1-3][0-9][0-9][0-9])?/)
		if(strTokens==null)return "";
		var myDay=parseInt("01",10);
		var myMonth=parseInt("01",10);
		var myYear=parseInt("0"+strTokens[1],10);
		var myHour=parseInt("00",10);
		var myMinute=parseInt("00",10);
		var mySecond=parseInt("00",10);
	}
	return new Date(myYear,myMonth-1,myDay,myHour,myMinute,mySecond);
}

/***********Déformatage des dates avant envoi serveur******/
/////////////////
// dateUnFormat
/////////////////
function unFormatDate(pStrDate)
{
	return DateToStr(StrToDate(pStrDate),"YYYY-MM-DD");
}
/**********************************************************/
/**********Formatage des dates utilisateur******************/
/**********************************************************/
/////////////////
// formatDate
/////////////////
var winModalWindow

function IgnoreEvents(e)
{
	return false
}
function ShowWindow(openurl,name,width,height,top,left)
{
	if(window.showModalDialog)
		window.showModalDialog(openurl,name,"dialogWidth="+width+"px;dialogHeight="+height+"px;center=yes")
	else
	{
		window.captureEvents(Event.CLICK|Event.FOCUS)
		window.onclick=IgnoreEvents
		window.onfocus=HandleFocus
		winModalWindow=window.open(openurl,name,"dependent=yes,width="+width+",height="+height+",top="+top+",left="+left)
		winModalWindow.focus()
	}
}

function HandleFocus()
{
	if(winModalWindow)
	{
		if(!winModalWindow.closed)
			winModalWindow.focus()
		else
			window.releaseEvents(Event.CLICK|Event.FOCUS)
	}
	return false
}

function showError(fieldObject)
{
	fieldObject.focus();
	fieldObject.select();
}

function showDateError(fieldObject)
{
	if(trim(fieldObject.value)!=""&&!isValidDate(fieldObject.value))showError(fieldObject);
}

/*******************************************/
/*                                         */
/*          formatage-divers.js            */
/*                                         */
/*******************************************/
// mapping avec le formattage automatique
function formatCapitalizedName(data)
{
	return nameFormat(data);
}

////////////////////////////////////////////////////////////
// Format a name: First Letter of each word is capitalized
////////////////////////////////////////////////////////////
function nameFormat(data)
{
	if(data=="")
		return "";

	// 1ere etape: on met une majuscule apres chaque blanc
	var allWords=data.value.split(" ");
	var spaceFormattedData="";
	var nbWords=allWords.length;
	if(nbWords==1)
	{
		var word=allWords[0];
		var firstLetter=word.substring(0,1);
		var otherLetters="";
		if(word.length>1)
		{
			otherLetters=word.substring(1,word.length);
			otherLetters=otherLetters.toLowerCase();
		}
		firstLetter=firstLetter.toUpperCase();
		spaceFormattedData=firstLetter+otherLetters;
	}
	else
	{
		for(var i=0;i<nbWords;i++)
		{
			var word=allWords[i];
			var firstLetter=word.substring(0,1);
			var otherLetters="";
			if(word.length>1)
			{
				otherLetters=word.substring(1,word.length);
				otherLetters=otherLetters.toLowerCase();
			} 
			firstLetter=firstLetter.toUpperCase();

			spaceFormattedData+=firstLetter+otherLetters;
			if(i<nbWords-1)
				spaceFormattedData+=" ";
		}
	}

	// 2eme etape: on met une majuscule apres chaque tiret 	

	allWords=spaceFormattedData.split("-");
	var formattedData="";
	nbWords=allWords.length;
	if(nbWords==1)
	{
		return spaceFormattedData;
	}
	else
	{
		for(var i=0;i<nbWords;i++)
		{
			var word=allWords[i];
			if(word !="")
			{
				var firstLetter=word.substring(0,1);
				var otherLetters="";
				if(word.length>1)
				{
					otherLetters=word.substring(1,word.length);
				}
				firstLetter=firstLetter.toUpperCase();
				formattedData+=firstLetter+otherLetters;
				if(i<nbWords-1)
					formattedData+="-";
			}
		}
	}
	return formattedData;	
}

////////////////////////////////////////////////////////////
// Format a place: First Letter of first word is capitalized
////////////////////////////////////////////////////////////
function firstLetterUpper(data) 
{
	if(data=="")
		return "";

	// 1ere etape: on met une majuscule apres chaque blanc 	
	var allWords=data.value.split(" ");
	var spaceFormattedData="";

	var nbWords=allWords.length;

	for(var i=0;i<nbWords;i++)
	{
		var word=allWords[i];
		var firstLetter=word.substring(0,1);
		var otherLetters="";
		if(word.length>1)
		{
			otherLetters=word.substring(1,word.length);
			otherLetters=otherLetters.toLowerCase();
		} 
		if(i==0)
			firstLetter=firstLetter.toUpperCase();

		spaceFormattedData+=firstLetter+otherLetters;
		if(i<nbWords-1)
			spaceFormattedData+=" ";
	}
	return spaceFormattedData;	
}

/////////////////
// zipFormat
/////////////////
function zipFormat(fieldObject)
{
	var data=fieldObject.value;
	data=data.replace(/\s/g,"");	
	if(data.length>2)
		data=data.substring(0,2)+" "+data.substring(2,data.length);

	if(data!=fieldObject.value) 
		fieldObject.value=data;
}

/////////////////
// phoneNumberFormat
/////////////////
function phoneNumberFormat(fieldObject)
{
	var value=fieldObject.value;
	if(!value)
		return;

	var phoneNumber="";
	value=value.replace(" ","");
	value=value.replace(".","");
	
	var validChars="0123456789+";
	var position=0;
	var startWithPlus=false;
	for(var i=0;i<value.length;i++) 
	{
		var val=value.charAt(i);
		if(validChars.indexOf(val) !=-1)
		{
			if(val=='+') 
			{
				if(position==0)
				{
					phoneNumber+=val;
					position++;
					startWithPlus=true;
				}
			}
			else
			{
				phoneNumber+=val;
				position++;
			}
		}
	}

	if(phoneNumber.length==0)
	{
		if(phoneNumber!=fieldObject.value) 
			fieldObject.value=phoneNumber;	
		return;
	}

	var newPhoneNumber="";
	var i=0;
	var previousPairIndex=0;

	if(startWithPlus)
	{
		newPhoneNumber+="+";

		// Indicateur pays
		if(phoneNumber.length>=3)
		{
			newPhoneNumber+=phoneNumber.substring(1,3);
			// Numero seul:
			if(phoneNumber.length>=4)
			{
				newPhoneNumber+=" "+phoneNumber.substring(3,4);			
				if(phoneNumber.length>=6)
				{
					i=6;
					previousPairIndex=4;
				}
			else
			{
					newPhoneNumber+=" "+phoneNumber.substring(4,phoneNumber.length);				
					if(newPhoneNumber!=fieldObject.value) 
						fieldObject.value=newPhoneNumber;
					return;
				}
			}	
			else
			{
				newPhoneNumber+=" " +phoneNumber.substring(3,phoneNumber.length);
				if(newPhoneNumber!=fieldObject.value) 
					fieldObject.value=newPhoneNumber;
				return;
			}
		}
	else
	{
			newPhoneNumber+=phoneNumber.substring(1,phoneNumber.length);
	 	 	if(newPhoneNumber!=fieldObject.value) 
				fieldObject.value=newPhoneNumber;
			return;
		}
	}
	else
	{
		// Est-ce un indicateur international,qui commence par 00
		if(phoneNumber.length>4)
 	 	{
			if(phoneNumber.substring(0,2)=="00")
			{
				newPhoneNumber+="00 "+phoneNumber.substring(2,4)+" "+phoneNumber.substring(4,5);
				if(phoneNumber.length>=7)
 				{
					phoneNumber=phoneNumber.substring(1,phoneNumber.length);	 
					i=6;
					previousPairIndex=4;
			}
			else
			{
					if(phoneNumber.length>=5)
					{
						newPhoneNumber+=" "+phoneNumber.substring(5,phoneNumber.length);				
					}	
					if(newPhoneNumber!=fieldObject.value) 
						fieldObject.value=newPhoneNumber;
					return;
				}
			}
			else
			{
				i=2;
				previousPairIndex=0;	
			}			
		}
		else
		{
			i=2;
			previousPairIndex=0;
		}	
	}

	for(;i<phoneNumber.length;i++)
	{
		if(i % 2==0)
		{
			if(previousPairIndex==0)
				newPhoneNumber+=phoneNumber.substring(previousPairIndex,i);	
			else
				newPhoneNumber+=" "+phoneNumber.substring(previousPairIndex,i);	
			previousPairIndex=i;
		} 
	}

	if((i==2)&&(i>phoneNumber.length))
		i=phoneNumber.length;
 
	if((i>=previousPairIndex)&&(i<=phoneNumber.length))
	{
		if(previousPairIndex==0)
			newPhoneNumber+=phoneNumber.substring(previousPairIndex,i);
		else
			newPhoneNumber+=" "+phoneNumber.substring(previousPairIndex,i);
	}

	if(newPhoneNumber!=fieldObject.value) 
		fieldObject.value=newPhoneNumber;
}

/*******************************************/
/*                                         */
/*              formulaire.js              */
/*                                         */
/*******************************************/
// Affectation du champ 'dispatch' du formulaire
// et Validation du formulaire 
function doSubmit(newDispatch,message)
{
	veuillezPatienter(message);
	if(document.body) document.body.style.cursor="wait";
	document.forms[0].dispatch.value=newDispatch;
	document.forms[0].submit();
}

// rechargement du formulaire en submittant le formulaire avec l'action speciale 'recharger' 
function recharger()
{
	doSubmit("recharger");
}

// validation de la page en submittant le formulaire avec l'action speciale 'valider'
function valider()
{
	doSubmit("valider");
}
// rafraichir la page en submittant le formulaire avec l'action speciale 'rafraichir'
function rafraichir()
{
	doSubmit("rafraichir");
}

function getChamp(nomChamp)
{
	return document.forms[0].elements[nomChamp];
}
function setValeurChamp(nomChamp,valeurChamp)
{
	document.forms[0].elements[nomChamp].value=valeurChamp;
}
function getValeurChamp(nomChamp)
{
	var champ=getChamp(nomChamp);
	if(champ) return champ.value;
}
function getElementFromMultiBox(multiBoxProperty,index)
{
	if(multiBoxProperty)
	{
		if(multiBoxProperty.length)
		{
			return multiBoxProperty[index];
		}
		else
		{
			return multiBoxProperty;
		}
	}
}
function getCheckedRadioValue(nomChamp)
{
	var champ=getCheckedRadio(nomChamp);
	if(champ) return champ.value;
}
function getCheckedRadio(nomChamp)
{
	var champRadio=getChamp(nomChamp);
	if(champRadio)
	{
		var nbRadios=champRadio.length;
		for(var i=nbRadios;i>=0;i--)
		{
			var radioCourant=champRadio[i];
			if(radioCourant)
			{
				if(radioCourant.checked)
				{
					return radioCourant;
				}
			}
		}
	}
}
function checkRadio(nomChamp,valeurACocher)
{
	var champRadio=getChamp(nomChamp);
	if(champRadio)
	{
		var nbRadios=champRadio.length;
		for(var i=nbRadios;i>=0;i--)
		{
			var radioCourant=champRadio[i];
			if(radioCourant)
			{
				if(radioCourant.value==valeurACocher)
				{
					radioCourant.checked=true;
				}
				else
				{
					radioCourant.checked=false;
				}
			}
		}
	}
}

// confirmer une suppression
function confirmerSuppression(nomAction,messageConfirmation)
{
	fonction="doSubmit (\'"+nomAction+"\')";
	afficherAlerte("confirmation",messageConfirmation);
}

function buildActionPopupAndDoSubmitOuFonctionJSString(nomActionAffichagePopupJS,nomAction,nomDoSubmitOuJS,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	var actionPopup=nomActionAffichagePopupJS+"(";
	actionPopup+="\""+nomAction+"\"";
	if (nomDoSubmitOuJS) actionPopup+=",\""+nomDoSubmitOuJS+"\"";
	actionPopup+=",\""+titrePopup+"\"";
	actionPopup+=","+popupWidth;
	actionPopup+=","+popupHeight;
	actionPopup+=",\""+popupScroll+"\"";
	actionPopup+=",\""+popupResizable+"\"";
	if(nomParametre1)
	{
		actionPopup+=",\""+nomParametre1+"\"";
		actionPopup+=",\""+valeurParametre1+"\"";
		if(nomParametre2)
		{
			actionPopup+=",\""+nomParametre2+"\"";
			actionPopup+=",\""+valeurParametre2+"\"";
			if(nomParametre3)
			{
				actionPopup+=",\""+nomParametre3+"\"";
				actionPopup+=",\""+valeurParametre3+"\"";
			}
		}
	}
	actionPopup+=")";	
	return actionPopup;
}

function validerEtActionPopup(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	var actionPopup=buildActionPopupAndDoSubmitOuFonctionJSString("actionPopup",nomAction,null,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3);
	setValeurChamp("actionPopup",actionPopup);
	doSubmit("validerEtActionPopup");
}

function validerEtActionPopupSimple(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	var actionPopup=buildActionPopupAndDoSubmitOuFonctionJSString("actionPopupSimple",nomAction,null,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3);
	setValeurChamp("actionPopup",actionPopup);
	doSubmit("validerEtActionPopup");
}

function validerEtActionPopupEtRafraichir(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	var actionPopup=buildActionPopupAndDoSubmitOuFonctionJSString("actionPopupEtDoSubmit",nomAction,"rafraichir",titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3);
	setValeurChamp("actionPopup",actionPopup);
	doSubmit("validerEtActionPopup");
}

function validerEtActionPopupEtRafraichir(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	validerEtActionPopupEtDoSubmit(nomAction,"rafraichir",titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
}
function validerEtActionPopupEtDoSubmit(nomAction,nomSubmit,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	var actionPopup=buildActionPopupAndDoSubmitOuFonctionJSString("actionPopupEtDoSubmit",nomAction,nomSubmit,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3);
	setValeurChamp("actionPopup",actionPopup);
	doSubmit("validerEtActionPopup");
}

function validerEtActionPopupEtFonctionJS(nomAction,nomFonctionJS,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	var actionPopup=buildActionPopupAndDoSubmitOuFonctionJSString("actionPopupEtFonctionJS",nomAction,nomFonctionJS,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3);
	setValeurChamp("actionPopup",actionPopup);
	doSubmit("validerEtActionPopup");
}

var URLPopup="";
var rechargerPage;
var popupCallbackFunction;

function setURLPopup(urlDeLaPopup)
{
	URLPopup=urlDeLaPopup;
}

function actionPopup(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	popupCallbackFunction = "valider()";
	if(actionPopupSimple(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3))
	{
		eval(popupCallbackFunction);
	}
}

function actionPopupSimpleWithTabParam(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,tabParam)
{
	var today=new Date().getTime();
	var paramPopup="actionPopup="+nomAction+"&titrePopup="+titrePopup+"&date="+today;
	for(i=0;i<tabParam.length-1;i+=2)
	{
		paramPopup=paramPopup+"&"+tabParam[i]+"="+escape(tabParam[i+1]);
	}
	var urlDeLaPopup=URLPopup;
	urlDeLaPopup=urlDeLaPopup+"?"+paramPopup;
	rechargerPage=false;
	afficherPopupCentree(urlDeLaPopup,window,popupWidth,popupHeight,popupScroll,popupResizable);
	return rechargerPage;

}
//Deprecated - a repercuter sur les autres méthodes
function actionPopupSimple(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	var tabParam = new Array();
	if(nomParametre1)
	{
		tabParam.push(nomParametre1);
		tabParam.push(valeurParametre1);
	}
	if(nomParametre2)
	{
		tabParam.push(nomParametre2);
		tabParam.push(valeurParametre2);
	}
	if(nomParametre3)
	{
		tabParam.push(nomParametre3);
		tabParam.push(valeurParametre3);
	}
	return actionPopupSimpleWithTabParam(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,tabParam);
}

function actionPopupEtRafraichir(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	popupCallbackFunction = "rafraichir()";
	if(actionPopupSimple(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3))
	{
		eval(popupCallbackFunction);
	}
}

function actionPopupEtDoSubmit(nomAction,nomDoSubmit,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	popupCallbackFunction = "doSubmit('"+nomDoSubmit+"');";
	if(actionPopupSimple(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3))
	{
		eval(popupCallbackFunction);
	}
}

function actionPopupEtDoSubmitTab(nomAction,nomDoSubmit,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,params)
{
	popupCallbackFunction = "doSubmit('"+nomDoSubmit+"');";
	if(actionPopupSimpleWithTabParam(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,params)) {
		eval(popupCallbackFunction);
	}
}  

function actionPopupEtFonctionJS(nomAction,fonctionJS,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3)
{
	popupCallbackFunction = fonctionJS;
	if(actionPopupSimple(nomAction,titrePopup,popupWidth,popupHeight,popupScroll,popupResizable,nomParametre1,valeurParametre1,nomParametre2,valeurParametre2,nomParametre3,valeurParametre3))
	{
		eval(popupCallbackFunction);
	}
}

function isVeuillezPatienterEnCours()
{
	if(isVisible("calqueMessageAttente"))
		return true;
	else
		return false;
}
function veuillezPatienter(message)
{
	setInvisible("calqueBandeau");
	setInvisible("calqueDonnees");
	setInvisible("calqueMenu");
	setVisible("calqueBandeauCache");
	setVisible("calqueMenuCache");
	var zoneCalqueMessageAttente=getElementFromDocument("calqueMessageAttente");
	if(zoneCalqueMessageAttente)
	{
		// Ce code ne fonctionne pas une fois les CSS de carac appliquées, car le plus proche parent positionné de #calqueMessageAttente est #texte et plus body.
		/*zoneCalqueMessageAttente.style.top=document.body.clientHeight/2-50;
		zoneCalqueMessageAttente.style.left=document.body.clientWidth/2-100;*/
		setItVisible(zoneCalqueMessageAttente);
		if(message)
		{
			var spanMessage=getElementFromDocument("spanMessage");
			if(spanMessage) spanMessage.innerHTML=message;
		}
	}
}
/*******************************************/
/*                                         */
/*                 utils.js                */
/*                                         */
/*******************************************/
/*************************************/
/* Blocage du clic droit sur la page */
/*************************************/
if (window.Event)   
	document.captureEvents(Event.MOUSEUP);

function nocontextmenu()    
{  
	if (window.Event)
	{
		return false;
	}
	else
	{
		event.cancelBubble = true  
		event.returnValue = false;  
		return false;  
	}
}  
function norightclick(e)   
{  
	if (window.Event)   
	{  
		if (e.which == 2 || e.which == 3)  
			return false;  
	}  
	else if (event.button == 2 || event.button == 3)  
	{  
		event.cancelBubble = true  
		event.returnValue = false;  
		return false;  
	}  
}
document.oncontextmenu = nocontextmenu;   
document.onmousedown = norightclick;   

var ie50=false;
if(navigator.appName=="Microsoft Internet Explorer")
{
	var appVersion=navigator.appVersion;
	if(appVersion.indexOf("MSIE")!=-1)
	{
		var versionMSIE=appVersion.substring(appVersion.indexOf("MSIE")+4,appVersion.length);
		if (parseFloat(versionMSIE)<5.5) ie50=true;
	}
}
if (navigator.appName=='Netscape')
{
	document.captureEvents(Event.KEYDOWN);
}
document.onkeydown=bloqueTouche;

// Gestion de la fenetre d'aide
var fenetreAide;
function fermerAide()
{
	if((fenetreAide)&&(!fenetreAide.closed)) // fenetre d'aide déjà ouverte
		fenetreAide.close();
}

function ouvrirAide()
{
	if ((!fenetreAide) || (fenetreAide.closed))
	{
		var aideURL="aide/aide.jsp?idPageAide="+ getIdPageAide() + "&titrePageAide=" + getTitrePageAide();
		var x;
		var y;
		if (self.screen)
		{     // for NN4 and IE4
			width = screen.width * 0.4;
			height = screen.height * 0.95; //0.95=> décalage pour la barre de tâches
			x = 0;
			y = screen.width - width - 5; // 5=>décalage pour la scroll barre
		}
		else
		{
			width=320;
			height=600;
			x = 0;
			y = 500;
		}
		var options='width='+width+',height='+height+',status=no,resizable=yes,top='+x+',left='+y;
		fenetreAide = window.open(aideURL,'',options);
	}
}

// Gestion de la fenetre A Propos 		
var fenetreApropos;
function fermerApropos()
{
	if ((fenetreApropos) && (!fenetreApropos.closed)) // fenetre apropos déjà ouverte
		fenetreApropos.close();
}

function ouvrirAPropos()
{
	var aproposURL="apropos/apropos.jsp";
	afficherPopupCentree(aproposURL,window,250,300,"no","no");
}

// Gestion de Copie d'Ecran 
function impression()
{
	window.print();
}		

// Modification du titre du bandeau 
function setTitreBandeau(nouveauTitreBandeau) 
{
	var zoneTitreBandeau=getElementFromDocument("TitreBandeau");
	if (zoneTitreBandeau) 
		zoneTitreBandeau.innerHTML = nouveauTitreBandeau;
}

var oldClassName="";
var vientDEtreCharge=true;
// Gestion de l'affichage d'une liste avec possibilite de selectionne un element
function clickLigne(prefixListe,nomChampIdSelectionne,idSelectionne)
{
	var oldIdSelectionne=document.forms[0].elements[nomChampIdSelectionne].value;
	var newIdSelectionne=idSelectionne.substr(prefixListe.length);
	document.forms[0].elements[nomChampIdSelectionne].value=newIdSelectionne;

	var oldTRselectionne=document.getElementById(prefixListe+oldIdSelectionne);
	if((oldTRselectionne)&&(oldClassName!=""))
		setTDClassInTR(oldTRselectionne,oldClassName);
	if((oldIdSelectionne!=newIdSelectionne)||(vientDEtreCharge))
	{
		vientDEtreCharge=false;
		var TRselectionne=document.getElementById(prefixListe+newIdSelectionne);
		oldClassName=getTDClassInTR(TRselectionne);
		setTDClassInTR(TRselectionne,"ligneSelectionneeTableauSaisie");
	}
	else
		document.forms[0].elements[nomChampIdSelectionne].value="";
}

function initSelectionListe(prefixListe,nomChampIdSelectionne)
{			
	var idSelectionne=document.forms[0].elements[nomChampIdSelectionne].value;			
	var TRselectionne=document.getElementById(prefixListe+idSelectionne);		
	vientDEtreCharge=false;
	oldClassName=getTDClassInTR(TRselectionne);		
	setTDClassInTR(TRselectionne,"ligneSelectionneeTableauSaisie");			
}

// Selection/Deselection d'une ligne d'un tableau
function setTDClassInTR(TRobject,nomClass)
{
	var lesTDFils=TRobject.getElementsByTagName("TD");
	for(i=0;i<lesTDFils.length;i++)
	{
		var unTD=lesTDFils[i];
		unTD.className=nomClass;
	}
}

function getTDClassInTR(TRobject)
{
	var lesTDFils=TRobject.getElementsByTagName("TD");
	for(i=0;i<lesTDFils.length;i++)
	{
		var unTD=lesTDFils[i];
		return unTD.className;
	}
	return "";
}

// recuperation de l'id selectionne en cours
function getIdSelectionne(nomChampIdSelectionne)
{
	var valeur=getValeurChamp(nomChampIdSelectionne);
	if((!vientDEtreCharge)&&(valeur)&&(valeur!=0)&&(valeur!=""))
		return valeur;
	else
		return "";
}
function refresh() 
{
	window.parent.location.reload();
}

// Gestion du passage sur une ligne d'un tableau	    
var oldCSS;
function changeCSS (ligne)
{
	oldCSS = ligne.className;
	ligne.className = "ligneSelectionneeTableauSaisie";		   
}
function restoreCSS (ligne)
{
	ligne.className = oldCSS;
}		

// Met le focus et selectionne le champ dont le nom est passe en parametre.
function setFocusChamp (nomChampDefaut)
{
	var champToSetFocusDefaut=getElementFromDocument(nomChampDefaut);
	if (champToSetFocusDefaut)					
	{
		var typeChampToSetFocusDefaut=champToSetFocusDefaut.type;
		if ((typeChampToSetFocusDefaut)&&(typeChampToSetFocusDefaut!="hidden"))
		{
			var readonly=false;
			if ((typeChampToSetFocusDefaut=="select-one")||(typeChampToSetFocusDefaut=="select-multiple"))
				readonly=champToSetFocusDefaut.disabled;		
			else
				readonly=champToSetFocusDefaut.readOnly;
			if (!readonly)
			{
				if((typeChampToSetFocusDefaut=="text")||(typeChampToSetFocusDefaut=="textarea")||(typeChampToSetFocusDefaut=="password"))
				{	
					if((champToSetFocusDefaut.select)&&(!ie50))
						champToSetFocusDefaut.select();
				}		
				else if((champToSetFocusDefaut.focus)&&(!ie50))
					champToSetFocusDefaut.focus();
			}							
		}
	}							
}
		
/* Fonctions pour l'aide contextuelle */
function changeContenuAideContextuelle(messageAide)
{
	var zoneAideContextuelle=getElementFromDocument("spanTexteAideContextuelle");
	if (zoneAideContextuelle)
		zoneAideContextuelle.innerHTML=messageAide;
}
function effaceContenuAideContextuelle()
{
	changeContenuAideContextuelleParDefaut();
}
function setStyleCurseurSouris(nouveauStyle)
{
	if (document.body)
		document.body.style.cursor=nouveauStyle;
}

function bloqueTouche(e)
{
	if(!e)
	{
		if(event.ctrlKey)
		{
			//Touche Ctrl enfoncée
			if((event.keyCode==78)||(event.keyCode==104))//n ou N enfoncé
				event.returnValue=false;
		}
		if(window.opener)
		{
			var isOnTextInput = false;
			var sourceElt = event.srcElement;
			if (sourceElt.type)
			{
				// On détermine si le focus est placé sur une zone de saisie (text, textarea ou pasword)
				isOnTextInput = sourceElt.type.toLowerCase()=='text' || sourceElt.type.toLowerCase()=='textarea' || sourceElt.type.toLowerCase()=='password';
			}
			
			if( event.keyCode==122 //F11
			 || (event.keyCode==8 && !isOnTextInput)) // backspace (retour) si on n'est pas sur une zone de saisie uniquement !
			{
				event.keyCode=0;
				return false;
			}
		}
	}
}
	
/* Fonction pour boutons dans le bandeau*/
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];}
}
function extrait_valeur_dans_chaine (num, texte, separateur)
{
	tableau=texte.split(separateur)
	return tableau[num]
}
		
// Cette fonction permet de "nettoyer" une chaîne de caractères lue dans le fichier de propriété via un 
// tag bean:message et de remplacer les caractères codés dans cette chaîne (par exemple, l'apostrophe) 
// par leur valeur réelle.
function cleanString(str)
{
	// Construction d'un tableau des codes de caractères à remplacer. 
	// Pour l'instant, on y place juste le code caractère 39 (apostrophe)
	// A enrichir en fonction des besoins !
	var codesToReplace = new Array();
	// Pour chaque entrée, on donne le code et la valeur réelle
	codesToReplace[0] = new Array("39", "\'");

	// Remplacement des codes 
	var result = str;
	for (i=0 ; i<codesToReplace.length ; i++)
	{
		var toReplace = "&#"+codesToReplace[i][0]+";";
		while (result.indexOf(toReplace)>=0)
		{
			var start = result.indexOf(toReplace);
			var end = start+toReplace.length;
			result = result.slice(0, start) + codesToReplace[i][1] + result.slice(end);
		}
	}
	return result; 
}
	
function calculAge(dateDeNaissance)
{
	var tableau=dateDeNaissance.split('/');
	var anneeNaiss=parseInt(tableau[2],10);
	var moisNaiss=parseInt(tableau[1],10)-1;
	var jourNaiss=parseInt(tableau[0],10);

	var now=new Date();
	var anneeNow=now.getFullYear();
	var moisNow=now.getMonth();
	var jourNow=now.getDate();

	var anneeAge=anneeNow-anneeNaiss;
	if (moisNow>=moisNaiss)
		var moisAge=moisNow-moisNaiss;
	else
	{
		anneeAge--;
		var moisAge=12+moisNow-moisNaiss;
	}
	if (jourNow<jourNaiss)
	{
		moisAge--;
		if (moisAge<0) anneeAge--;
	}		
	return anneeAge;
}

// Efface les options d'une liste déroulante
function videListe(liste)
{
	var nb = liste.options.length;
	for(i=0;i<nb;i++)
	{
		liste.options[0]=null;
	}
}

function selectionneElementDansListe(nomChamp, valeurASelectionner)
{
	var champListe=getChamp(nomChamp);
	if((champListe)&&((champListe.type=="select-one")||(champListe.type=="select-multiple")))
	{
		var nbChoix=champListe.options.length;
		for (var i=nbChoix;i>=0;i--)
		{
			var optionCourante=champListe.options[i];
			if(optionCourante)
			{
				if (optionCourante.value==valeurASelectionner)
				{
					optionCourante.selected=true;
				}
				else
				{
					optionCourante.selected=false;
				}
			}
		}
	}
}
/*******************************************/
/*                                         */
/*          convergence.js             	   */
/*                                         */
/*******************************************/
var urlRedirection;
var urlRedirectionParam;
var urlActionQuitter;
var actionQuitterRedirectionValider;
var messageFermer;
var messageQuitterComposantSeul;
var messageQuitter;

function setFermetureUrlSiteRetour(redirectionEnable,urlRedirectionParam)
{
	if(redirectionEnable=="true" && urlRedirectionParam!=null && urlRedirectionParam.length>0)
		urlRedirection=urlRedirectionParam;
	else
		urlRedirection=null;
}
function setActionQuitterRedirectionValider(actionQuitterRedirectionValiderParam)
{
	actionQuitterRedirectionValider=actionQuitterRedirectionValiderParam;
}
function setURLActionQuitter(url)
{
	urlActionQuitter=url;
}
function setMessageFermer(messageFermerParam)
{
	messageFermer=messageFermerParam;
}
function setMessageQuitterComposantSeul(messageQuitterComposantSeulParam)
{
	messageQuitterComposantSeul=messageQuitterComposantSeulParam;
}
function setMessageQuitter(messageQuitterParam)
{
	messageQuitter=messageQuitterParam;
}

function doSubmitComposant(nomComposant,nomForwardComposant)
{
	setValeurChamp("nomComposantDestination",nomComposant);
	setValeurChamp("nomForwardComposantDestination",nomForwardComposant);
	doSubmit("gotoComposant");
}
function doSubmitComposantArbre(nomComposant,nomForwardComposant)
{
	setValeurChamp("nomComposantDestination",nomComposant);
	setValeurChamp("nomForwardComposantDestination",nomForwardComposant);
	doSubmitArbre("gotoComposant");
}
function doSubmitComposantArbreSansValidation(nomComposant,nomForwardComposant)
{
	setValeurChamp("nomComposantDestination",nomComposant);
	setValeurChamp("nomForwardComposantDestination",nomForwardComposant);
	doSubmitArbre("gotoComposantSansValidation");
}
function enregistrer()
{
	doSubmitArbre("enregistrerSimulation");
}
function enregistrerEtFermer()
{
	doSubmitArbre("enregistrerEtFermerSimulation");
}
function enregistrerEtAccueil()
{
	doSubmitArbre("enregistrerEtFermerSimulationEtAccueil");
}
function fermerSimulation()
{
	doSubmitArbre("fermerSimulation");
}
function fermerSimulationEtAccueil()
{
	doSubmitArbre("fermerSimulationEtAccueil");
}
function enregistrerEtQuitter()
{
	doSubmitArbre("enregistrerEtQuitterSimulation");
}
function quitterSimulation()
{
	doSubmitArbre("fermerEtQuitterSimulation");
}
function fermer()
{
	confirmationOuiNonAnnuler(messageFermer,"enregistrerEtFermer()","fermerSimulation()");
}
function fermerEtAccueil()
{
	confirmationOuiNonAnnuler(messageFermer,"enregistrerEtAccueil()","fermerSimulationEtAccueil()");
}

function quitterComposantSeul()
{
	confirmationOuiNonAnnuler(messageQuitterComposantSeul,"enregistrerEtQuitter()","quitterSimulation()");
}

function quitter()
{		
	confirmationOuiNon(messageQuitter,actionQuitterRedirectionValider,"");					
}
function fermetureDefinitive()
{
	if (window.opener && urlRedirection!=null && urlRedirection.length>0)
		window.opener.location=urlRedirection;
	doSubmitArbre('fermetureDefinitive');
}
function quitterRedirection()
{
	if (window.opener && urlRedirection!=null && urlRedirection.length>0)
		window.opener.location=urlRedirection;
	document.location=urlActionQuitter;
}
/*******************************************/
/*                                         */
/*          retraite.js             	   */
/*                                         */
/*******************************************/
/************/
/* Editions */
/************/
function gestionEditions(clientId,coupleId,dossierId,utilisateurId,idEdition)
{
	gestionEditionsSelonParam(clientId,coupleId,dossierId,utilisateurId,null,idEdition);
}
function gestionEditionsGroupe(clientId,coupleId,dossierId,utilisateurId,idGroupe)
{
	var idsGroupes=new Array();
	idsGroupes[0]=idGroupe;
	gestionEditionsSelonParam(clientId,coupleId,dossierId,utilisateurId,idsGroupes,null);
}
function ouvreEdition(idEdition,clientId,coupleId,dossierId,utilisateurId)
{
	var idsEditions=new Array();
	idsEditions[0]=idEdition;
	ouvreEditions(null,idsEditions,clientId,coupleId,dossierId,utilisateurId);
}
function tabContient(tabGroupe, idGroupe)
{
	for (var i=tabGroupe.length-1;i>=0;i--)
	{
		if (tabGroupe[i]==idGroupe)
		{
			return true;
		}
	}
	return false;
}
function detailConseiller(conseillerId)
{
	actionPopupSimple("DetailConseillerWebEntryAction","detailConseiller.titre","400", "400", "No", "No","conseillerId",conseillerId);
}

/*********************/
/* carriere-actuelle */
/*********************/
function setTailleTableauHistorique()
{
	var	height = getWindowHeight(top);
	// La hauteur ci-dessous a été déterminée approximativement	pour convenir
	// à la	majorité des cas et	surtout	conserver l'existant en	800*600.
	var	historiqueHeight = 0.12*height;
	var	scrollHistorique = getElementFromDocument("scrollTableauHistorique");
	if (scrollHistorique)
	{
		scrollHistorique.style.height=historiqueHeight + "px";
	}
}
function isPeriodeCarriereActuelleIncomplete()
{
	var csp=getValeurChamp("cspActuelle");
	var anneeDebutActivite=getValeurChamp("anneeDebutActivite");
	var revenusDebutCarriere=getValeurChamp("revenusDebutCarriere");
	var revenusActuels=getValeurChamp("revenusActuels");
	if ((csp==null)||(csp=="")
		||(anneeDebutActivite==null)||(anneeDebutActivite=="")
		||(revenusDebutCarriere==null)||(revenusDebutCarriere=="")
		||(revenusActuels==null)||(revenusActuels==""))
	{
		return true;
	}
	else
	{
		return false;
	}			
}
function changementCarriereMultiCSPOui()
{
	doSubmit("changementCarriereMultiCSPOui");
}

/********************/
/* estimation-bilan */
/********************/
function calculFinancementRetraite()
{
	var	retraiteSouhaitee=getValeurChamp("retraiteSouhaitee");
	if (retraiteSouhaitee!="")
	{
		setValeurChamp("resultatEstAffiche","true");
	}
	doSubmit('calculFinancementRetraite');
}
function showHideResultat()
{
	getElementFromDocument("divRetraiteSouhaiteeCalculette").style.display='InLine';
	getElementFromDocument("divPopupMesureDejaPrise").style.display='InLine';
	getElementFromDocument("divMessagePriseRDV").style.display='none';
	getElementFromDocument("divBoutonOk").style.display='block';
	getElementFromDocument("divBoutonModifier").style.display='none';
	getElementFromDocument("divTotalRevenusRetraite").style.display='none';
	getElementFromDocument("divResultat").style.display='none';
	getElementFromDocument("divBoutonSuivant").style.display='none';
	setValeurChamp("resultatEstAffiche","false");
	getChamp("retraiteSouhaitee").readOnly=false;
	getChamp("retraiteSouhaitee").className="champNumeriqueSaisissable";
	getElementFromDocument("spanRetraiteSouhaitee").className="champLibelle";
	if(getChamp("tauxRetraiteSouhaitee"))
	{
		getChamp("tauxRetraiteSouhaitee").readOnly=false;
		getChamp("tauxRetraiteSouhaitee").className="champNumeriqueSaisissable";
	}	
	if(getElementFromDocument("spanTauxRetraiteSouhaitee"))
	{
		getElementFromDocument("spanTauxRetraiteSouhaitee").className="champLibelle";
	}
	getChamp("montantMesuresPersonnelles").readOnly=false;
	getChamp("montantMesuresPersonnelles").className="champNumeriqueSaisissable";
	getElementFromDocument("spanMontantMesuresPersonnelles").className="champLibelle";
}
function effacerDetailMesuresPrises()
{
	getElementFromDocument("detailMesuresPersonnellesSaisiAEffacer").value=true;
}
function afficheTexte(periodeCarriereId,idCsp,typeRetraite,indexCspSelectionnee)
{
	if (periodeCarriereId)
	{
		setValeurChamp("periodeCarriereId",periodeCarriereId);
	}
	if (idCsp)
	{
		setValeurChamp("idCsp",idCsp);
	}
	setValeurChamp("typeRetraite",typeRetraite);
	if (indexCspSelectionnee !=	null)
	{
		setValeurChamp("indexCspSelectionnee",indexCspSelectionnee);
	}
	doSubmit("rafraichir");
}
function changementProfilReversion()
{
	doSubmit("changementProfilReversion");
}

/********************************/
/* ajout-modif-periode-carriere */
/********************************/
function getChampRevenusAnnuels(indice)
{
	return getChamp("indexListeDonneesCotisationParAnnee["+indice+"].montantRevenus");
}
function isJusquaAgeRetraite()
{
	var radioValue=getCheckedRadioValue("jusquaAgeRetraite");
	if (radioValue=="true")
	{
		return true;
	}
	else
	{
		return false;
	}
	return false;
}
function isUnePartiePeriodeStrictementAvant(annee)
{
	var anneeDebutStr=getValeurChamp("anneeDebutPeriode");
	if (anneeDebutStr=="")
	{
		return false;
	}
	else
	{
		var anneeDebut=parseInt(anneeDebutStr);
		if (anneeDebut>=annee)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
}
function areAnneesDebutEtFinEgales()
{
	var anneeDebutStr=getValeurChamp("anneeDebutPeriode");
	var anneeFinStr=getAnneeFinReelleStr();
	if ((anneeDebutStr!="")&&(anneeFinStr!=""))
	{
		var anneeDebut=parseInt(anneeDebutStr);
		var anneeFin=parseInt(anneeFinStr);
		if (anneeDebut==anneeFin)
		{
			return true;
		}
	}
	return false;
}
function isTableauRevenusDephase()
{
	if (getValeurChamp("tableauRevenusARegenerer")=="true")
	{
		return true;
	}
	else
	{
		return false;
	}
}
function resetDivComplementCSP()
{
	getElementFromDocument("divComplementSalarie").style.display='none';
	getElementFromDocument("divComplementFonctionnaire").style.display='none';
	getElementFromDocument("divComplementArtIndusComm").style.display='none';
	getElementFromDocument("divComplementAvocat").style.display='none';
	getElementFromDocument("divComplementArchitecte").style.display='none';
	getElementFromDocument("divComplementAuxiliaireMedical").style.display='none';
	getElementFromDocument("divComplementDentiste").style.display='none';
	getElementFromDocument("divComplementMedecin").style.display='none';
	getElementFromDocument("divComplementNotaire").style.display='none';
	getElementFromDocument("divComplementChefExploitation").style.display='none';
	getElementFromDocument("divComplementGeometreExpert").style.display='none';
	getElementFromDocument("divComplementOfficierMinisterielVeterinaire").style.display='none';
}
function majLayoutPage()
{
	majLibelleAnneeDebutPeriode();
	majLibelleAnneeFinPeriode();
	majDivRevenusFinPeriode();
	majLayoutSpecifiqueCSP();
}
function majLibelleAnneeDebutPeriode()
{
	var anneeDebut=getValeurChamp("anneeDebutPeriode");
	var zoneLibelleAnneeDebut=getElementFromDocument("spanLibelleAnneeDebutPeriode");
	zoneLibelleAnneeDebut.innerHTML=anneeDebut;
}
function majLibelleAnneeFinPeriode()
{
	var anneeFinReelle=getAnneeFinReelleStr();
	var zoneLibelleAnneeFin=getElementFromDocument("spanLibelleAnneeFinPeriode");
	zoneLibelleAnneeFin.innerHTML=anneeFinReelle;
}
function majDivRevenusFinPeriode()
{
	if (areAnneesDebutEtFinEgales())
	{
		setValeurChamp("revenusFinPeriode",getValeurChamp("revenusDebutPeriode"));
		getElementFromDocument("divRevenusFinPeriodeZoneLibelle").style.display='none';
		getElementFromDocument("divRevenusFinPeriodeZoneTexte").style.display='none';
	}
	else
	{
		getElementFromDocument("divRevenusFinPeriodeZoneLibelle").style.display='InLine';
		getElementFromDocument("divRevenusFinPeriodeZoneTexte").style.display='InLine';
	}
}
function changeAnneeDebutPeriode()
{
	setValeurChamp("tableauRevenusARegenerer","true");
	majLibelleAnneeDebutPeriode();
	majDivRevenusFinPeriode();
}
function changeAnneeFinPeriode()
{
	checkRadio("jusquaAgeRetraite", "false");
	if (!isJusquaAgeRetraite())
	{
		setValeurChamp("tableauRevenusARegenerer","true");
		majLibelleAnneeFinPeriode();
		majDivRevenusFinPeriode();
	}
}
function clickRadioJusquaRetraiteOui()
{
	setValeurChamp("anneeFinPeriode","");
	setValeurChamp("tableauRevenusARegenerer","true");
	majLibelleAnneeFinPeriode();
	majDivRevenusFinPeriode();
}
function clickRadioJusquaRetraiteNon()
{
	changeAnneeFinPeriode();
}
function changeRevenusDebutPeriode()
{
	setValeurChamp("tableauRevenusARegenerer","true");
	if (areAnneesDebutEtFinEgales())
	{
		setValeurChamp("revenusFinPeriode",getValeurChamp("revenusDebutPeriode"));
	}
}
function changeRevenusFinPeriode()
{
	setValeurChamp("tableauRevenusARegenerer","true");
}
function changeCSP()
{
	setValeurChamp("tableauRevenusARegenerer","true");
	majLayoutSpecifiqueCSP();
	changementCSP();
}
function activeCalculAutomatiqueRevenusAnnuels()
{
	doSubmit("calculAutomatiqueRevenusAnnuels");
}
function clickOngletDetailPeriode()
{
	majOngletSelectionne("ongletDetailPeriode");
}
function clickOngletRevenus()
{
	if (isTableauRevenusDephase())
	{
		doSubmit("ongletRevenus");
	}
	else
	{
		majOngletSelectionne("ongletRevenus");
	}
}

/*******************/
/* choix-solutions */
/*******************/
function checkSolutionChoisieIdCourant(i,typeProduit,nomDivProduitsEpargne,nomImage)
{
	var checkboxObject = getElementFromMultiBox(document.forms[0].listeSolutionsChoisiesIds,i);
	if(checkboxObject)
	{
		if (checkboxObject.checked)
			checkboxObject.checked=false;
		else if (!checkboxObject.disabled)
			checkboxObject.checked=true;
		manageProduitOnClick(checkboxObject,typeProduit,nomDivProduitsEpargne,nomImage); 
	}  
}	 
function majSolutionAssociee(cocheEpargne,indiceSolution,typeProduit,nomDivProduitsEpargne,nomImage)
{
	if (cocheEpargne.checked)
	{
		var checkboxObject = getElementFromMultiBox(document.forms[0].listeSolutionsChoisiesIds,indiceSolution);
		if(checkboxObject)
		{
			if (!checkboxObject.disabled && !checkboxObject.checked)
			{
				checkboxObject.checked=true;
				manageProduitOnClick(checkboxObject,typeProduit,nomDivProduitsEpargne,nomImage); 
			}
		}	 
	}
}
function afficherPopupQuestionTNS()
{
	var largeur=500;
	var hauteur=400;
	actionPopup("PopupQuestionTNSWebEntryAction", "choixSolutions.bloc.financementRetraite.internet", largeur, hauteur,"No","No");
}
function changementPriseEnCompteFiscalite()
{
	if ( getElementFromDocument("priseEnCompteFiscaliteTmp").checked )
	{
		getElementFromDocument("priseEnCompteFiscalite").value="true";
	}
	else
	{
		getElementFromDocument("priseEnCompteFiscalite").value="false";
	}
}

/*****************/
/* preconisation */
/*****************/
function groupePrecedent() 
{
	doSubmit('groupePrecedent');
}
function groupeSuivant() 
{
	doSubmit('groupeSuivant');
}
/* Permet de masquer les réponses dès que l'on y a répondu*/
function hideQuestion(id)
{
}
/* Fonction	interne	(pb	avec setTimeout()...)*/
function hide()
{
}
/* Affiche ou cahce	les	réponse	si on clique sur la	question */
function showHideQuestion(id)
{
}
function checkSolutionChoisieIdCourant(i,idProduit)
{ 
}

/*********************/
/* dipsonible-fiscal */
/*********************/
function afficherTableauResultat(afficher)
{
	var	display	= "none";
	if (afficher) display="inline";
	getElementFromDocument("tableauResultat").style.display=display;
}
function calculerGain()
{
	doSubmit('calculGainFiscalSocial');
}

function isArtisantOuCommercantOuIndustriel(csp)
{
	var	isCspAOuCOuI;
	switch (csp)
	{
		case "311":
		case "330":
		case "310":
		case "350":
			isCspAOuCOuI = 1;
		break;

		default:
			isCspAOuCOuI = 0;
	}
	return isCspAOuCOuI;
	
}
function isTNS(csp)
{
	var	isCspTNS;
	switch (csp)
	{

		case "331":
		case "311":
		case "307":
		case "339":
		case "341":
		case "343":
		case "304":
		case "312":
		case "306":
		case "313":
		case "319":
		case "320":
		case "350":
		case "308":
		case "314":
		case "318":
		case "317":
		case "309":
		case "315":
		case "321":
		case "316":
		case "333":
		case "334":
		case "335":
		case "336":
		case "340":
		case "342":
		case "305":
		case "324":
		case "332":
		case "330":
		case "310":
		case "323":
		case "344":
		case "345":
		case "346":
		case "349":
			isCspTNS = 1;
		break;

		default:
			isCspTNS = 0;
	}
	return isCspTNS;
}


function isSalarie(csp)
{
	if (!isTNS(csp))
	{
		// si la CSP n'est pas TNS,	on retourne	vrai à condition que ce	ne soit	pas	fonctionnaire ou militaire ou vide
		switch (csp)
		{
			case "300":
			case "303":
			case "327":
			case "328":
				return 0;
				break;
			default:
				return 1;
		}
	}
	else
	{
		// si la CSP est TNS, on retourne systématiquement faux	!
		return 0;
	}
}

function isSalarieCadreOuNonCadre(csp)
{
	var	isCspSalarieCadreOuNonCadre;
	switch (csp)
	{
		case "301":
		case "302":
			isCspSalarieCadreOuNonCadre = 1;
		break;

		default:
			isCspSalarieCadreOuNonCadre = 0;
	}
	return isCspSalarieCadreOuNonCadre;
}

function isFonctionnaireOuMilitaire(csp)
{
	var	result;
	switch (csp)
	{
		case "303":
		case "327":
		case "328":
			result = 1;
			break;
		default:
			result = 0;
	}
	return result;
}

function isAgri(csp)
{
	switch (csp)
	{
		case "324":
		case "323":
		case "344":
		case "345":
		case "346":
			return true;
		default	:
			return false;
	}
}

function getInfoBulleCalculetteRevenus(intervenant)
{
	var	infoBulle=infoBulleCalculetteRevenuActiviteBeneficeImposable;
	if (intervenant=="client")
	{
		if (isTNS(getValeurChamp("cspActuelle")))
			infoBulle=infoBulleCalculetteBeneficeImposable;
		else
			infoBulle=infoBulleCalculetteRevenuActivite;
	}
	if (intervenant=="conjoint")
	{
		if (isTNS(getValeurChamp("cspActuelleConjoint")))
			infoBulle=infoBulleCalculetteBeneficeImposable;
		else
			infoBulle=infoBulleCalculetteRevenuActivite;
	}
	return infoBulle;
}

function ouvrirPopupDetails()
{
	var largeur=650;
	var hauteur=280;
	actionPopup("PopupDetailsDisponiblesWebEntryAction", "popupDetailsDisponibles.titre", largeur, hauteur,"No","No");
}

function checkConjointCollaborateurClient()
{
	if (getChamp("conjointCollaborateurClientAffichage").checked)
	{
		setValeurChamp("conjointCollaborateurClient","true");
	}
	else
	{
		setValeurChamp("conjointCollaborateurClient","false");
	}	
	changementCSP('client');
}
function checkConjointCollaborateurConjoint()
{
	if (getChamp("conjointCollaborateurConjointAffichage").checked)
	{
		setValeurChamp("conjointCollaborateurConjoint","true");
	}
	else
	{
		setValeurChamp("conjointCollaborateurConjoint","false");
	}		
	changementCSP('conjoint');
}

/***********************/
/* simulation-solution */
/***********************/
function ouvrirPopupParametrage(idSolution)  
{
	actionPopup("ParametrageWebEntryAction", "popupParametrage.titre", 650,390,"No","No", "solutionId", idSolution);
}
function ouvrirPopupParametrageAbondement(idSolution)  
{
	actionPopup("ParametrageAbondementWebEntryAction", "popupParametrageAbondement.titre", 650, 390, "No", "No", "solutionId", idSolution);
}
function ouvrirPopupComparatif(idSolution) 
{
	validerEtActionPopup("ComparatifWebEntryAction", "popupComparatif.titre", 750,560,"No","No", "solutionId", idSolution);
}
function getChampSolution(nomChamp,noSolution) 
{
	return getChamp("indexListeSolutionsRetraite["+noSolution+"]."+nomChamp);   
}
function getValeurChampSolution(nomChamp,noSolution)
{
	return getValeurChamp("indexListeSolutionsRetraite["+noSolution+"]."+nomChamp);
}
function setValeurChampSolution(nomChamp,noSolution, valeur)
{
	setValeurChamp("indexListeSolutionsRetraite["+noSolution+"]."+nomChamp, valeur);
}
function setAndFormatCurrencyValeurChampSolution(nomChamp,noSolution,valeur)
{
	setValeurChampSolution(nomChamp,noSolution,currencyFormat(valeur+""));
} 
function changeAffichageVI(noSolution) 
{
	var champCheckbox=getChampSolution("existanceVersementInitial",noSolution);   
	if (champCheckbox)
	{
		var divVersementInitial=getElementFromDocument("divVersementInitial"+noSolution);
		if (divVersementInitial)
		{
			if (champCheckbox.checked)
			{
				divVersementInitial.style.visibility='visible';
				champSaisie = getChampSolution("montantVersementInitial",noSolution); 
				if(champSaisie)
				{
					champSaisie.focus();
				}
			}
			else
			{
				divVersementInitial.style.visibility='hidden';
				setValeurChamp("indexListeSolutionsRetraite["+noSolution+"].montantVersementInitial","");
				doSubmit("calculer");
			}
		}
	}
}
function solutionOptimaleDemandee()
{
	doSubmit("solutionOptimaleDemandee");   
}
function accesDisponibleFiscalDemande()
{
	doSubmit("accesDisponibleFiscalDemande");   
}
function switchTypeSortie(idSolution)
{
	document.forms[0].action=document.forms[0].action+"?idSolution="+idSolution;
	doSubmit("switchTypeSortie");
}

/***********************/
/* disponible-fiscal   */
/***********************/
function dispoFiscalChangementCSP(estimationRetraiteConjoint, existeSolutionMadelin, habiliteIRVMadelinPrevoyance, cspConjointInactif, libelleSeparator)
{
	cspConjointInactif = parseInt(cspConjointInactif);
	estimationRetraiteConjoint = (estimationRetraiteConjoint=="true");
	existeSolutionMadelin = (existeSolutionMadelin);
	habiliteIRVMadelinPrevoyance = (habiliteIRVMadelinPrevoyance);

	var effacerCellMadelinPrevoyanceClientFormulaire=false;
	var effacerCellMadelinPrevoyanceConjointFormulaire=false;
	var effacerCellMadelinPrevoyanceClientTotalDisponible=false;
	var effacerCellMadelinPrevoyanceConjointTotalDisponible=false;
	var	elementBeneficeImposable=getElementFromDocument("spanBeneficeImposable");
	var	libelleBeneficeAAfficher;
	var	cspActuelleClient =	getValeurChamp("cspActuelle");
	var	isClientTNS=isTNS(cspActuelleClient);
	var	isClientAgri=isAgri(cspActuelleClient);
	var	isClientSalarie=isSalarie(cspActuelleClient);
	var	isClientSalarieCadreOuNC=isSalarieCadreOuNonCadre(cspActuelleClient);
	var	isClientAOuCOuI=isArtisantOuCommercantOuIndustriel(cspActuelleClient);
	var isClientConjointCollaborateur = false;
	var isConjointConjointCollaborateur = false;
	
	if (estimationRetraiteConjoint)
	{
		var	cspActuelleConjoint	= getValeurChamp("cspActuelleConjoint");
		var	isConjointTNS=isTNS(cspActuelleConjoint);
		var	isConjointAgri=isAgri(cspActuelleConjoint);
		var	isConjointSalarie=isSalarie(cspActuelleConjoint);
		var	isConjointSalarieCadreOuNC=isSalarieCadreOuNonCadre(cspActuelleConjoint);
		var	isConjointAOuCOuI=isArtisantOuCommercantOuIndustriel(cspActuelleConjoint);
	}
	else
	{
		var	isConjointTNS=false;
		var	isConjointAgri=false;
		var	isConjointSalarie=false;
		var	isConjointSalarieCadreOuNC=false;
		var	isConjointAOuCOuI=false;
	}

	var	libelleBeneficeClient=getLibelleBenefice(isClientTNS);
//	if (cspActuelleClient==cspConjointInactif)
//	{
//		libelleBeneficeClient = ""
//	}

	if (estimationRetraiteConjoint)
	{
		var	libelleBeneficeConjoint=getLibelleBenefice(isConjointTNS);
		if (cspActuelleConjoint==cspConjointInactif)
		{
			libelleBeneficeConjoint = ""
		}
	}

	if ( (isClientTNS) && (isConjointTNS) )
	{
		// Pas de frais reels
		getElementFromDocument("ligneFraisReelsFormulaire").style.display="none";
		setValeurChamp("fraisReelsClient", "");
		if (estimationRetraiteConjoint)
		{
			setValeurChamp("fraisReelsConjoint", "");
		}
	}
	else
	{
		// Gestion affichage frais reels
		getElementFromDocument("ligneFraisReelsFormulaire").style.display="inline";
		if (!(isClientTNS))
		{
			getElementFromDocument("cellFraisReelsClientFormulaire").style.visibility="";
		}
		else
		{
			getElementFromDocument("cellFraisReelsClientFormulaire").style.visibility="hidden";
			setValeurChamp("fraisReelsClient", "");
		}
		if (estimationRetraiteConjoint)
		{
			if (!(isConjointTNS))
			{
				getElementFromDocument("cellFraisReelsConjointFormulaire").style.visibility="";
			}
			else
			{
				getElementFromDocument("cellFraisReelsConjointFormulaire").style.visibility="hidden";
				setValeurChamp("fraisReelsConjoint", "");
			}
		}
	}

	if (getElementFromDocument("ligneConjointCollaborateurFormulaire"))
	{
		if (estimationRetraiteConjoint)
		{
			var checkBoxClient = getChamp("conjointCollaborateurClientAffichage");	
			var checkBoxConjoint = getChamp("conjointCollaborateurConjointAffichage");	
			if ( ( (isClientAOuCOuI) && (isConjointSalarieCadreOuNC) ) || ( (isConjointAOuCOuI) && (isClientSalarieCadreOuNC) ) )
			{
				// Gestion affichage des cases a cocher pour les conjoints collaborateur à temps partiel
				getElementFromDocument("ligneConjointCollaborateurFormulaire").style.display="inline";
				if ( (isClientAOuCOuI) && (isConjointSalarieCadreOuNC) )
				{
					getElementFromDocument("cellConjointCollaborateurClientFormulaire").style.visibility="hidden";
					getElementFromDocument("cellConjointCollaborateurConjointFormulaire").style.visibility="";
					if (checkBoxClient)
					{
						checkBoxClient.checked=false;
						setValeurChamp("conjointCollaborateurClient", "false");
					}
				}
	
				if ( (isConjointAOuCOuI) && (isClientSalarieCadreOuNC) )
				{
					getElementFromDocument("cellConjointCollaborateurClientFormulaire").style.visibility="";
					getElementFromDocument("cellConjointCollaborateurConjointFormulaire").style.visibility="hidden";
					if (checkBoxConjoint)
					{
						checkBoxConjoint.checked=false;
						setValeurChamp("conjointCollaborateurConjoint", "false");
					}
				}
			}
			else
			{
				if (checkBoxClient)
				{
					checkBoxClient.checked=false;
					setValeurChamp("conjointCollaborateurClient", "false");
				}
				if (checkBoxConjoint)
				{
					checkBoxConjoint.checked=false;
					setValeurChamp("conjointCollaborateurConjoint", "false");
				}
	
				// Pas de possibilité de conjoint collaborateur à temps partiels
				getElementFromDocument("ligneConjointCollaborateurFormulaire").style.display="none";
			}
			if (checkBoxClient && checkBoxClient.checked)
			{
				isClientConjointCollaborateur = true;
			}
			if (checkBoxConjoint && checkBoxConjoint.checked)
			{
				isConjointConjointCollaborateur = true;
			}
		}
		else
		{
			getElementFromDocument("ligneConjointCollaborateurFormulaire").style.display="none";
		}
	}
	
	if ( isClientTNS ||	isConjointTNS)
	{
		if ( isClientTNS || isClientConjointCollaborateur)
		{
			// on affiche les champs madelins du client
			getElementFromDocument("cellMadelinClientFormulaire").style.visibility="";
			if(habiliteIRVMadelinPrevoyance=='true')
			{
				if ( isClientAgri )
				{
					getElementFromDocument("cellMadelinPrevoyanceClientFormulaire").style.visibility="hidden";
					setValeurChamp("cotisationMadelinPrevoyanceClient",	"");
					effacerCellMadelinPrevoyanceClientFormulaire=true;
				}
				else
				{
					getElementFromDocument("cellMadelinPrevoyanceClientFormulaire").style.visibility="";
				}
			}
			if (existeSolutionMadelin=='true')
			{
				getElementFromDocument("cellMadelinClientTotalDisponible").style.visibility="";
				if(habiliteIRVMadelinPrevoyance=='true')
				{
					if ( isClientAgri )
					{
						getElementFromDocument("cellMadelinPrevoyanceClientTotalDisponible").style.visibility="hidden";
						effacerCellMadelinPrevoyanceClientTotalDisponible=true;
					}
					else
					{
						getElementFromDocument("cellMadelinPrevoyanceClientTotalDisponible").style.visibility="";
					}
				}
			}
		}
		else
		{
			// on cache	les	champs madelins	du clients
			getElementFromDocument("cellMadelinClientFormulaire").style.visibility="hidden";
			setValeurChamp("cotisationMadelinClient",	"");
			if(habiliteIRVMadelinPrevoyance=='true')
			{
				getElementFromDocument("cellMadelinPrevoyanceClientFormulaire").style.visibility="hidden";
				setValeurChamp("cotisationMadelinPrevoyanceClient",	"");
				effacerCellMadelinPrevoyanceClientFormulaire=true;
			}
			if (existeSolutionMadelin=='true')
			{
				getElementFromDocument("cellMadelinClientTotalDisponible").style.visibility="hidden";
				if(habiliteIRVMadelinPrevoyance=='true')
				{
					getElementFromDocument("cellMadelinPrevoyanceClientTotalDisponible").style.visibility="hidden";
					effacerCellMadelinPrevoyanceClientTotalDisponible=true;
				}
			}
		}
		if (estimationRetraiteConjoint)
		{
			if ( isConjointTNS || isConjointConjointCollaborateur)
			{
				getElementFromDocument("cellMadelinConjointFormulaire").style.visibility="";
				if(habiliteIRVMadelinPrevoyance=='true')
				{
					if ( isConjointAgri )
					{
						getElementFromDocument("cellMadelinPrevoyanceConjointFormulaire").style.visibility="hidden";
						setValeurChamp("cotisationMadelinPrevoyanceConjoint", "");
						effacerCellMadelinPrevoyanceConjointFormulaire=true;
					}
					else
					{
						getElementFromDocument("cellMadelinPrevoyanceConjointFormulaire").style.visibility="";
					}
				}
				if (existeSolutionMadelin=='true')
				{
					getElementFromDocument("cellMadelinConjointTotalDisponible").style.visibility="";
					if(habiliteIRVMadelinPrevoyance=='true')
					{
						if ( isConjointAgri )
						{
							getElementFromDocument("cellMadelinPrevoyanceConjointTotalDisponible").style.visibility="hidden";
							effacerCellMadelinPrevoyanceConjointTotalDisponible=true;
						}
						else
						{
							getElementFromDocument("cellMadelinPrevoyanceConjointTotalDisponible").style.visibility="";
						}
					}
				}
			}
			else
			{
				// on cache	les	champs madelins	du conjoint
				getElementFromDocument("cellMadelinConjointFormulaire").style.visibility="hidden";
				setValeurChamp("cotisationMadelinConjoint", "");
				if(habiliteIRVMadelinPrevoyance=='true')
				{
					getElementFromDocument("cellMadelinPrevoyanceConjointFormulaire").style.visibility="hidden";
					setValeurChamp("cotisationMadelinPrevoyanceConjoint", "");
					effacerCellMadelinPrevoyanceConjointFormulaire=true;
				}
				if (existeSolutionMadelin=='true')
				{
					getElementFromDocument("cellMadelinConjointTotalDisponible").style.visibility="hidden";
					if(habiliteIRVMadelinPrevoyance=='true')
					{
						getElementFromDocument("cellMadelinPrevoyanceConjointTotalDisponible").style.visibility="hidden";
						effacerCellMadelinPrevoyanceConjointTotalDisponible=true;
					}
				}
			}
		}

		var	libelleMadelin = getLibelleMadelin(isClientAgri, isConjointAgri, isClientTNS, isConjointTNS);
		getElementFromDocument("libelleMadelinFormulaire").innerHTML=libelleMadelin;
		if (existeSolutionMadelin=='true')
		{
			getElementFromDocument("libelleMadelinTotalDisponible").innerHTML=libelleMadelin;
		}

		getElementFromDocument("ligneMadelinFormulaire").style.display="inline";
		if(habiliteIRVMadelinPrevoyance=='true')
		{
			getElementFromDocument("ligneMadelinPrevoyanceFormulaire").style.display="inline";
		}
		if (existeSolutionMadelin=='true')
		{
			getElementFromDocument("ligneMadelinTotalDisponible").style.display="inline";
			if(habiliteIRVMadelinPrevoyance=='true')
			{
				getElementFromDocument("ligneMadelinPrevoyanceTotalDisponible").style.display="inline";
			}
		}

		if (effacerCellMadelinPrevoyanceClientFormulaire)
		{
			if ( (estimationRetraiteConjoint && effacerCellMadelinPrevoyanceConjointFormulaire)
				|| (!estimationRetraiteConjoint) )
			{
				getElementFromDocument("ligneMadelinPrevoyanceFormulaire").style.display="none";
			}
		}
		if (effacerCellMadelinPrevoyanceClientTotalDisponible)
		{
			if ( (estimationRetraiteConjoint && effacerCellMadelinPrevoyanceConjointTotalDisponible)
				|| (!estimationRetraiteConjoint) )
			{
				getElementFromDocument("ligneMadelinPrevoyanceTotalDisponible").style.display="none";
			}
		}
	}
	else
	{

		// pas de madelin
		getElementFromDocument("ligneMadelinFormulaire").style.display="none";
		if(habiliteIRVMadelinPrevoyance=='true')
		{
			getElementFromDocument("ligneMadelinPrevoyanceFormulaire").style.display="none";
		}
		
		if (existeSolutionMadelin=='true')
		{
			getElementFromDocument("ligneMadelinTotalDisponible").style.display="none";
			if(habiliteIRVMadelinPrevoyance=='true')
			{
				getElementFromDocument("ligneMadelinPrevoyanceTotalDisponible").style.display="none";
			}
		}
	}

	if (isClientSalarie	|| isConjointSalarie)
	{
		// Gestion de l'affichage pour la cotisation article 83
		getElementFromDocument("ligneArt83Formulaire").style.display="inline";
		if (isClientSalarie)
		{
			getElementFromDocument("cellArt83ClientFormulaire").style.visibility="";
		}
		else
		{
			getElementFromDocument("cellArt83ClientFormulaire").style.visibility="hidden";
			setValeurChamp("cotisationArt83Client",	"");
		}
		if (estimationRetraiteConjoint)
		{
			if (isConjointSalarie)
			{
				getElementFromDocument("cellArt83ConjointFormulaire").style.visibility="";
			}
			else
			{
				getElementFromDocument("cellArt83ConjointFormulaire").style.visibility="hidden";
				setValeurChamp("cotisationArt83Conjoint", "");
			}
		}
	}
	else
	{
		// Pas de cotisation Article 83
		getElementFromDocument("ligneArt83Formulaire").style.display="none";
		setValeurChamp("cotisationArt83Client",	"");
		if (estimationRetraiteConjoint)
		{
			setValeurChamp("cotisationArt83Conjoint", "");
		}
	}

	if (getValeurChamp("estimationRetraiteConjoint")=="true")
	{
		if (libelleBeneficeClient==libelleBeneficeConjoint)
		{
			libelleBeneficeAAfficher=libelleBeneficeClient;
		}
		else
		{
			if ((libelleBeneficeClient!="") && (libelleBeneficeConjoint!=""))
			{
				libelleBeneficeAAfficher=libelleBeneficeClient + " "+ libelleSeparator + " " + libelleBeneficeConjoint;
			}
			else
			{
				if (libelleBeneficeClient=="")
				{
					libelleBeneficeAAfficher=libelleBeneficeConjoint;
				}
				if (libelleBeneficeConjoint=="")
				{
					libelleBeneficeAAfficher=libelleBeneficeClient;
				}
			}

		}
	}
	else
	{
		libelleBeneficeAAfficher=libelleBeneficeClient;
	}
	elementBeneficeImposable.innerHTML=libelleBeneficeAAfficher;
}



