// JavaScript Document
var ListSecteurs = new Array('Attractions','Aventure','Hebergement','Restauration','Services');
var MRCarray = new Array();
MRCarray[0]=new Array('Carleton-sur-Mer','Escuminac','Maria','Nouvelle','Pointe-a-la-Croix');
MRCarray[1]=new Array('Bonaventure','Caplan','Cascapédia-Saint-Jules','New Carlisle','New Richmond','Paspébiac','Saint-Alphonse','Saint-Elzéar ','Saint-Godefroi','Saint-Siméon','Shigawake');
MRCarray[2]=new Array('Cloridorme','Gaspé','Grande-Vallée','Petite-Vallée');
MRCarray[3]=new Array('Cap-Chat','La Martre','Marsoui','Sainte-Anne-des-Monts','Saint-Maxime-du-Mont-Louis');
MRCarray[4]=new Array('Chandler','Grande-Riviere','Percé','Port-Daniel-Gascons','Sainte-Thérese-de-Gaspé');
//MRCarray['Les Îles-de-la-Madeleine']=new Array('Grosse-Île','Les-Îles-de-la-Madeleine','Autre');
//MRCarray['Kamouraska']=new Array('Kamouraska','La Pocatiere','Mont-Carmel','Riviere-Ouelle','Saint-Alexandre-de-Kamouraska','Saint-André','Sainte-Hélene','Saint-Germain','Saint-Joseph-de-Kamouraska','Saint-Pacôme','Saint-Pascal','Saint-Philippe-de-Néri','Autre');
MRCarray[5]=new Array('Amqui','Causapscal','Lac-au-Saumon','Saint-Damase','Sainte-Irene','Saint-Léon-le-Grand','Saint-Noël','Saint-Vianney','Saint-Zénon-du-Lac-Humqui','Sayabec','Autre');
//MRCarray['La Mitis']=new Array('La Rédemption','Les Hauteurs','Métis-sur-Mer','Mont-Joli','Price','Saint-Charles-Garnier','Saint-Donat','Sainte-Angele-de-Mérici','Sainte-Flavie','Sainte-Luce','Saint-Gabriel-de-Rimouski','Saint-Joseph-de-Lepage','Autre'); 
//MRCarray[5]=new Array('Notre-Dame-des-Neiges','Saint-Clément','Sainte-Françoise','Saint-Éloi','Sainte-Rita','Saint-Jean-de-Dieu','Saint-Mathieu-de-Rioux','Saint-Simon','Trois-Pistoles');
MRCarray[6]=new Array('Métis-sur-Mer','Mont-Joli','Price','Sainte-Angele-de-Mérici','Sainte-Flavie','Saint-Joseph-de-Lepage'); 
MRCarray[7]=new Array('Baie-des-Sables','Les Méchins','Matane','Sainte-Paule','Saint-Léandre','Saint-René-de-Matane','Saint-Ulric');
//MRCarray['Rimouski-Neigette']=new Array('Esprit-Saint','Le Bic','Rimouski','Saint-Anaclet-de-Lessard','Saint-Fabien','Autre');
//MRCarray['Rivière-du-Loup']=new Array("Cacouna","Isle-Verte","Notre-Dame-du-Portage","Riviere-du-Loup","Saint-Antonin","Saint-Arsene","Saint-Cyprien","Saint-Épiphane","Saint-Hubert-de-Riviere-du-Loup","Saint-Modeste","Saint-Paul-de-la-Croix",'Autre');
//MRCarray['Témiscouata']=new Array("Auclair","Biencourt","Cabano","Dégelis","Lac-des-Aigles","Lejeune","Notre-Dame-du-Lac","Packington","Pohénégamook","Riviere-Bleue","Saint-Athanase","Saint-Eusebe","Saint-Honoré-de-Témiscouata","Saint-Juste-du-Lac","Saint-Louis-du-Ha! Ha!","Saint-Marc-du-Lac-Long","Saint-Michel-du-Squatec","Saint-Pierre-de-Lamy",'Autre');
var focusFunc = new Function("this.className='inputFocus';");
var blurFunc= new Function("this.className='inputTexte';updateTD(this)");
var ListFields = new Array('Fomation_','Lieu_','Date_');
var inc;
var NumCandidat;
inc=1;



function checkTelephone(tel,champs){
if (tel.charAt(3)=="-") tel=tel.replace("-"," ");
tel=tel.replace("(","");
tel=tel.replace(")","");
var regex = "^[0-9]{3}[ |-][0-9]{3}[ |-][0-9]{4}$";
var theExpression = new RegExp(regex);
var TelephoneValid = (theExpression.test(tel));
	if (TelephoneValid==false){
	document.formInscription[champs].value = "Format:555 555-5555";
	document.formInscription[champs].className='inputRequis';
	if (document.getElementById('DIV_'+champs)) updateInput(document.getElementById('DIV_'+champs));
	return false;
	}else if (tel!=document.formInscription[champs].value){
		document.formInscription[champs].value = tel;
		if (document.getElementById('DIV_'+champs)) document.getElementById('DIV_'+champs).innerHTML=tel;
		 return true;
	}
}


function checkCodePostal(){
  		var regex = "^[a-zA-Z][0-9][a-zA-Z][ ][0-9][a-zA-Z][0-9]$";
      	var theExpression = new RegExp(regex);

		codeP=document.formInscription.codePostal.value;
		codeP=codeP.replace("-"," ");
		if (codeP.charAt(3)!=" "){
			codeP=codeP.replace("-"," ");
		}

     	var CodePostalValid = (theExpression.test(codeP));
		if (CodePostalValid==false){
				document.formInscription.codePostal.value = "Format:A1A 1A1";
				document.formInscription.codePostal.className='inputRequis';
				if (document.getElementById('DIV_codePostal')) updateInput(document.getElementById('DIV_codePostal'));
			   return false;
		}else{
		document.formInscription.codePostal.value = codeP.toUpperCase();
		if (document.getElementById('DIV_codePostal')) document.getElementById('DIV_codePostal').innerHTML=codeP.toUpperCase();
		 return true;
		}
}

function checkEmail() {
  		var regex = "^[0-9a-z-]([\._0-9a-z-]+)?[_0-9a-z-]@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$";
      	var theExpression = new RegExp(regex);
     	var MailValid = (theExpression.test(document.formInscription.courriel.value));
		if (MailValid==false){
			
			   document.formInscription.courriel.value = "Format:aaa@bbb.ccc";
			   document.formInscription.courriel.className='inputRequis';
			   if (document.getElementById('DIV_courriel')) updateInput(document.getElementById('DIV_courriel'));
			   return false;
		}
}
//--------114 – 116 – 22 – 33 
function checkNEQ() {
  		var regex = "^[1-9]{2}[0-9]{8}$";
      	var theExpression = new RegExp(regex);
     	var NEQValid = (theExpression.test(document.formInscription.NEQ.value));
		if (NEQValid==false){
			
			  // document.formInscription.NEQ.value = "Invalide";
			   document.formInscription.NEQ.className='inputRequis';
			   if (document.getElementById('DIV_NEQ')) updateInput(document.getElementById('DIV_NEQ'));
			   return false;
		}
}
//-------------------etape 1
function etape1(){
	var valid = true;
	var done = false;
	var where = 0;
	var last = 0;
	var champsObl = ["telephone","entreprise","adresse","codePostal","courriel","gestionnaire","NEQ"];
	var nbrChamps = champsObl.length;
	
	for(i=0;i<nbrChamps;i++){
		if(document.formInscription[champsObl[i]].value!= "*Remplir ce champs*" && document.formInscription[champsObl[i]].value!="" || champsObl[i]=="codePostal"){
		if(champsObl[i] == "codePostal") if(checkCodePostal()==false) valid=false;
		if(champsObl[i] == "telephone") if(checkTelephone(document.formInscription[champsObl[i]].value,"telephone")==false) valid = false;
		if(champsObl[i] == "courriel")	if(checkEmail()==false) valid= false;
		if(champsObl[i] == "fax") if(checkTelephone(document.formInscription[champsObl[i]].value,"fax")==false)valid= false;
		if(champsObl[i] == "NEQ") if(checkNEQ()==false) valid=false;
		
		}else{
			document.formInscription[champsObl[i]].value ="*Remplir ce champs*";
			document.formInscription[champsObl[i]].className='inputRequis';
			if (document.getElementById('DIV_'+champsObl[i])) updateInput(document.getElementById('DIV_'+champsObl[i]));
			valid= false;
		}
	}
	villeForm=document.getElementById("ville");
	if (villeForm.value=="Autre" || villeForm.value==""){
		villeForm.className='inputRequis';
		valid=false;
	}
	return valid;

}

function etape2(){
	var valid = true;
	TableCalculs=document.getElementById('caddie');
	tRow = TableCalculs.rows.length-1;
	if (document.getElementById("nomParticipant").value==""){
		document.getElementById("nomParticipant").className='inputRequis';
		valid=false;
	}
	if (document.getElementById("fonction").value==""){
		document.getElementById("fonction").className='inputRequis';
		valid=false;
	}
	if (tRow<2){
		document.getElementById("formationTD").className='inputRequis';
		document.getElementById("villeTD").className='inputRequis';
		document.getElementById("dateTD").className='inputRequis';
		valid=false;
	}
	

	return valid;

}

function inscription(){
	var valid = true;
	var done = false;
	var where = 0;
	var last = 0;
	var champsObl = ["nomParticipant","telephone","entreprise","adresse","codePostal","courriel","fonction"];
	var nbrChamps = champsObl.length;
	
	for(i=0;i<nbrChamps;i++){
		if(document.formInscription[champsObl[i]].value!= "*Remplir ce champs*" && document.formInscription[champsObl[i]].value!="" || champsObl[i]=="codePostal"){
		if(champsObl[i] == "codePostal") if(checkCodePostal()==false) valid=false;
		if(champsObl[i] == "telephone") if(checkTelephone(document.formInscription[champsObl[i]].value,"telephone")==false) valid = false;
		if(champsObl[i] == "courriel")	if(checkEmail()==false) valid= false;
		if(champsObl[i] == "fax") if(checkTelephone(document.formInscription[champsObl[i]].value,"fax")==false)valid= false;
		}else{
			document.formInscription[champsObl[i]].value ="*Remplir ce champs*";
			document.formInscription[champsObl[i]].className='inputRequis';
			if (document.getElementById('DIV_'+champsObl[i])) updateInput(document.getElementById('DIV_'+champsObl[i]));
			valid= false;
		}
	}
	choixformationForm=document.getElementById("choixformation");
	choixlieuForm=document.getElementById("choixlieu");
	choixdateForm=document.getElementById("choixdate");
	villeForm=document.getElementById("ville");
	if (villeForm.value=="Autre" || villeForm.value==""){
		villeForm.className='inputRequis';
		valid=false;
	}
	if (choixformationForm.value==""){
		document.getElementById("formationTD").className='inputRequis';
		valid=false;
	}else if (choixlieuForm.value==""){
		document.getElementById("villeTD").className='inputRequis';
		valid=false;
	}else if (choixdateForm.value==""){
		document.getElementById("dateTD").className='inputRequis';
		valid=false;
	}
	
	//valid=true;
	return valid;

}
function putStatus(selectName){
	span = document.getElementById("statSpan");
	selectedValue = selectName.options[selectName.selectedIndex].id;
	span.innerHTML = selectedValue;
}
function selectFormation(selectName){
	document.getElementById("formationTD").className='inputTexte';
	selectID = selectName.options[selectName.selectedIndex].value;
	selectedNameFormation = selectName.options[selectName.selectedIndex].text;
	choixformationForm=document.getElementById("choixformation");
	choixlieuForm=document.getElementById("choixlieu");
	choixdateForm=document.getElementById("choixdate");
	
	//formationString = document.getElementById("formationStr");
	//villeString = document.getElementById("villeStr");
	//dateString = document.getElementById("dateStr");
	villeDiv = document.getElementById("villeTD");
	allSelect = villeDiv.getElementsByTagName("select");

	//formationString.innerHTML = "";
	//villeString.innerHTML = "";
	//dateString.innerHTML = "";
document.getElementById("addformationbtn").style.display ="block";
	if(selectID == "0"){
		for(i =0 ; i< allSelect.length;i++){	
			allSelect[i].style.display = "none";
			allSelect[i].disabled = "disabled";
		}
		dateDiv = document.getElementById("dateTD");
		allSelect = dateDiv.getElementsByTagName("select");
	
		for(i =0 ; i< allSelect.length;i++){
			allSelect[i].style.display = "none";
			allSelect[i].disabled = "disabled";
		}
		//formationString.innerHTML = "";
		//villeString.innerHTML = "";
		//dateString.innerHTML = "";

choixformationForm.value="";
	choixlieuForm.value="";
	choixdateForm.value="";
	}else{
		
		
		for(i =0 ; i< allSelect.length;i++){
			if(allSelect[i].id != selectID){
				allSelect[i].style.display = "none";
				allSelect[i].disabled = "disabled";
			}
		}
		curSelect = document.getElementById(selectID);
		curSelect.style.display ="block";
		selectTime(curSelect);
		curSelect.disabled = "";
		curSelect.selectedIndex=0;
		//formationString.innerHTML = "";
		//formationString.innerHTML = selectedNameFormation;
		choixformationForm.value=selectedNameFormation;

	}
}
function selectTime(selectName){
	selectID = selectName.options[selectName.selectedIndex].value;
	selectedName = selectName.options[selectName.selectedIndex].text;
	dateDiv = document.getElementById("dateTD");
	allSelect = dateDiv.getElementsByTagName("select");
	selectName.options[selectName.selectedIndex].text;
	//villeString = document.getElementById("villeStr");
	//dateString = document.getElementById("dateStr");
	choixformationForm=document.getElementById("choixformation");
	choixlieuForm=document.getElementById("choixlieu");
	choixdateForm=document.getElementById("choixdate");
	
	//villeString.innerHTML = "";
	//dateString.innerHTML = "";

	choixlieuForm.value="";
	choixdateForm.value="";
	if(selectID == "0"){
		dateDiv = document.getElementById("dateTD");
		allSelect = dateDiv.getElementsByTagName("select");
	
		for(i =0 ; i< allSelect.length;i++){
			allSelect[i].style.display = "none";
			allSelect[i].disabled = "disabled";
		}
		//villeString.innerHTML = "";
		//dateString.innerHTML = "";
	}else{
		for(i =0 ; i< allSelect.length;i++){
			if(allSelect[i].id != selectID){
				allSelect[i].style.display = "none";
				allSelect[i].disabled = "disabled";
			}
		}
		//alert(selectID);
		curSelect = document.getElementById(selectID);
		curSelect.style.display ="block";
		curSelect.disabled = "";
		curSelect.selectedIndex=0;
		
		selectedName2 = curSelect.options[curSelect.selectedIndex].text;
		//dateString.innerHTML = " le " + selectedName2;
		//villeString.innerHTML = "";
		//villeString.innerHTML = " à " + selectedName;
	choixlieuForm.value=selectedName;
	choixdateForm.value=selectedName2;
	}
}
function selectDate(selectName){
	//selectID = selectName.options[selectName.selectedIndex].value;
	selectedName = selectName.options[selectName.selectedIndex].text;
	lieuid=document.formInscription["formation"].value
	
	lieuvalue = document.getElementById(lieuid);
	lieutexte=lieuvalue.options[lieuvalue.selectedIndex].text;
	document.getElementById("choixlieu").value=lieutexte;

	choixdateForm=document.getElementById("choixdate");
	if(selectID == "0"){
		choixdateForm.value="";
	}else{
	choixdateForm.value=selectedName;
	}
}
function disableDateSelect(){
	dateDiv = document.getElementById("dateTD");
	allSelect = dateDiv.getElementsByTagName("select");

	for(i =0 ; i< allSelect.length;i++){
		allSelect[i].style.display = "none";
		allSelect[i].disabled = "disabled";
	}
}

function choixmrc(thisID){
thisValue=thisID;//thisID.selectedIndex;
litedesvilles=MRCarray[thisValue];
SelectVille = document.getElementById("ville");
document.getElementById("ville").className='inputTexte';
alloption = SelectVille.getElementsByTagName("option");
for(i=(alloption.length-1);i>1;i--){
  SelectVille.removeChild(SelectVille[i]);
}
setTimeout("placeNodeSelect(litedesvilles)",200);
}

function placeNodeSelect(theArrayValue){
theNode = document.getElementById("ville");
	for(i=0;i<theArrayValue.length;i++){
	bufferOptionNode=document.createElement('option');
	bufferOptionValue=theArrayValue[i];
	bufferOptionNode.setAttribute('value',bufferOptionValue);
	bufferOptionNode.innerHTML = bufferOptionValue;
	theNode.appendChild(bufferOptionNode);
	}
theNode.selectedIndex=0;
}

function choixville(thisValue){
//alert(thisValue);
document.getElementById("ville").className='inputTexte';
SelectVille = document.getElementById("ville");
if (thisValue=="Autre"){
nouvelleVille=prompt("Entrez le nom de la ville :", "");
if (nouvelleVille!="" && nouvelleVille!="undefined" && nouvelleVille!=null){	
	//---------------------------------------------------
	bufferOptionNode=document.createElement('option');
	bufferOptionValue=nouvelleVille;
	bufferOptionNode.setAttribute('value',bufferOptionValue);
	bufferOptionNode.innerHTML = bufferOptionValue;
	//SelectVille.insertBefore(bufferOptionNode,thisValue.firstChild);
	//alert(SelectVille.length);
	SelectVille.appendChild(bufferOptionNode);
	//alert(SelectVille.length);
	//---------------------------------------------------
	curNum=SelectVille.length-1;
	setTimeout("SelectVille.selectedIndex=curNum",200);
}

}
}

Array.prototype.inArray = function (value)
{
	var i;
	for (i=0; i < this.length; i++) {
		if (value.match(this[i])) {
			return true;
		}
	}
	return false;
};


function updateTD(row){
if (row.value!="" && row.value!="*Remplir ce champs*" && row.className!='inputRequis' && row.value!="Format:555-555-5555" && row.value!="Format:A1A 1A1" && row.value!="Format:aaa@bbb.ccc"){

	 theTD=row.parentNode;
	 row.style.display = "none";
	 bufferDIV=theTD.getElementsByTagName('div');
	 if (bufferDIV[0]) theTD.removeChild(bufferDIV[0]);
	 var bufferOption=document.createElement('div');
	 bufferOption.setAttribute('id','DIV_'+row.name);
	 bufferOption.setAttribute('inputID',row.name);
	 bufferOption.onclick = new Function("updateInput(this);");
	 bufferOption.className='inputTexteDIV';
	 bufferOption.innerHTML=wrapString(row.value);
	 row.parentNode.appendChild(bufferOption);
	 }else if (row.value=="*Remplir ce champs*" || row.value=="Format:555-555-5555" || row.value=="Format:A1A 1A1" || row.value=="Format:aaa@bbb.ccc"){
		 row.className='inputRequis';
	 }
}
function updateRow(row){
var Secure=0;
	if (row!=null){
	//calculRow();
	theTr=row;
		while(theTr.tagName!="TR"){
			theTr=theTr.parentNode;
			if (Secure++ >10) return ;
		}
	 fieldsSelection=theTr.getElementsByTagName('input');
	 textareasSelection = theTr.getElementsByTagName('textarea');
	 for(i=0;i<fieldsSelection.length;i++){
		if (fieldsSelection[i].getAttribute('type')!="button") updateTD(fieldsSelection[i]);
	 }
	 for(i=0;i<textareasSelection.length;i++){
		updateTD(textareasSelection[i]);
	}
	
	
	}
}

function iniInputField(){
 fieldsSelection = document.getElementsByTagName('input');
 textareasSelection = document.getElementsByTagName('textarea');
	for(i=0;i<fieldsSelection.length;i++){
		if (fieldsSelection[i].getAttribute('type')!="button" && fieldsSelection[i].getAttribute('type')!="submit" && fieldsSelection[i].getAttribute('type')!="radio" && fieldsSelection[i].getAttribute('type')!="checkbox") {
		if (!fieldsSelection[i].onfocus) fieldsSelection[i].onfocus=focusFunc;
		if (!fieldsSelection[i].onblur) fieldsSelection[i].onblur =blurFunc;
		}
	}
	for(i=0;i<textareasSelection.length;i++){
		if (!textareasSelection[i].onfocus) textareasSelection[i].onfocus=focusFunc;
		if (!textareasSelection[i].onblur) textareasSelection[i].onblur =blurFunc;
	}
}
function updateInput(row){
//alert(row.getAttribute('inputID'));
	theTD=row.parentNode;
	theInputName=row.getAttribute('inputID');
	document.getElementById(theInputName).style.display = "block";
	if (document.getElementById(theInputName).className!='inputRequis') document.getElementById(theInputName).focus();
	theTD.removeChild(row);
}
function wrapString(inputString){
  //inputString.replace(/(\r\n)/gi, "<br>");
  inputString = sg(inputString,'\n','<br>');
  return inputString;
}
function sg(a,a2,a3) {
	var r='';
	while (a.indexOf(a2)!=-1) {
		var v1=a.indexOf(a2);
		r+=a.substring(0,v1)+a3;
		a=a.substring(v1+a2.length);
	}
	return r+a;
}

function properCase(theField){
theField.value = theField.value.toLowerCase();
fVal=theField.value.replace(/\b(\w)/g, function(c){return c.toUpperCase()});
if(fVal!=theField.value)theField.value=fVal;
}
function AllCase(theField){
theField.value = theField.value.toUpperCase();
}

function FormatNoSpace(theField,s,evenement){
	var touche = window.event ? window.event.keyCode : evenement.which;
	if (touche==8) return;
	if (touche!=8 || touche!=46){
	myvalue=theField.value;
	mylength=myvalue.length;
	if (touche==32 || touche==189){
		if (mylength!=s) theField.value =myvalue.substring(0,mylength-1);
	}else if (mylength==(s-1)){
	theField.value =theField.value+" ";
	}
	}
}

function Formattelephone(theField,s,z,evenement){
	
	var touche = window.event ? window.event.keyCode : evenement.which;
	if (touche!=8 || touche!=46){
		myvalue=theField.value;
		mylength=myvalue.length;
		if (touche==32 ||touche==109 || touche==57 || touche==48){
			if (mylength!=s && mylength!=z) theField.value =myvalue.substring(0,mylength-1);
		}else if (mylength==(s-1)){
		theField.value =theField.value+" ";
		}else if (mylength==(z-1)){
		theField.value =theField.value+"-";
		}
	}
}

function removeFormation(theRow){
var Secure=0;
if (theRow!=null){
theTr=theRow;
while(theTr.tagName!="TR"){
	theTr=theTr.parentNode;
	if (Secure++ >10) return ;
}

thetable=document.getElementById('caddie');
thetable.removeChild(theTr);
}
}

function addFormation(){
	choixformationForm=document.getElementById("choixformation");
	choixlieuForm=document.getElementById("choixlieu");
	choixdateForm=document.getElementById("choixdate");
	if (choixformationForm.value!="" && choixlieuForm.value !="" && choixdateForm.value!= "" ){
	var TableCalculs=document.getElementById('caddie');
	tRow = TableCalculs.rows.length-1;
	var theModelRow=TableCalculs.rows[tRow];
	var theNewRow=theModelRow.cloneNode(true);;
	TableCalculs.insertBefore(theNewRow,theModelRow);
	//inc++;
	fieldsSelection=theNewRow.getElementsByTagName('input');
		for(i=0;i<fieldsSelection.length;i++){
			fieldsSelection[i].value = "";
			fieldsSelection[i].style.display = "block";
			var bufferTD=fieldsSelection[i].parentNode;
			//var bufferDIV=bufferTD.getElementsByTagName('div');
			//if (bufferDIV[0]) bufferTD.removeChild(bufferDIV[0]);
			fieldsSelection[i].setAttribute('name',ListFields[i]+inc);
			fieldsSelection[i].setAttribute('id',ListFields[i]+inc);
			var bufferOption=document.createElement('div');
	 		bufferOption.setAttribute('id','DIV_'+ListFields[i]+inc);
	 		bufferOption.className='inputTexteDIV';
	 		bufferTD.appendChild(bufferOption);
		 }
		linkSelection=theNewRow.getElementsByTagName('a');
		for(i=0;i<linkSelection.length;i++){
			linkSelection[i].style.display = "block";
		 }
	theNewRow.setAttribute('id','Row'+inc);
	//------------------
	choixformationForm2=document.getElementById("Fomation_"+inc);
	choixlieuForm2=document.getElementById("Lieu_"+inc);
	choixdateForm2=document.getElementById("Date_"+inc);
//--
	choixformationForm2.value=choixformationForm.value;
	choixlieuForm2.value=choixlieuForm.value;
	choixdateForm2.value=choixdateForm.value;
	document.getElementById("DIV_Fomation_"+inc).innerHTML=choixformationForm2.value;
	document.getElementById("DIV_Lieu_"+inc).innerHTML=choixlieuForm2.value;
	document.getElementById("DIV_Date_"+inc).innerHTML=choixdateForm2.value;
	//------------------------
	//document.getElementById("choixformation").value="";
	document.getElementById("choixlieu").value="";
	document.getElementById("choixdate").value="";
	inc++;
	}
}
function ajoutercandidat(){
if (etape2(0)){
	document['formInscription'].action="post.php?addc=1";
	document['formInscription'].submit();
}
}
function cancelm(){
	document['formInscription'].action="etape3.php";
	document['formInscription'].submit();
}
 
function CheckSelection(fieldName,fieldVal){
if (fieldVal==0){
fieldName.selectedIndex++;
fieldVal=fieldName.value;
}

if (fieldVal!=0){
//bufferDef=document.getElementById(fieldVal);
//bufferDef.style.display="block";
document.getElementById("Fonction").value=fieldName.options[fieldName.selectedIndex].text;
//document.getElementById("Title").value=fieldName.options[fieldName.selectedIndex].text;
}
}
function resetDivDefinition(){

}
function PlacerField(ItemSelected){
	for(i=0;i<ListSecteurs.length;i++){
	bufferField=document.getElementById(ListSecteurs[i]);
	if (ListSecteurs[i]!=ItemSelected){
		bufferField.style.display="none";
		bufferField.selectedIndex=0;
	}else{
		bufferField.style.display="block";
	}
	}
}
