function precisePoste(){
	if(document.form1.poste_recherche.options[document.form1.poste_recherche.selectedIndex].value == "Autres"){
		document.getElementById('precise-poste').style.visibility = "visible";	
	}else{
		document.getElementById('precise-poste').style.visibility = "hidden";	
	}
}
function showDetail(id_offre){
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'detail', id_offre, doShowDetail);
}
function doShowDetail(r){
	var str = "<div style='padding-left:25px;padding-top:10px'>";
	str = str + "<strong>D&eacute;tail de l'offre :</strong><br /><br />";
	str = str + "<u>Réf. :</u> " + r.ref_interne[0] + "<br />";
	//str = str + "<u>Date :</u> " + r.date_update[0] + "<br /><br />";
	str = str + "<u>Poste :</u><br />";
	str = str + "<strong>" + r.titre[0] + "</strong><br /><br />";
	str = str + "<u>Lieu :</u><br />";
	str = str + "<strong>" + r.lieu[0] + "</strong><br /><br />";
	str = str + "<strong>" + r.nom[0] + " " + r.prenom[0] + "</strong><br />";
	str = str + r.adresse1[0] + "<br />";
	if(r.adresse2[0]!= ""){
		str = str + r.adresse2[0] + "<br />"
	}
	str = str + r.zip[0] + " " + r.ville[0] + "<br /><br />";
	str = str + "<a href='offres-emplois-diagnostic-immobilier," + r.id_offre[0] + ".cfm'><strong>Postuler</strong></a><br /><br />";
	str = str + "</div>";
	
	str2 = "<table width='90%' border='0' cellpadding='0' cellspacing='0'>";
	str2 = str2 + "<tr><td><strong>" + r.titre[0] + "</strong><br /><br />";
	str2 = str2 + r.desc_1[0] + "<br />";
	str2 = str2 + r.desc_2[0] + "<br />";
	str2 = str2 + "</td></tr></table>";
	
	$('menu-emplois').innerHTML = str;
	$('tableau').innerHTML = str2;
	
			
}
function doQueryForm1(){
	var cfcObj = new Object();
	cfcObj.id_offre = document.form1.id_offre.value;
	cfcObj.poste_recherche = document.form1.poste_recherche.value;
	if(cfcObj.poste_recherche == "Autres"){
		cfcObj.poste_recherche = document.form1.poste_recherche_autre.value;
	}
	cfcObj.civilite = document.form1.civilite.options[document.form1.civilite.selectedIndex].value;
	cfcObj.nom = document.form1.nom.value;
	cfcObj.prenom = document.form1.prenom.value;
	cfcObj.adresse = document.form1.adresse.value;
	cfcObj.cp = document.form1.cp.value;
	cfcObj.ville = document.form1.ville.value;
	cfcObj.pays = document.form1.pays.value;
	cfcObj.tel = document.form1.tel.value;
	cfcObj.email = document.form1.email.value;
	cfcObj.date_naissance = document.form1.date_naissance.value;
	if(trim(cfcObj.nom) == ""){
		alert("vous devez saisir votre nom");
	}else if(trim(cfcObj.prenom) == ""){
		alert("vous devez saisir votre prénom");
	}else if(trim(cfcObj.adresse) == ""){
		alert("vous devez saisir votre adresse");
	}else if(trim(cfcObj.cp) == ""){
		alert("vous devez saisir votre code postal");
	}else if(trim(cfcObj.ville) == ""){
		alert("vous devez saisir votre ville");
	}else if(trim(cfcObj.tel) == ""){
		alert("vous devez saisir votre numéro de téléphone");
	}else if(trim(cfcObj.email) == "" || !emailCheck(cfcObj.email)){
		alert("vous devez saisir votre email");
	}else if(trim(cfcObj.date_naissance) != "" && !isDate(cfcObj.date_naissance)){
		alert("la date de naissance saisie est invalide.");
	}else{
		// ok, on envoie l'objet au cfc
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'step1', cfcObj, doQueryFirstResults);
	}
}
function doQueryFirstResults(r){
	var id_dde = r.id_dde[0];
	var str = "";
	var d = new Date();
	str = str + "<h1 align='center'>Rejoindre le r&eacute;seau AGENDA Expertises</h1>";
	str = str + "<div class='small-txt'>";
	str = str + "<form name='form2' action='offres-emplois-diagnostic-immobilier.cfm' method='post' enctype='multipart/form-data' onsubmit='return verifForm2();'>";
	str = str + "<input type='hidden' name='id_dde' value='" + r.id_dde[0] + "' />";
	str = str + "<fieldset>";
	str = str + "<legend>Informations compl&eacute;mentaires : </legend>";
	str = str + "<label>Permis de conduire : </strong></label>";
	str = str + "<input type='checkbox' name='permisA' value='1' style='border:none'> A <input type='checkbox' name='permisB' value='1' style='border:none'> B <input type='checkbox' name='permisC' value='1' style='border:none'> C <input type='checkbox' name='permisD' value='1' style='border:none'> D <br />";
	str = str + "<label for='formation'>Votre formation * </label>";
	str = str + "<textarea name='formation' style='width:200px;height:50px;'></textarea><br />";
	str = str + "<label for='experience'>Exp&eacute;rience professionnelle * </label>";
	str = str + "<textarea name='experience' style='width:200px;height:90px'></textarea><br />";
	str = str + "<label for='informatique'>Niveau et connaissance informatique : </label>";
	str = str + "<textarea name='informatique' style='width:200px;height:60px'></textarea><br />";
	str = str + "<label>Situation actuelle : </label>";
	str = str + "<select name='situation'>";
	str = str + "<option value='poste'>En poste</option>";
	str = str + "<option value='recherche'>A la recheche d'emploi</option>";
	str = str + "<option value='formation'>En cours de formation</option>";
	str = str + "</select>";
	str = str + "<label for='lieu'>Lieu de travail souhait&eacute; </label>";
	str = str + "<input name='lieu' style='width:200px'><br /><br />";
	str = str + "<label for='date_dispo'>Date de disponibilit&eacute; </label>";
	str = str + "<input name='date_dispo' style='width:80px' value='jj/mm/aaaa' onfocus=\"this.value='';\"><br />";
	str = str + "<label for='salaire'>Base de salaire brut mensuel souhait&eacute; </label>";
	str = str + "<input name='salaire' style='width:80px'><br /><br />";
	str = str + "<label for='lettre'>Lettre de motivation * <sup>1</sup></label>";
	str = str + "<input type='file' name='lettre' style='width:200px;height:18px'><br /><br />";
	str = str + "<label for='cv'>CV * <sup>1</sup></label>";
	str = str + "<input type='file' name='cv' style='width:200px;height:18px'><br /><br />";
	str = str +	"<div align='right'>";
	str = str + "<input name='submit2' type='submit' class='btnSubmit' style='width:80px;' value='ENVOYER' />";
	str = str + "</div>";
	str = str + "<span class='small-txt'>1 : Seuls les fichiers .doc, .rtf, .pdf sont accept&eacute;s</span>";
	str = str + "</fieldset>";
	str = str + "</form>";
	str = str + "</div>";
	$('bloc-central').innerHTML = str;
}

function verifForm2(){
	if(trim(document.form2.formation.value) == ""){
		alert("vous devez saisir votre formation");
		return false;
	}else if(trim(document.form2.experience.value) == ""){
		alert("vous devez saisir votre expérience");
		return false;
	}else if(trim(document.form2.date_dispo.value) != "" && !isDate(document.form2.date_dispo.value)){
		alert("vous devez saisir une date valide");
		return false;
	}else if(document.form2.lettre.value == ""){
		alert("vous devez joindre une lettre de motivation");
		return false;
	}else if(document.form2.cv.value == ""){
		alert("vous devez joindre un cv");
		return false;
	}else{
		return true;
	}
}
function endCandidature(id_dde){
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'step2', id_dde, endProcess);
}
function endProcess(r){
	var str = "";
	str = str + "<h1 align='center'>Rejoindre le r&eacute;seau AGENDA Expertises</h1>";
	str = str + "<h2>Merci " + r.civilite[0] + " " + r.prenom[0] + " " + r.nom[0] + "<br /><br />";
	str = str + "Votre candidature au poste de <strong>" + r.poste_recherche[0] + "</strong> a bien &eacute;t&eacute; enregistr&eacute;e et nous vous en remercions.<br />";
	str = str + "Notre service RH vous contactera prochainement.<br /><br /><br />";
	str = str + "Vous pouvez &agrave; tout moment modifier vos donn&eacute;s personnelles en nous contactant par courrier ou par email aux coordonn&eacute;es suivantes :<br />";
	str = str + "Denis RUIZ<br />";
	str = str + "AGENDA France<br />";
	str = str + "Immeuble Le Gamma<br />";
	str = str + "95 Avenue des Logissons<br />";
	str = str + "13770 VENELLES<br />";
	str = str + "T&eacute;l. : 04 42 54 53 29<br />";
	str = str + "Fax : 04 42 54 31 15<br />";
	str = str + "<a href='mailto:denis.ruiz@agendafrance.fr?subject=Modification de mes données personnelles'>denis.ruiz@agendafrance.fr</a>";
	$('bloc-central').innerHTML = str;
}
