function affiche(spanIn)
{
	if (spanIn == '')
	return;

	var spanToDisplay = document.getElementById(spanIn);
	//spanCampagne.style.display="none";
	//spanOrganisation.style.display="none";
	spanLieuDAction.style.display="none";
	spanContractant.style.display="none";
	spanAction.style.display="none";
	spanCertificat.style.display="none";
	spanVisite.style.display="none";
	spanTablBord.style.display="none";


	//ospanCampagne.className="deactive";
	ospanOrganisation.className="deactive";
	ospanLieuDAction.className="deactive";
	ospanContractant.className="deactive";
	ospanAction.className="deactive";
	ospanCertificat.className="deactive";
	ospanVisite.className="deactive";
	ospanTablBord.className="deactive";
	
	var spanAAfficher=document.getElementById('spanAffiche');
	spanAAfficher.value=spanIn;


	spanToDisplay.style.display="";


	var ongletToDisplay=document.getElementById("o"+spanIn);
	ongletToDisplay.className="active";
}

function afficheSpanBilan(spanIn)
{
	if (spanIn == '')
		return;

	var spanToDisplay = document.getElementById(spanIn);
	spanPresentationAF.style.display="none";
	spanSecteurActivite.style.display="none";
	spanAutreSecteur.style.display="none";
	spanAutreSituation.style.display="none";

	ospanPresentationAF.className="deactive";
	ospanSecteurActivite.className="deactive";
	ospanAutreSecteur.className="deactive";
	ospanAutreSituation.className="deactive";
	
	var spanAAfficher=document.getElementById('spanBilanAffiche');
	spanAAfficher.value=spanIn;

	spanToDisplay.style.display="";

	var ongletToDisplay=document.getElementById("o"+spanIn);
	ongletToDisplay.className="active";
}


function affiche2(spanIn)
{
	if (spanIn == '')
	return;

	if (spanIn == 'pageContractant'){
		spanPaiement.style.display="none";
		spanImmatriculationInsee.style.display="none";
		spanRegimeFiscal.style.display="none";
		spanContractant.style.display="none"; //pour masquer le datagrid
		spanProjet.style.display="none";

		pageContractant.style.display="";
		spanEtablissement.style.display="";
		return;
	}


	var spanToDisplay = document.getElementById(spanIn);
	spanPaiement.style.display="none";
	spanEtablissement.style.display="none";
	spanImmatriculationInsee.style.display="none";
	spanRegimeFiscal.style.display="none";
	spanProjet.style.display="none";
	
	

	spanToDisplay.style.display="";

	ospanEtablissement.className="deactive";
	ospanPaiement.className="deactive";
	ospanImmatriculationInsee.className="deactive";
	ospanRegimeFiscal.className="deactive";
	ospanProjet.className="deactive";
	

	var spanAAfficherContractant=document.getElementById('spanAfficheContractant');
	spanAAfficherContractant.value=spanIn;


	var ongletToDisplay=document.getElementById("o"+spanIn);
	ongletToDisplay.className="active";


}


function afficheContractant(spanIn)
{

	if (spanIn == '')
	return;

	var spanToDisplay = document.getElementById(spanIn);
	spanPaiement.style.display="none";
	spanIdentite.style.display="none";
	spanElementsFinanciers.style.display="none";
	spanCompte.style.display="none";

	spanToDisplay.style.display="";

	ospanIdentite.className="deactive";
	ospanPaiement.className="deactive";
	ospanElementsFinanciers.className="deactive";
	//ospanCompte.className="deactive";
	var spanAAfficherContractant=document.getElementById('spanContractantAAfficher');
	spanAAfficherContractant.value=spanIn;

	var ongletToDisplay=document.getElementById("o"+spanIn);
	ongletToDisplay.className="active";
}

function afficheControle(spanIn)
{
	if (spanIn == '')
	return;

	var spanToDisplay = document.getElementById(spanIn);
	spanInformation.style.display="none";
	spanDocuments.style.display="none";
	spanCommentaire.style.display="none";

	spanToDisplay.style.display="";

	ospanInformation.className="deactive";
	ospanDocuments.className="deactive";
	ospanCommentaire.className="deactive";

	var spanAAfficherControle=document.getElementById('spanControleAAfficher');
	spanAAfficherControle.value=spanIn;


	var ongletToDisplay=document.getElementById("o"+spanIn);
	ongletToDisplay.className="active";
}

/*
* debut des fonctions d'AJAX
*/
function getReturnData( data , statusCode , statusMessage)
{
	ActiverClick();
	if( statusCode != AJForm.STATUS['SUCCESS'] )
	{
		alert( "Message " + statusMessage );
		return true;
	}
	//AJFORM succeeded.
	else {
		if(data.split('<separateur>')[3])
		{
			var span = document.getElementById("ctl0_MenuLayout_DateCreationAction");
			var laDateCreation = document.createTextNode(data.split('<separateur>')[3]+' ');
			if(span.childNodes[0])
			span.removeChild(span.childNodes[0]);
			span.appendChild(laDateCreation);
		}

		if(data.split('<separateur>')[4])
		{
			var span = document.getElementById("ctl0_MenuLayout_DateModificationAction");
			var laDateModif = document.createTextNode(data.split('<separateur>')[4]+' ');
			if(span.childNodes[0])
			span.removeChild(span.childNodes[0]);
			span.appendChild(laDateModif);
		}

		if(data.split('<separateur>')[5])
		{
			var span = document.getElementById("ctl0_MenuLayout_ActionCreePar");
			var nom = document.createTextNode(data.split('<separateur>')[5]);
			if(span.childNodes[0])
			span.removeChild(span.childNodes[0]);
			span.appendChild(nom);
		}
		
		if(data.split('<separateur>')[6] == 1)  // si l'action est validée
		{
			GriserStatut();
		}
		
		if(data.split('<separateur>')[2])
		{
			if(data.split('<separateur>')[1])
			{
				document.mainForm.ctl0$MenuLayout$idAction.value = data.split('<separateur>')[1];
				document.mainForm.ctl0$MenuLayout$modification.value = "1";
				//top.arbreAE.location.reload();
			}
			var tab = data.split('<separateur>')[2];
			//(tab.length<60)
			var spanEnr = document.getElementById("MessageEnr");
				spanEnr.style.display="";
				Myalert(tab);
			/*else
				alert(tab);*/
		}
		else
		{
			alert("Impossible d'effectuer l'opération demandée.");
		}
		//alert(data);

	}//fin else
}

function afficherResultatRecherche( data , statusCode , statusMessage) {
	//AJFORM failed. Submit form normally.
	if( statusCode != AJForm.STATUS['SUCCESS'] )
	{
		alert( statusMessage );
		return true;
	}
	//AJFORM succeeded.
	else
	{
		if (data != "")
		{
			var url = "?page=ActesDEngagement&Action="+data;

			var lienRedirection = document.getElementById ("redirigeRecherche");
			lienRedirection.href=url;
			lienRedirection.click();
		}
		else
		{
			alert ("Aucun résultat trouvé");
		}

	}
}

/**
* Méthode qui sera appelée sur le click du bouton enregisté
*/
function saveAE()
{
	DesactiverClick();
	thisForm = document.mainForm;
	old_action=thisForm.action;
	thisForm.action="?page=saveAE";
	var old_action;

	thisForm.ajform_submit();
	thisForm.action=old_action;
}


/**
* Méthode qui sera appelée sur le click du bouton enregisté
*/

function verifierTauxHoraire()
{
/*	var tauxCentre;
	var tauxEtp;
	var ES;
	var DS;
	var thisForm = document.mainForm;
	dureeEtp= thisForm.ctl0$MenuLayout$DureeTF.value;
	dureeCentre= thisForm.ctl0$MenuLayout$DureeTE.value;
	ES=thisForm.ctl0$MenuLayout$EffectifMin.value;
	DS=thisForm.ctl0$MenuLayout$DureeMax.value;

	if ( (parseFloat(dureeCentre) + parseFloat(dureeEtp))  < parseFloat(ES) * parseFloat(DS) ){
		return confirm("Les heures totales sont inférieures à l'effectif stagiaire multiplié par la durée maximale.\nVoulez vous continuer?") ;
	}*/
	return true;

}

function verifierDateDemandePremierAcompte()
{/*
	var thisForm = document.mainForm;
	var dateDemandeParOF = thisForm.ctl0$MenuLayout$dateDemandeParOF.value;
	
	var demande = document.getElementById('ctl0_MenuLayout_versementPremierAccompteOui');
	var dejaDemande = document.getElementById('ctl0_MenuLayout_DemandePremierAcompteFaite');
	
	//si oui est coché et il y avait pas de demande avant
	
	if((demande.checked) && (dejaDemande.value == '0')) {
	
	var dateDebutDeroulement = thisForm.ctl0$MenuLayout$DateDebutDeroulement.value;
	var dateDebutDeroulementReel = thisForm.ctl0$MenuLayout$DateDebutReelle.value;
	
	//si les valeurs ne sont pas mentinné on ne fait pas de test.
	if(!(dateDemandeParOF) || !(dateDebutDeroulement)) 
	{
	alert("La date de demande de premier acompte ou la date de début de formation n'est pas renseignés.");
	return false;
	}
	
	//si la date de début réel est mentionné on la prend.
	if(dateDebutDeroulementReel) 
	{
		var tabDate = dateDebutDeroulementReel.split("/");
		var dateDebut= new Date(tabDate[2],tabDate[1],tabDate[0]);
	}
	else
	{
		var tabDate = dateDebutDeroulement.split("/");
		var dateDebut= new Date(tabDate[2],tabDate[1],tabDate[0]);
	}

	var tabDate = dateDemandeParOF.split("/");
	var dateFin= new Date(tabDate[2],tabDate[1],tabDate[0]);

	var diffDate = (dateFin.getTime() - dateDebut.getTime())/(60*60*24*1000);  

	//tester si la date de demande du premier acompte est supérieur à un mois par rapport à la date de début de l'AE
	if((parseFloat(diffDate) > 30) || (parseFloat(diffDate) < 0))
	return confirm("La date de demande du premier acompte doit être au plus tard un mois après le début de formation.\nVoulez vous continuer ?")
	
	}
*/
	return true;
}




function verifyFormAE()
{
	if((verifierTauxHoraire()) &&  (verifierDateDemandePremierAcompte()))
	saveAE();
}


function onEnregistrerClick()
{
	if(confirm('Etes-vous sûr de vouloir enregistrer cette Action ?'))
	{
		var btn=document.getElementsByName("btn_valide");
		btn[0].value='0';
	
		verifyFormAE();
		
		if(thisForm.ctl0_MenuLayout_ComboCampagnes)
			thisForm.ctl0_MenuLayout_ComboCampagnes.disabled = 'disabled';
			
		var creation=document.getElementsByName("creation");
		creation[0].value = '1';
	}
}

function Ajout(ajout)
{
	if(ajout)
	{
		var creation=document.getElementsByName("creation");
		creation[0].value ='1';	
	}
}

function ActiverAjout()
{
	var creation=document.getElementsByName("creation");
	if(creation[0].value=='1')
		return true;
	alert('Veuillez enregistrer l\'action de formation'); 
	return false;
}


function onValiderClick()
{
	if(confirm('Etes-vous sûr de vouloir valider cette Action ?'))
	{
		var btn=document.getElementsByName("btn_valide");
		btn[0].value='1';
		
		verifyFormAE();
		
		if(thisForm.ctl0_MenuLayout_ComboCampagnes)
			thisForm.ctl0_MenuLayout_ComboCampagnes.disabled = 'disabled';
		
		var creation=document.getElementsByName("creation");
		creation[0].value = '1';
	}
}


function DesactiverClick()
{
	var divToDisplay = top.document.getElementById("chargement");
	divToDisplay.style.display="block";
	document.onmousedown = InterditClick;
}


function GriserStatut()
{
	var thisForm = document.mainForm;
	//if(thisForm.StatutValide.checked==true)
		thisForm.ctl0$MenuLayout$StatutValide.disabled="false";

	if(!thisForm.ctl0$MenuLayout$Avance[0].checked)
	{
		thisForm.ctl0_MenuLayout_AvanceNull.disabled="false";
		thisForm.ctl0_MenuLayout_AvanceFor.disabled="false";
		thisForm.ctl0_MenuLayout_AvanceFac.disabled="false";
	}
	var span = document.getElementById("ctl0_MenuLayout_Statut");
		
	if(span.childNodes[0])
		span.removeChild(span.childNodes[0]);
	var status = document.createTextNode("Statut : Validé");
	span.appendChild(status);
}

function ActiverClick()
{
	var divToDisplay = top.document.getElementById("chargement");
	divToDisplay.style.display="none";
	document.onmousedown = "";
}


function InterditClick(e)
{
	var msg = "Veuillez patienter pendant le traitement de votre demande ...";
	if ((navigator.appName == 'Netscape') && 	(e.which == 1))
	{
		alert(msg);
		return false;
	}
	else if ((navigator.appName == 'Microsoft Internet Explorer') && (event.button == 1))
	{
		alert(msg);
		return false;
	}
	return true;
}


////////////////////// SIRET EN JS ////////////////////////

/*
* @name EstSiretValide
*
* @param     Le code SIRET dont on veut vérifier la validité.
*
* @return     Un booléen qui vaut 'true' si le code SIRET passé en
* paramètre est valide, false sinon.
*/

function EstSiretValide(sender,parameter)
{
	var estValide;
	if ( (parameter.length != 14) || (isNaN(parameter)) )
	estValide = false;
	else {
		// Donc le SIRET est un numérique à 14 chiffres
		// Les 9 premiers chiffres sont ceux du SIREN (ou RCS), les 4suivants
		// correspondent au numéro d'établissement
		// et enfin le dernier chiffre est une clef de LUHN.
		var somme = 0;
		var tmp;
		for (var cpt = 0; cpt<parameter.length; cpt++) {
			if ((cpt % 2) == 0) { // Les positions impaires : 1er, 3è, 5è,etc...
			tmp = parameter.charAt(cpt) * 2; // On le multiplie par 2
			if (tmp > 9)
			tmp -= 9;    // Si le résultat est supérieur à 9, on lui soustrait 9
			}
			else
			tmp = parameter.charAt(cpt);
			somme += parseInt(tmp);
		}
		if ((somme % 10) == 0)
		estValide = true; // Si la somme est un multiple de 10 alors le SIRET est valide
		else
		estValide = false;
	}
	return estValide;
}



////////////////////// RIB EN JS ////////////////////////

function EstRIBValide(sender,parameter)
{
	var inputElems;
	inputElems = document.getElementsByTagName("input");

	//extraire le numéro de ligne
	for( i=0; i < inputElems.length; i++)
	{
		var inputName = inputElems[i].name;
		if( inputName.search(/ListeContractants/)==16)
		{
			row = inputName.split("$");
			var ctli = row[3];
		}
	}

	var bqe=document.getElementById("ctl0_MenuLayout_ListeContractants_"+ctli+"_CodeBanque");
	var gui=document.getElementById("ctl0_MenuLayout_ListeContractants_"+ctli+"_CodeGuichet");
	var cpt=document.getElementById("ctl0_MenuLayout_ListeContractants_"+ctli+"_NumeroCompte");

	var bqe=bqe.value;
	var gui=gui.value;
	var cpt=cpt.value;



	if (cpt && gui && bqe)
	{
		cpt = cpt.toUpperCase();

		// Conversion du numero de compte en chiffres
		var tab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		var tab1="123456789123456789234567890123456789".split("");

		while (cpt.match(/\D/) != null)
		cpt=cpt.replace(/\D/, tab1[tab.indexOf(cpt.match(/\D/))]);
		var cp=parseInt    (cpt, 10);

		//Calcul clé RIB
		a=bqe%97;
		a=a*100000+parseInt(gui, 10);
		a=a%97;
		a=a*Math.pow(10, 11) + cp;
		a=a%97
		a=a*100;
		a=a%97
		a=97-a;
		
		if(parameter == a)
		return true;
	}
	else
	{
		return false;
	}
}

/*
* fin des fonctions d'AJAX
*/


//permet d'ouvrir une fenêtre centré.
function openwindow(url)
{
	/*window.open(url, "",
	"width=460,height=170,scrollbars=0,left=" +
	((screen.width - 460)/2) + ",top=" + ((screen.height - 150)/2) );*/
	openwindow2(url,460,200);
}

//permet d'ouvrir une fenêtre centré.
function openwindow2(url,width,height)
{
	window.open(url, "",
	"width="+width+",height="+height+",scrollbars=yes,left=" +
	((screen.width - width)/2) + ",top=" + ((screen.height - height)/2) );
}

// ouvre une fenetre 
function openwindowFull(url)
{
	window.open(url, "test",
	"fullscreen=yes,toolbar=yes,scrollbars=yes,resizable=yes");
}


function remplirLieuAction(choix) {

	var inputElems;

	if(document.GeoForm.codeInsee.value)
	{
		inputElems = opener.document.getElementsByTagName("input");

		//extraire le numéro de ligne
		for( i=0; i < inputElems.length; i++)
		{
			var inputName = inputElems[i].name;

			if(inputName.search(/DataListLieuDAction/)==16)
			{	
				row = inputName.split("$");
				var ctli = row[3];
			}
		}
		if(choix=="Etudiant")
		{
		var laVille = opener.document.getElementById("ctl0_MenuLayout_DataListLieuDAction_"+ctli+"_EtudiantVilleLieuDAction");
		var leCodepostal = opener.document.getElementById("ctl0_MenuLayout_DataListLieuDAction_"+ctli+"_codePostalLieuDAction");
		var leCodeInsee = opener.document.getElementById("ctl0_MenuLayout_DataListLieuDAction_"+ctli+"_codeINSEELieuDAction");

		laVille.value = document.GeoForm.ville.value;
		leCodepostal.value = document.GeoForm.codePostal.value;
		leCodeInsee.value = document.GeoForm.codeInsee.value;
		}
	}
	self.close();
	return false;
}

function remplirContractant() {

	var inputElems;

	if(document.GeoForm.NumeroSiret.value)
	{
		inputElems = opener.document.getElementsByTagName("input");

		//extraire le numéro de ligne
		for( i=0; i < inputElems.length; i++)
		{
			var inputName = inputElems[i].name;

			if(inputName.search(/ListeContractants/)==16)
			{	
				row = inputName.s
				
			}
				
		}
				
	}
				
}

function IsNbreValide(chaine)
{
	var regExpChiffres=/^[0-9]+(,|.)?[0-9]*$/g;
	return matchRegularExpression(chaine,regExpChiffres);
}

function matchRegularExpression(valeur, regularExpression)
{
	var resultat = valeur.match(regularExpression);
	if(resultat!=null && resultat.length==1) return true;
	else return false;
}

/*function calculTVAEtTTC(nomZoneHT,nomZoneTVA,nomZoneTTC,nomCheckTVA,tauxTVA)
{
		if(nomCheckTVA.checked)
		{
			var valeur = nomZoneHT.value;
			valeur = arrondir(valeur,2);
			var TVA = parseFloat(nomZoneHT.value.replace(',','.'))*parseFloat(tauxTVA);
			var TTC = parseFloat(valeur.replace(',','.'))+parseFloat(TVA);
			TVA = arrondir(TVA,2);
			TTC = arrondir(TTC,2);
			nomZoneTVA.value= TVA;
			nomZoneTTC.value= TTC;
			nomZoneHT.value = valeur;
		}
		else
		{
			nomZoneTVA.value= 0,00;
			nomZoneHT.value = arrondir(nomZoneHT.value,2);
			nomZoneTTC.value= arrondir(nomZoneHT.value,2);
		};
}*/

function calculTVAEtTTC(nomZoneHT,nomZoneTVA,nomZoneTTC,tauxTVA)
{
		if(parseFloat(tauxTVA)>0)
		{
			var valeur = nomZoneHT.value;
			valeur = arrondir(valeur,2);
			var TVA = parseFloat(nomZoneHT.value.replace(',','.'))*parseFloat(tauxTVA);
			var TTC = parseFloat(nomZoneHT.value.replace(',','.'))+parseFloat(TVA);
			TVA = arrondir(TVA,2);
			TTC = arrondir(TTC,2);
			nomZoneTVA.value= TVA;
			nomZoneTTC.value= TTC;
			nomZoneHT.value = valeur;
		}
		else
		{
			nomZoneTVA.value= 0,00;
			nomZoneHT.value = arrondir(nomZoneHT.value,2);
			nomZoneTTC.value= arrondir(nomZoneHT.value,2);
		};
}

function calculTVAEtHT(nomZoneHT,nomZoneTVA,nomZoneTTC,tauxTVA)
{
		if(parseFloat(tauxTVA)>0)
		{
			var valeur = nomZoneTTC.value;
			valeur = parseFloat(valeur);
			var valTTC = parseFloat(nomZoneTTC.value.replace(',','.'));
			var HT =valTTC/(1+parseFloat(tauxTVA));
			var TVA = valTTC-HT;
			TVA = arrondir(TVA,2);
			HT = arrondir(HT,2);
			nomZoneTVA.value= TVA;
			//nomZoneTTC.value= TTC;
			nomZoneHT.value = HT;
		}
		else
		{
			nomZoneTVA.value= '0,00';
			nomZoneHT.value = nomZoneTTC.value;
			//nomZoneTTC.value= '0,00';
		};
}

function calculCoutHoraire(volumeGlobal,duree,effectif,coutTotal,coutHoraire)
{
	try
	{
		valVolumeGlobal = document.getElementById(volumeGlobal);
		valDuree = document.getElementById(duree);
		valEffectif = document.getElementById(effectif);
		
		valCouTotal = parseFloat(coutTotal.value.replace(',','.'));
		if(!valCouTotal)
		{
			coutHoraire.value = 0,00;
			return;
		}
		if(valVolumeGlobal)
		{
			if(valVolumeGlobal.value)
			{
				valVolumeGlobal = parseFloat(valVolumeGlobal.value.replace(',','.'));
				cout = valCouTotal/valVolumeGlobal;
				cout = arrondir(cout,2);
				coutHoraire.value = cout;
				return;
			}
			else
			{
				coutHoraire.value = 0,00;
				return;
			}
		}
		if(valDuree && valEffectif)
		{
		
			valDuree = parseFloat(valDuree.value.replace(',','.'));
			valEffectif = parseFloat(valEffectif.value.replace(',','.'));
			if(valDuree && valEffectif)
			{
				cout = valCouTotal/valEffectif/valDuree;
				cout = arrondir(cout,2);
				coutHoraire.value = cout;
				return;
			}
			else
			{
				coutHoraire.value = '0,00';
				return;
			}
		}
	}
	catch(erreur)
	{
	}
}


function recalculCoutTotal(volumeGlobal,duree,effectif,coutHoraire,coutTotal)
{
	try
	{
		valVolumeGlobal = document.getElementById(volumeGlobal);
		valDuree = document.getElementById(duree);
		valEffectif = document.getElementById(effectif);
		valCouHoraire = parseFloat(coutHoraire.value.replace(',','.'));
		
	
		if(valVolumeGlobal)
		{
			if(valVolumeGlobal.value)
			{
				valVolumeGlobal = parseFloat(valVolumeGlobal.value.replace(',','.'));
				valCouTotal = valCouHoraire * valVolumeGlobal;
				valCouTotal = arrondir(valCouTotal,2);
				coutTotal.value = valCouTotal;
				return;
			}
			else
			{
				coutTotal.value.value = '0,00';
				return;
			}
		}
		
		if(valDuree && valEffectif)
		{
			valDuree = parseFloat(valDuree.value.replace(',','.'));
			valEffectif = parseFloat(valEffectif.value.replace(',','.'));
			if(valDuree && valEffectif)
			{
				valCouTotal = valCouHoraire * valEffectif * valDuree;
				valCouTotal = arrondir(valCouTotal,2);
				coutTotal.value = valCouTotal;
				return;
			}
			else
			{
				coutTotal.value = '0,00';
				return;
			}
		}
	}
	catch(erreur)
	{
	}
}

function calculCouTotal(totalCentre,totalEtp,total)
{
		if(totalCentre.value || totalCentre.value)
		{
			var totalCentre = parseFloat(totalCentre.value.replace(',','.'));
			var totalEtp = parseFloat(totalEtp.value.replace(',','.'));
			total.value = arrondir(totalEtp+totalCentre,2);
		}
		else
		{
			total.value = '0,00';
		}
}


function calculPrixTotal(idZonneCoutHoraire,idZonneDureeTotale,idZonnePrixTotal)
{
		ZonneCoutHoraire = document.getElementById(idZonneCoutHoraire);
		ZonneDureeTotale = document.getElementById(idZonneDureeTotale);
		ZonnePrixTotal = document.getElementById(idZonnePrixTotal);
		if(ZonneCoutHoraire && ZonneDureeTotale)
		{
			coutHoraire = parseFloat(ZonneCoutHoraire.value.replace(',','.'));
			dureeTotale = parseFloat(ZonneDureeTotale.value.replace(',','.'));
			coutHoraire = arrondir(coutHoraire,2);
			dureeTotale = arrondir(dureeTotale,2);
			
			if(coutHoraire && dureeTotale)
			{
				coutHoraire = parseFloat(coutHoraire.replace(',','.'));
				dureeTotale = parseFloat(dureeTotale.replace(',','.'));
				ZonnePrixTotal.value = arrondir(coutHoraire*dureeTotale,2);
			}
			else
				ZonnePrixTotal.value = '0,00';
			
			if(ZonneCoutHoraire.value)
				ZonneCoutHoraire.value = arrondir(coutHoraire,2);
			else
				ZonneCoutHoraire.value = '0,00';
			if(ZonneDureeTotale.value)
				ZonneDureeTotale.value = arrondir(dureeTotale,2);
			else
				ZonneDureeTotale.value = '0,00';
		}
		else
			ZonnePrixTotal.value = '0,00';
}




function calculPrixTotalCollectif(idZonneCoutHoraire,idZonneDureeTotale,idZonneEffectif,idZonnePrixTotal)
{
		ZonneCoutHoraire = document.getElementById(idZonneCoutHoraire);
		ZonneDureeTotale = document.getElementById(idZonneDureeTotale);
		Zonneeffectif = document.getElementById(idZonneEffectif);
		ZonnePrixTotal = document.getElementById(idZonnePrixTotal);
		if(ZonneCoutHoraire && ZonneDureeTotale && Zonneeffectif)
		{
			coutHoraire = parseFloat(ZonneCoutHoraire.value.replace(',','.'));
			dureeTotale = parseFloat(ZonneDureeTotale.value.replace(',','.'));
			effectif = parseFloat(Zonneeffectif.value.replace(',','.'));
			coutHoraire = arrondir(coutHoraire,2);
			dureeTotale = arrondir(dureeTotale,2);
			effectif = arrondir(effectif,2);
			if(coutHoraire && dureeTotale && effectif)
			{
				coutHoraire = parseFloat(coutHoraire.replace(',','.'));
				dureeTotale = parseFloat(dureeTotale.replace(',','.'));
				effectif = parseFloat(effectif.replace(',','.'));
				ZonnePrixTotal.value = arrondir(coutHoraire*dureeTotale*effectif,2);
			}
			else
				ZonnePrixTotal.value = '0,00';
			if(ZonneCoutHoraire.value)
				ZonneCoutHoraire.value = arrondir(coutHoraire,2);
			else
				ZonneCoutHoraire.value = '0,00';
			if(ZonneDureeTotale.value)
				ZonneDureeTotale.value = arrondir(dureeTotale,2);
			else
				ZonneDureeTotale.value = '0,00';
		}
		else
			ZonnePrixTotal.value = '0,00';
}

function remplirTableauResume()
{
	//resumCoutCentre = document.getElementById('RESUME_COUT_HORAIRE_CENTRE');
	//coutCentre = document.getElementById('COUT_HORAIRE_CENTRE');

	resumTotalCentreHT = document.getElementByName('RESUME_TOTAL_CENTRE_HT');
	resumTotalCentreTVA = document.getElementById('RESUME_TOTAL_CENTRE_TVA');
	resumTotalCentreTTC = document.getElementById('RESUME_TOTAL_CENTRE_TTC');
	totalCentreHT = document.getElementByName('TOTAL_CENTRE_HT');
	totalCentreTVA = document.getElementById('TOTAL_CENTRE_TVA');
	totalCentreTTC = document.getElementById('TOTAL_CENTRE_TTC');
	
	//resumCoutEtp = document.getElementById('RESUME_COUT_HORAIRE_ETP');
	//coutEtp = document.getElementById('COUT_HORAIRE_ENTREPRISE');
	
	
	resumTotalEtpHT = document.getElementById('RESUME_TOTAL_ETP_HT');
	resumTotalEtpTVA = document.getElementById('RESUME_TOTAL_ETP_TVA');
	resumTotalEtpTTC = document.getElementById('RESUME_TOTAL_ETP_TTC');
	totalEtpHT = document.getElementById('SOUS_TOTAL_ENTREPRISE_HT');
	totalEtpTVA = document.getElementById('SOUS_TOTAL_ENTREPRISE_TVA');
	totalEtpTTC = document.getElementById('SOUS_TOTAL_ENTREPRISE_TTC');
	

	resumTotalHT = document.getElementById('RESUME_TOTAL_HT');
	resumTotalTVA = document.getElementById('RESUME_TOTAL_TVA');
	resumTotalTTC = document.getElementById('RESUME_TOTAL_TTC');
	totalHT = document.getElementById('TOTAL_HT');
	totalTVA = document.getElementById('TOTAL_TVA');
	totalTTC = document.getElementById('TOTAL_TTC');

	//resumCoutCentre.value = coutCentre.value;
	resumTotalCentreHT.value = totalCentreHT.value;
	resumTotalCentreTVA.value = totalCentreTVA.value;
	resumTotalCentreTTC.value = totalCentreTTC.value;
	//resumCoutEtp.value = coutEtp.value;
	resumTotalEtpHT.value = totalEtpHT.value;
	resumTotalEtpTVA.value = totalEtpTVA.value;
	resumTotalEtpTTC.value = totalEtpTTC.value;
	resumTotalHT.value = totalHT.value;
	resumTotalTVA.value = totalTVA.value;
	resumTotalTTC.value = totalTTC.value;
}

function calculSomme(idZonneText1,idZonneText2,idZonneTexteTotal)
{
	zonne1 = document.getElementById(idZonneText1);
	zonne2 = document.getElementById(idZonneText2);
	zonneTexteTotal = document.getElementById(idZonneTexteTotal);
	 
	if(zonne1.value && zonne2.value)
	{
		//zonne1.value = arrondir(zonne1.value,2);
		//zonne2.value = arrondir(zonne2.value,2);
		zonneTexteTotal.value = parseFloat(zonne1.value.replace(',','.'))+parseFloat(zonne2.value.replace(',','.'));
		zonneTexteTotal.value = arrondir(zonneTexteTotal.value,2);
	}
	else if(zonne1.value)
	{
		zonne1.value = arrondir(zonne1.value,2);
		zonneTexteTotal.value = zonne1.value;	
	}
	else if(zonne2.value)
	{
		zonne2.value = arrondir(zonne2.value,2);
		zonneTexteTotal.value = zonne2.value;	
	}
	else
	{
		zonne1.value = '0,00';
		zonne2.value = '0,00';
		zonneTexteTotal.value = '0,00';	
	}
}
function calculSommeInteger(idZonneText1,idZonneText2,idZonneTexteTotal)
{
	zonne1 = document.getElementById(idZonneText1);
	zonne2 = document.getElementById(idZonneText2);
	zonneTexteTotal = document.getElementById(idZonneTexteTotal);
	 
	if(zonne1.value && zonne2.value)
	{
		zonneTexteTotal.value = parseFloat(zonne1.value)+parseFloat(zonne2.value);
	}
	else if(zonne1.value)
	{
		zonneTexteTotal.value = zonne1.value;	
	}
	else if(zonne2.value)
	{
		zonneTexteTotal.value = zonne2.value;	
	}
	else
	{
		zonne1.value = '0';
		zonne2.value = '0';
		zonneTexteTotal.value = '0';	
	}
}

function calculTotalEmploi(nomzonne1,nomzonne2,nomzonne3,nomzonne4,total)
{
	try
	{
		valTotal = 0;
		zonne1 = document.getElementById(nomzonne1);
		zonne2 = document.getElementById(nomzonne2);
		zonne3 = document.getElementById(nomzonne3);
		zonne4 = document.getElementById(nomzonne4);
		zonneTotal = document.getElementById(total);
		total = 0;
		//if(!IsNbreValide(zonne1.value) || !zonne1.value);
		if (zonne1.value && IsNbreValide(zonne1.value))
			total =total + parseFloat(zonne1.value.replace(',','.'));
	//	if(!IsNbreValide(zonne2.value) || !zonne2.value);
		if (zonne2.value && IsNbreValide(zonne2.value))			
			total = total + parseFloat(zonne2.value.replace(',','.'));
		//if(!IsNbreValide(zonne3.value) || !zonne3.value);
		if (zonne3.value && IsNbreValide(zonne3.value))
			total = total + parseFloat(zonne3.value.replace(',','.'));
		//if(!IsNbreValide(zonne4.value) || !zonne4.value):
		if (zonne4.value && IsNbreValide(zonne4.value))
			total = total + parseFloat(zonne4.value.replace(',','.'));
		
		zonneTotal.value = total;
	}
	catch(erreur)
	{
	//alert(erreur);
	}
}

function textLimit(textearea,taille) 
{
	var message = document.getElementById(textearea.id + 'Taille');

	if(textearea.value.length > taille) 
	{ 
		//alert ("Vous avez dépassé le nombre maximum de caractères : " + taille); 
		textearea.value = textearea.value.substr(0,taille); 
		return false; 
	}
	
	if(textearea.value.length == taille && message) 
		message.style.display='';
	else if(message)
		message.style.display='none';
}


function Myalert(msg)
{
	var spanEnr = document.getElementById("MessageEnr");
	spanEnr.style.display="";
	var t = msg.split('-');
	var lent = t.length;
	var maxwidth = t[0].length+10;
	var ligne = 0;
	
	newmsg = "<center><b>"+t[0]+"</b></center>";
	for(i=1;i<lent;i++)
	{
		newmsg+="<br>-"+t[i];
		if(t[i].length>maxwidth)
			maxwidth = t[i].length;
		if(t[i].length>100)
			ligne++;
	}
	ejs_al_largeur = 6*maxwidth;
	if(ejs_al_largeur>600)
		ejs_al_largeur=600;
	
	document.getElementById("ejs_al_box2").style.height = 15*(lent+5+ligne);
	
	ejs_al_start(newmsg);	
}

function ejs_al_close()
{
	if(document.getElementById)
	{
		document.getElementById("ejs_al_box2").style.visibility = 'hidden'
		ejs_al_deplace();
		var spanEnr = document.getElementById("MessageEnr");
		spanEnr.style.display="none";
		window.location.replace( "?page=POF.RechercheDesActions");
	}
}

function ejs_al_start(msg)
{
	ejs_al_mess = msg;
	ejs_al_box2 = 0;
	if(document.getElementById)
	{
		document.getElementById("ejs_al_box2").style.visibility = 'visible'
		ejs_al_deplace();
	}
}

function ejs_al_deplace()
{
	document.getElementById("ejs_al_box2").style.left = ejs_al_posX-(ejs_al_box2/2)-5;
	document.getElementById("ejs_al_box2").style.width = ejs_al_box2+10;
	ejs_al_box2 += 15;
	if(ejs_al_box2<ejs_al_largeur)
	setTimeout("ejs_al_deplace()",1);
	else
	{
		bt_annule='';
		bt_ok='ejs_al_close()';
		message_confirmation = '';
		Ok='OK';
		document.getElementById("ejs_al_box2").innerHTML = '<br />'+ejs_al_mess+'<BR><BR><CENTER>'+message_confirmation+'<B><A HREF=javascript:'+bt_ok+'><FONT COLOR='+ejs_al_police_color+'>'+Ok+'</FONT></A></B></CENTER>'
	}
}

function recuperationAvance(mntHT,mntTVA,mntTTC,recuperAvance,ancienRecup,tauxTVA,avanceResteARecuperer)
{
	zonneMntHT = document.getElementById(mntHT);
	zonneMntTVA = document.getElementById(mntTVA);
	zonneMntTTC = document.getElementById(mntTTC);
	zonneRecupAvance = document.getElementById(recuperAvance);
	zonneAncienRecup = document.getElementById(ancienRecup);
	zonneTauxTVA = document.getElementById(tauxTVA);
	zonneAvanceResteARecuperer = document.getElementById(avanceResteARecuperer);
	
	avance = parseFloat(zonneRecupAvance.value.replace(',','.'));
	ancienAvance = parseFloat(zonneAncienRecup.value.replace(',','.'));
	montantTTC = parseFloat(zonneMntTTC.value.replace(',','.'));
	maxAvance = parseFloat(zonneAvanceResteARecuperer.value);
	
	diff = avance - ancienAvance;
	if(montantTTC<diff || avance>maxAvance)
	{
		alert("Vous avez dépassé le montant d'avance à récupérer sur cette période");
		zonneRecupAvance.value = ancienAvance;
		return;
	}
	
	montantTTC = montantTTC - (avance - ancienAvance);
	
	zonneMntTTC.value = arrondir(montantTTC,2);
	
	// mise à jour de la valeur de ancien récupération
	zonneAncienRecup.value = zonneRecupAvance.value;
	calculTVAEtHTAvance(zonneMntHT,zonneMntTVA,zonneMntTTC,zonneTauxTVA.value);
}

function calculTVAEtHTAvance(nomZoneHT,nomZoneTVA,nomZoneTTC,tauxTVA)
{
		if(parseFloat(tauxTVA)>0)
		{
			var valeur = nomZoneTTC.value;
			valeur = arrondir(valeur,2);
			var TVA = parseFloat(nomZoneTTC.value.replace(',','.'))*parseFloat(tauxTVA)/(parseFloat(tauxTVA)+1);
			var HT = parseFloat(nomZoneTTC.value.replace(',','.'))/(parseFloat(tauxTVA)+1);
			TVA = arrondir(TVA,2);
			HT = arrondir(HT,2);
			nomZoneTVA.value= TVA;
			nomZoneTTC.value= valeur;
			nomZoneHT.value = HT;
		}
		else
		{
			nomZoneTVA.value= 0,00;
			nomZoneHT.value = arrondir(nomZoneTTC.value,2);
			nomZoneTTC.value= arrondir(nomZoneTTC.value,2);
		};
}

function CalculPoucentageFoad(dureeCentre,dureeFoad,pourcentage)
{
	var ddf = document.getElementById(dureeFoad);
	var dtc = document.getElementById(dureeCentre);
	var prFoad = document.getElementById(pourcentage);
	
	if(dtc.value != 0){
	prctge = (ddf.value * 100) / dtc.value ;
	prctge = arrondir(prctge,2);
	
	prFoad.value = prctge ;
	return;
	}
	else{
	prFoad.value = '0,00' ;
	return;
	}
	
}
function cachePanelFoad(idPanel){
   foadPanel = document.getElementById(idPanel);
   if(foadPanel)
   	foadPanel.style.display='none' ;
 
 }
function afficherPanelFoad(idPanel){

   foadPanel = document.getElementById(idPanel);
   if(foadPanel)
  	foadPanel.style.display='' ;
 
 }
function panelDetailCertif(idPanel){
	 myPanel = document.getElementById(idPanel);
	 aucunCertf = document.getElementById('ctl0_MenuLayout_actionFormationObject_caracteristiques_aucunCertif');
	 if(myPanel && aucunCertf.checked == 1){
	 	myPanel.style.display='none';
	 }
	 else
 		myPanel.style.display='';	
}
 
 function detailVisibilite(idDetail,idAutres){
 detail = document.getElementById(idDetail);
 autre = document.getElementById(idAutres);
 if(autre.checked == 0)
 	detail.style.display='none';
 else
 	detail.style.display='';
 }
 
 function calculEffectif(volume,parcours,effectif)
 {
 	var vol = document.getElementById(volume);
	var par = document.getElementById(parcours);
	var effe = document.getElementById(effectif);
	
	if(par.value != 0){
		effectif = vol.value / par.value ;
		effectif_arrondit = Math.round(effectif);
		
		effe.value = effectif_arrondit ;
		if(effectif_arrondit!=effectif)
		{
			var span = document.getElementById("warning_effectif");
			var text = document.createTextNode("Attention, l'effectif théorique affiché est arrondi. La valeur calculée est "+effectif.toString());
			if(span.childNodes[0])
				span.removeChild(span.childNodes[0]);
			span.appendChild(text);
		}
		else
		{
			var span = document.getElementById("warning_effectif");
			var text = document.createTextNode("");
			if(span.childNodes[0])
				span.removeChild(span.childNodes[0]);
			span.appendChild(text);
		}
		return;
	}
	else{
		effe.value = '0' ;
		return;
	}
 }
 
 function calculPrix(volume,prix,prix_1,prix_2,prix_3)
 {
 	var vol = parseFloat(document.getElementById(volume).value.replace(',','.').replace(' ',''));
	var prix = document.getElementById(prix);
	
	if(vol<=15000)
	 	prix.value = document.getElementById(prix_1).value;
	else
	{
		if(vol<=50000)
			prix.value = document.getElementById(prix_2).value;
		else
			prix.value = document.getElementById(prix_3).value;
	}
 }
 
 function calculMontantHor(volume,prix,montant)
 {
 	var vol = document.getElementById(volume);
	var prix = document.getElementById(prix);
	var montant = document.getElementById(montant);
	
	result = parseFloat(vol.value.replace(',','.').replace(' ',''))*parseFloat(prix.value.replace(',','.').replace(' ',''));
	montant.value = arrondir(result,2);
 }
 
 function calculMontant(mt_centre,mt_etp,mt_ttc,mt_tva,mt_ht,to_tva)
 {
 	var mt_centre = document.getElementById(mt_centre);
	var mt_etp = document.getElementById(mt_etp);
	var mt_ttc = document.getElementById(mt_ttc);
	var mt_tva = document.getElementById(mt_tva);
	var mt_ht = document.getElementById(mt_ht);
	var to_tva = document.getElementById(to_tva);
	
	ttc = parseFloat(mt_centre.value.replace(',','.').replace(' ',''))+parseFloat(mt_etp.value.replace(',','.').replace(' ',''));
	ht = ttc/(1+parseFloat(to_tva.value));
	tva = ttc-ht;
	
	mt_ttc.value = arrondir(ttc,2);
	mt_ht.value = arrondir(ht,2);
	mt_tva.value = arrondir(tva,2);
 }
 
 function calculFSE(montant,taux,fse)
 {
 	var montant = document.getElementById(montant);
	var taux = document.getElementById(taux);
	var fse = document.getElementById(fse);
	
	result = parseFloat(montant.value.replace(',','.').replace(' ',''))*parseFloat(taux.value.replace(',','.').replace(' ',''))/100;
	fse.value = arrondir(result,2);
 }
 
 function calculNouveauPrix(volumeC,volumeE,prix,prix_1,prix_2,prix_3)
 {
 	var vol = parseFloat(document.getElementById(volumeC).value.replace(',','.').replace(' ',''))+parseFloat(document.getElementById(volumeE).value.replace(',','.').replace(' ',''));
	var prix = document.getElementById(prix);
	
	if(vol<=15000)
	 	prix.value = document.getElementById(prix_1).value;
	else
	{
		if(vol<=50000)
			prix.value = document.getElementById(prix_2).value;
		else
			prix.value = document.getElementById(prix_3).value;
	}
 }
 
 function calculEffectifTheoriqueRemu(effectifTheo,effectifTheoriqueRemu,pourcentage)
 {
	var effe = parseFloat(document.getElementById(effectifTheo).value.replace(',','.').replace(' ',''));
	var pourcentage = parseFloat(document.getElementById(pourcentage).value);
	var effTheoriqueRemu = document.getElementById(effectifTheoriqueRemu);
	
	effTheoriqueRemu.value = Math.round(pourcentage * effe);
	return;
 }

