function precisezTypedeBien(){
	if(document.form1.type_de_bien.options[document.form1.type_de_bien.selectedIndex].value == 5){
		document.getElementById('tr-precisez').style.visibility = "visible";
		document.getElementById('tr-precisez').style.height = "auto";
		document.getElementById('td-precisez').innerHTML = "<label for='type_de_bien_autre'>Pr&eacute;cisez :</label><input name='type_de_bien_autre' style='width:250px;' /><br /><br />";
	
	}else{
		document.getElementById('tr-precisez').style.visibility = "hidden";
		document.getElementById('tr-precisez').style.height = "0px";
		document.getElementById('td-precisez').innerHTML = null;
	}
}
function verifCommunes(){
	var code_postal = document.form1.code_postal.value;
	if(trim(code_postal) == "" || !checkCP('form1')){
		alert("vous devez saisir un code postal à 5 chiffres");
	}else{
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'step0', code_postal, doQueryVerifCommunes);
	}
}
function doQueryVerifCommunes(r){
	if(document.form1.canton.options.length > 0){
		for(var i=document.form1.canton.length; i>=0; i--){
			document.form1.canton.options[i] = null;
		}
	}
	if(r.getRowCount() > 0  && r.id_expert[0] == null){
		alert("Aucun diagnostiqueur ne couvre la zone de votre code postal.\rMerci de contacter notre numéro vert\r\r0 800 397 378\r\pour plus d'informations.");
	}else if(r.getRowCount() > 1){
		nbCantons = r.getRowCount();
		var i = 0;
		var j = 0;
		while(i < nbCantons){
			if(r.commune[i] != r.commune[i-1]){
				document.form1.canton.options[j] = new Option(r.commune[i],r.commune[i]);
				document.form1.submit1.disabled = false;
				j++;
			}
			i++;
		}
		var nbVerif = document.form1.canton.options.length;
		if(nbVerif < 6){
			document.form1.canton.size = nbVerif;	
		}else{
			document.form1.canton.size = 5;
		}
	}else if(r.getRowCount() == 1){
		document.form1.canton.options[0] = new Option(r.commune[0],r.commune[0]);
		document.form1.submit1.disabled = false;
		// on a un seul expert, on peut afficher ses infos
		code_postal = document.form1.code_postal.value;
		commune = r.commune[0];
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'step1', code_postal, commune, showDirectInfos);
	}else{
		// on affiche une alerte
		alert("Votre code postal n'est pas assez précis.\rPlusieurs diagnostiqueurs couvrent la zone concernée,\rune réponse personnalisée ne peut donc pas vous être fournie.\rMerci d'affiner votre recherche.");
	}
}
function showDirectInfos(r){
	/*var msg = "";
	for(i in r){
		msg = msg + r[i][0]+"\r";
	}
	confirm(msg);*/
	if(r.getRowCount() == 1){
		// on a un retour
		// on change le background
		$('bloc-devis').style.backgroundImage = "url('/images/agenda-diagnostic-immobilier-bloc-devis-rempli.gif')";
		// on prepare les infos expert
		var str = "<table width='100%' border='0'>";
		str = str + "<tr><td>";
		if(r.photo[0] != null){
			str = str + "<img src='/images/trombi/" + r.photo[0] + "' alt='Photo " + r.prenom[0] + " " + r.nom[0] + " Diagnostiqueur Immobilier' title='Photo " + r.prenom[0] + " " + r.nom[0] + " Diagnostiqueur Immobilier'>";
		}
		str = str + "</td>";
		str = str + "<td valign='top'>";
		str = str + "<strong>" + r.prenom[0] + " " + r.nom[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 />";
		str = str + "T&eacute;l. : " + r.tel[0] + "<br />";
		str = str + "Fax : " + r.fax[0] + "<br />";
		str = str + "<a href=\"mailto:" + r.email[0] + "\">Envoyer un e-mail</a><br />";
		str = str + "</td></tr>";
		// AJOUT 20071113 : CERTIFICATION
		if(r.certifie[0]){
			str = str + "<tr><td colspan='2' align='center' valign='middle'>" + r.logo_certif[0] + "<br />" + r.str_certif[0] + "</td></tr>";
		}
		// FIN AJOUT
		str = str + "</table>";
		str = str + "<div style='position:absolute;top:170px;left:4px;'>";
		str = str + "<a href=\"#\" onClick=\"displayWindow('/_estara/link_web.cfm?phone=" + r.tel[0]+ "','Clip','430','378')\"><img src='/images/devis-appelez-votre-diagnostiqueur-gratuitement.gif' alt='Appelez " + r.prenom[0] + " " + r.nom[0] + " gratuitement (Nouvelle fen&ecirc;tre)' title='Appelez " + r.prenom[0] + " " + r.nom[0] + " gratuitement (Nouvelle fen&ecirc;tre)' width='262' height='50' border='0'></a>";
		str = str + "</div>";
		// on affiche les infos expert
		$('coord-diagnostiqueur').innerHTML = str;
	}else{
		// on a pas de retour
		// on remet le background au cas où
		$('bloc-devis').style.backgroundImage = "url('/images/agenda-diagnostic-immobilier-bloc-devis-vide.gif')";
		// on vire les infos expert au cas où
		$('coord-diagnostiqueur').innerHTML = "";
		// on affiche une alerte
		alert("Votre code postal n'est pas assez précis.\rPlusieurs diagnostiqueurs couvrent la zone concernée,\rune réponse personnalisée ne peut donc pas vous être fournie.\rMerci d'affiner votre recherche.");
	}
}
function doQueryForm1(){
	
	if(trim(document.form1.code_postal.value) == "" || !checkCP('form1')){
		alert("vous devez saisir un code postal à 5 chiffres");
	}else if(document.form1.type_de_bien.options[document.form1.type_de_bien.selectedIndex].value == 5 && trim(document.form1.type_de_bien_autre.value) == ""){
		alert("vous devez préciser le type de bien");
	}else{
		type_besoin = document.form1.type_besoin.options[document.form1.type_besoin.selectedIndex].value;
		type_de_bien = document.form1.type_de_bien.options[document.form1.type_de_bien.selectedIndex].value;
		code_postal = document.form1.code_postal.value;
		commune = document.form1.canton.options[document.form1.canton.selectedIndex].value;
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'step1', code_postal, commune, doQueryFirstResults);
	}
}
			
function doQueryFirstResults (r) {
	var msg = "";
	for(i in r){
		msg = msg + r[i][0]+"\r";
	}
	//confirm(msg);
	if(r.getRowCount() == 1){
		// on a un retour
		// on change le background
		$('bloc-devis').style.backgroundImage = "url('/images/agenda-diagnostic-immobilier-bloc-devis-rempli.gif')";
		// on prepare les infos expert
		var str = "<table width='100%' border='0'>";
		str = str + "<tr><td>";
		if(r.photo[0] != null){
			str = str + "<img src='/images/trombi/" + r.photo[0] + "' alt='Photo " + r.prenom[0] + " " + r.nom[0] + " Diagnostiqueur Immobilier' title='Photo " + r.prenom[0] + " " + r.nom[0] + " Diagnostiqueur Immobilier'>";
		}
		str = str + "</td>";
		str = str + "<td valign='top'>";
		str = str + "<strong>" + r.prenom[0] + " " + r.nom[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 />";
		str = str + "T&eacute;l. : " + r.tel[0] + "<br />";
		str = str + "Fax : " + r.fax[0] + "<br />";
		str = str + "<a href=\"mailto:" + r.email[0] + "\">" + r.email[0] + "</a><br />";
		str = str + "</td></tr>";
		// AJOUT 20071113 : CERTIFICATION
		if(r.certifie[0]){
			str = str + "<tr><td colspan='2' align='center' valign='middle'>" + r.logo_certif[0] + "<br />" + r.str_certif[0] + "</td></tr>";
		}
		// FIN AJOUT
		str = str + "</table>";
		str = str + "<div style='position:absolute;top:170px;left:4px;'>";
		str = str + "<a href=\"#\" onClick=\"displayWindow('/_estara/link_web.cfm?phone=" + r.tel[0]+ "','Clip','430','378')\"><img src='/images/devis-appelez-votre-diagnostiqueur-gratuitement.gif' alt='Appelez " + r.prenom[0] + " " + r.nom[0] + " gratuitement (Nouvelle fen&ecirc;tre)' title='Appelez " + r.prenom[0] + " " + r.nom[0] + " gratuitement (Nouvelle fen&ecirc;tre)' width='262' height='50' border='0'></a>";
		str = str + "</div>";
		// on affiche les infos expert
		$('coord-diagnostiqueur').innerHTML = String(str);
		// id_expert
		document.form2.id_expert.value = r.id_expert[0];
		// code_canton (hidden)
		document.form2.code_canton.value = r.code_canton[0];
		// tarif disponible ? on met à jour le champ
		document.form2.tarif.value = r.has_tarif[0] == 1 ? 1 : 0;
		// tarif  diag dispo pour affichage ou non des cases à cocher
		document.form2.t_termites.value = r.t_termites[0] == 0 ? 0 : 1;
		document.form2.t_elec.value = r.t_elec[0] == 0 ? 0 : 1;
		document.form2.t_robien.value = r.t_robien[0] == 0 ? 0 : 1;
		document.form2.t_ptz.value = r.t_ptz[0] == 0 ? 0 : 1;
		document.form2.t_plomb_t.value = r.t_plomb_t[0] == 0 ? 0 : 1;
		document.form2.t_plomb_l.value = r.t_plomb_l[0] == 0 ? 0 : 1;
		document.form2.t_logdec.value = r.t_logdec[0] == 0 ? 0 : 1;
		document.form2.t_gaz.value = r.t_gaz[0] == 0 ? 0 : 1;
		document.form2.t_ernt_t.value = r.t_ernt_t[0] == 0 ? 0 : 1;
		document.form2.t_ernt_l.value = r.t_ernt_l[0] == 0 ? 0 : 1;
		document.form2.t_edl.value = r.t_edl[0] == 0 ? 0 : 1;
		document.form2.t_dpe_t.value = r.t_dpe_t[0] == 0 ? 0 : 1;
		document.form2.t_dpe_l.value = r.t_dpe_l[0] == 0 ? 0 : 1;
		document.form2.t_carrez.value = r.t_carrez[0] == 0 ? 0 : 1;
		document.form2.t_amiante.value = r.t_amiante[0] == 0 ? 0 : 1;
		
		// etat parasitaire obligatoire ? on met à jour le champ
		document.form2.termites.value = r.termites[0];
		// on bloque les premiers éléments
		document.form1.type_besoin.disabled = "disabled";
		document.form1.type_de_bien.disabled = "disabled";
		if(document.form1.type_de_bien_autre != null){
			document.form1.type_de_bien_autre.disabled = "disabled";
		}
		document.form1.code_postal.disabled = "disabled";
		document.form1.canton.disabled = "disabled";
		document.form1.submit1.style.visibility = "hidden";
		// on affiche la suite
		document.getElementById('divform2').style.visibility = "visible";
		if(document.form1.type_besoin.value == 2){
			document.getElementById('divInstallGaz').style.visibility = "hidden";
		}else{
			document.getElementById('divInstallGaz').style.visibility = "visible";
		}
	}else{
		// on a pas de retour
		// on remet le background au cas où
		$('bloc-devis').style.backgroundImage = "url('/images/agenda-diagnostic-immobilier-bloc-devis-vide.gif')";
		// on vire les infos expert au cas où
		$('coord-diagnostiqueur').innerHTML = "";
		// on affiche une alerte
		alert("Votre code postal n'est pas assez précis.\rPlusieurs diagnostiqueurs couvrent la zone concernée,\rune réponse personnalisée ne peut donc pas vous être fournie.\rMerci d'affiner votre recherche.");
	}
}
function doQueryForm2(){
	// on désactive le bouton au cas où
	document.form2.submit2.style.visibility = "hidden";
	var type_besoin = document.form1.type_besoin.options[document.form1.type_besoin.selectedIndex].value;
	var type_de_bien = document.form1.type_de_bien.options[document.form1.type_de_bien.selectedIndex].value;
	if(document.form1.type_de_bien_autre != null){
		var type_de_bien_autre = document.form1.type_de_bien_autre.value;
	}else{
		var type_de_bien_autre = '';
	}
	var code_postal = document.form1.code_postal.value;
	var commune = document.form1.canton.options[document.form1.canton.selectedIndex].value;
	var code_canton = document.form2.code_canton.value;
	var annee_construction = document.form2.annee_construction.options[document.form2.annee_construction.selectedIndex].value;
	var nbre_pieces = document.form2.nbre_pieces.options[document.form2.nbre_pieces.selectedIndex].value;
	if(document.form2.dependances.checked == true){
		var dependances = 1;
	}else{
		var dependances = 0;
	}
	var installGaz = document.form2.installGaz[0].checked;
	var installElec = document.form2.installElec[0].checked;
	var id_expert = document.form2.id_expert.value;
	var tarif = document.form2.tarif.value;
	var termites = document.form2.termites.value;
	var t_termites = document.form2.t_termites.value;
	var t_elec = document.form2.t_elec.value;
	var t_robien = document.form2.t_robien.value;
	var t_ptz = document.form2.t_ptz.value;
	var t_plomb_t = document.form2.t_plomb_t.value;
	var t_plomb_l = document.form2.t_plomb_l.value;
	var t_logdec = document.form2.t_logdec.value;
	var t_gaz = document.form2.t_gaz.value;
	var t_ernt_t = document.form2.t_ernt_t.value;
	var t_ernt_l = document.form2.t_ernt_l.value;
	var t_edl = document.form2.t_edl.value;
	var t_dpe_t = document.form2.t_dpe_t.value;
	var t_dpe_l = document.form2.t_dpe_l.value;
	var t_carrez = document.form2.t_carrez.value;
	var t_amiante = document.form2.t_amiante.value;
	var str = "";
	str = str + "<form name='form3' onsubmit='return false;'>";
	str = str + "<input type='hidden' name='type_besoin' value='" + type_besoin + "' />";
	str = str + "<input type='hidden' name='type_de_bien' value='" + type_de_bien + "' />";
	str = str + "<input type='hidden' name='type_de_bien_autre' value='" + type_de_bien_autre + "' />";
	str = str + "<input type='hidden' name='code_postal' value='" + code_postal + "' />";
	str = str + "<input type='hidden' name='code_canton' value='" + code_canton + "' />";
	str = str + "<input type='hidden' name='commune' value='" + commune + "' />";
	str = str + "<input type='hidden' name='annee_construction' value='" + annee_construction + "' />";
	str = str + "<input type='hidden' name='nbre_pieces' value='" + nbre_pieces + "' />";
	str = str + "<input type='hidden' name='dependances' value='" + dependances + "' />";
	str = str + "<input type='hidden' name='id_expert' value='" + id_expert + "' />";
	str = str + "<input type='hidden' name='tarif' value='" + tarif + "' />";
	str = str + "<input type='hidden' name='termites' value='" + termites + "' />";
	str = str + "<fieldset><legend align='top'>Votre besoin</legend>";	
	
	// on affiche les diagnostics en fonction des éléments connus
	if(type_besoin == 1){
		var chk = (type_de_bien != 5) ? "checked='checked'" : "";
		// transaction
		// sont cochés DPE, ERNT, Amiante si avant 1997, plomb si avant 1949, 
		// loi carrez si appart ou maison copropriete, etat parasitaire selon dept
		// si type de bien != autre
		if(t_dpe_t != 0){
			str = str + "<label for='diag' class='labelR'>Diagnostic Performance &Eacute;nerg&eacute;tique</label>";
			str = str + "<input type='checkbox' name='diag' value='dpe_t' " + chk + " style='border:none;'><br />";
		}
		// modifié 2008/02/26 pas coché par défaut
		if(t_ernt_t != 0){
			str = str + "<label for='diag' class='labelR'>&Eacute;tat des Risques Naturels ou Technologiques</label>";
			str = str + "<input type='checkbox' name='diag' value='ernt' style='border:none;'><br />";
		}
		var chk = (type_de_bien != 5 && annee_construction < 3) ? "checked='checked'" : "";
		if(t_amiante != 0){
			str = str + "<label for='diag' class='labelR'>Diagnostic Amiante</label>";
			str = str + "<input type='checkbox' name='diag' value='amiante' " + chk + " style='border:none;'><br />";
		}
		var chk = (type_de_bien < 4 && annee_construction == 1) ? "checked='checked'" : "";
		if(t_plomb_t != 0){
			str = str + "<label for='diag' class='labelR'>Diagnostic Plomb</label>";
			str = str + "<input type='checkbox' name='diag' value='plomb' " + chk + " style='border:none;'><br />";
		}
		var chk = (type_de_bien != 5 && (type_de_bien == 1 || type_de_bien == 3)) ? "checked='checked'" : "";
		if(t_carrez != 0){
			str = str + "<label for='diag' class='labelR'>Loi Carrez</label>";
			str = str + "<input type='checkbox' name='diag' value='carrez' " + chk + " style='border:none;'><br />";
		}
		var chk = (installGaz) ? "checked='checked'" : "";
		if(t_gaz != 0){
			str = str + "<label for='diag' class='labelR'>Diagnostic Gaz (installation de + 15 ans)</label>";
			str = str + "<input type='checkbox' name='diag' value='gaz' " + chk + " style='border:none;'><br />";
		}
		var chk = (type_de_bien != 5 && termites != 0) ? "checked='checked'" : "";
		var inf = (type_de_bien != 5 && termites != 0) ? "<sup>1</sup>" : "";
		if(t_termites != 0){
			str = str + "<label for='diag' class='labelR'>Termites" + inf + "</label>";
			str = str + "<input type='checkbox' name='diag' value='termites' " + chk + " style='border:none;'><br />";
		}
		var chk = (installElec) ? "checked='checked'" : "";
		if(t_elec != 0){
			str = str + "<label for='diag' class='labelR'>Electricit&eacute; (installation de + 15 ans )</label>";
			str = str + "<input type='checkbox' name='diag' value='elec'  " + chk + " style='border:none;'><br />";
		}
		if(t_ptz != 0){
			str = str + "<label for='diag' class='labelR'>Normes de surfaces et habitabilit&eacute; (<acronym title='Pr&ecirc;t Taux Z&eacute;ro'>PTZ</acronym>)</label>";
			str = str + "<input type='checkbox' name='diag' value='ptz' style='border:none;'><br />";
		}
	}else if(type_besoin == 2){
		// location
		// sont cochés DPE, ERNT si type de bien != autre
		var chk = (type_de_bien != 5) ? "checked='checked'" : "";
		if(t_dpe_l != 0){
			str = str + "<label for='dpe' class='labelR'>Diagnostic Performance &Eacute;nerg&eacute;tique</label>";
			str = str + "<input type='checkbox' name='diag' value='dpe_l' " + chk + " style='border:none;'><br />";
		}
		// modifié 2008/02/26 : pas coché
		if(t_ernt_l != 0){
			str = str + "<label for='ernt' class='labelR'>&Eacute;tat des Risques Naturels ou Technologiques</label>";
			str = str + "<input type='checkbox' name='diag' value='ernt_l' style='border:none;'><br />";
		}
		var chk = (type_de_bien < 4 && annee_construction == 1) ? "checked='checked'" : "";
		if(t_plomb_l != 0){
			str = str + "<label for='diag' class='labelR'>Diagnostic Plomb</label>";
			str = str + "<input type='checkbox' name='diag' value='plomb_l' " + chk + " style='border:none;'><br />";
		}
		if(t_edl != 0){
			str = str + "<label for='edl' class='labelR'>&Eacute;tat des lieux</label>";
			str = str + "<input type='checkbox' name='diag' value='edl' style='border:none;'><br />";
		}
		if(t_logdec != 0){
			str = str + "<label for='logdec' class='labelR'>Logement d&eacute;cent</label>";
			str = str + "<input type='checkbox' name='diag' value='logdec' style='border:none;'><br />";
		}
		if(t_amiante != 0){
			str = str + "<label for='amiante' class='labelR'>Diagnostic Amiante</label>";
			str = str + "<input type='checkbox' name='diag' value='amiante' style='border:none;'><br />";
		}
		
	}else{
		// autre
		// rien de coché par défaut
		if(t_dpe_t != 0 && t_dpe_l != 0){
			str = str + "<label for='dpe' class='labelR'>Diagnostic Performance &Eacute;nerg&eacute;tique</label>";
			str = str + "<input type='checkbox' name='diag' value='dpe_t' style='border:none;'><br />";
		}
		if(t_ernt_t != 0 && t_ernt_l != 0){
			str = str + "<label for='ernt' class='labelR'>&Eacute;tat des Risques Naturels ou Technologiques</label>";
			str = str + "<input type='checkbox' name='diag' value='ernt' style='border:none;'><br />";
		}
		if(t_amiante != 0){
			str = str + "<label for='amiante' class='labelR'>Diagnostic Amiante</label>";
			str = str + "<input type='checkbox' name='diag' value='amiante' style='border:none;'><br />";
		}
		if(t_plomb_t != 0 && t_plomb_l != 0){
			str = str + "<label for='plomb' class='labelR'>Diagnostic Plomb</label>";
			str = str + "<input type='checkbox' name='diag' value='plomb' style='border:none;'><br />";
		}
		if(t_carrez != 0){
			str = str + "<label for='carrez' class='labelR'>Loi Carrez</label>";
			str = str + "<input type='checkbox' name='diag' value='carrez' style='border:none;'><br />";
		}
		if(t_termites != 0){
			str = str + "<label for='termites' class='labelR'>Termites<sup>1</sup></label>";
			str = str + "<input type='checkbox' name='diag' value='termites' style='border:none;'><br />";
		}
		if(t_ptz != 0){
			str = str + "<label for='ptz' class='labelR'>Normes de surfaces et habitabilit&eacute; (<acronym title='Pr&ecirc;t Taux Z&eacute;ro'>PTZ</acronym>)</label>";
			str = str + "<input type='checkbox' name='diag' value='ptz' style='border:none;'><br />";
		}
		if(t_edl != 0){
			str = str + "<label for='edl' class='labelR'>&Eacute;tat des lieux</label>";
			str = str + "<input type='checkbox' name='diag' value='edl' style='border:none;'><br />";
		}
		if(t_logdec != 0){
			str = str + "<label for='logdec' class='labelR'>Logement d&eacute;cent</label>";
			str = str + "<input type='checkbox' name='diag' value='logdec' style='border:none;'><br />";
		}
		if(t_gaz != 0){
			str = str + "<label for='gaz' class='labelR'>Diagnostic Gaz (installation de + 15 ans)</label>";
			str = str + "<input type='checkbox' name='diag' value='gaz' style='border:none;'><br />";
		}
		if(t_elec != 0){
			str = str + "<label for='gaz' class='labelR'>Electricit&eacute; (installation de + 15 ans )</label>";
			str = str + "<input type='checkbox' name='diag' value='elec' style='border:none;'><br />";
		}
		str = str + "<label for='milliemes' class='labelR'>Milli&egrave;mes de copropri&eacute;t&eacute;</label>";
		str = str + "<input type='checkbox' name='diag' value='milliemes' style='border:none;'><br />";
		str = str + "<label for='dti' class='labelR'>Diagnostic Technique Immoblier</label>";
		str = str + "<input type='checkbox' name='diag' value='dti' style='border:none;'><br />";
		if(t_robien != 0){
			str = str + "<label for='robien' class='labelR'>Constat de Robien</label>";
			str = str + "<input type='checkbox' name='diag' value='robien' style='border:none;'><br />";
		}
	}
	str = str + "</fieldset>";

	if(type_de_bien != 5 && termites != 0){
		str = str + "<span class='small-txt'> 1 : ne concerne pas forc&eacute;ment l'int&eacute;gralit&eacute; du d&eacute;partement</span>";
	}

	str = str + "<fieldset><legend align='top'>Vous</legend>";
	str = str + "<label for='civilite' style='width:120px'>Civilit&eacute; : </label><select name='civilite' style='width:120px'>";
	str = str + "<option value='Mr'>Monsieur</option>";
	str = str + "<option value='Mme'>Madame</option>";
	str = str + "<option value='Mlle'>Mademoiselle</option>";
	str = str + "</select><br />";
	str = str + "<label for='nom' style='width:120px'><strong>Nom : </strong></label><input name='nom' style='width:240px'><br />";
	str = str + "<label for='prenom' style='width:120px'>Pr&eacute;nom : </label><input name='prenom' style='width:240px'><br />";
	str = str + "<label for='adresse' style='width:120px'>Adresse : </label><textarea name='adresse' style='width:240px;height:28px;'></textarea><br />";
	str = str + "<label for='cp' style='width:120px'>Code Postal : </label><input name='cp' style='width:80px'><br />";
	str = str + "<label for='ville' style='width:120px'>Ville : </label><input name='ville' style='width:240px'><br />";
	str = str + "<label for='tel' style='width:120px'><strong>T&eacute;l : </strong></label><input name='tel' style='width:120px'><br />";
	str = str + "<label for='email' style='width:120px'><strong>Email : </strong></label><input name='email' style='width:200px'><br />";
	str = str + "<span class='small-txt'>Si vous avez des commentaires sp&eacute;cifiques, nous vous recommandons des les indiquer directement &agrave; votre diagnostiqueur lors de la prise de rendez-vous</span>";
	str = str + "<div id='btnS3' align='right'>";
	str = str + "<input name='submit3' type='button' class='btnSubmit' style='width:80px' value='VALIDER' onkeydown=\"if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {doQueryForm3();return false;}else return true;\" onclick='doQueryForm3()' />";
	str = str + "</div>";
	str = str + "</form>";
	$('bloc-central').innerHTML = str;
	str2 = "<div style='position:absolute;top:40px;left:5px' class='small-txt'>";
	str2 = str2 + "<p>Conform&eacute;ment &agrave; la loi Informatiques et Libert&eacute;s du 6 janvier 1978, vous disposez d'un droit d'acc&eacute;s et de rectification aux donn&eacute;s personnelles vous concernant.</p>";
	str2 = str2 + "<p>Seule notre soci&eacute;t&eacute; est destinataire des informations que vous lui communiquez.</p>";
	str2 = str2 + "</div>";
	$('a-retenir').innerHTML = str2;
	

}

function doQueryForm3(){
	var cfcObj = new Object();
	cfcObj.type_besoin = document.form3.type_besoin.value;
	cfcObj.type_de_bien = document.form3.type_de_bien.value;
	cfcObj.type_de_bien_autre = document.form3.type_de_bien_autre.value;
	cfcObj.code_postal = document.form3.code_postal.value;
	cfcObj.code_canton = document.form3.code_canton.value;
	cfcObj.commune = document.form3.commune.value;
	cfcObj.annee_construction = document.form3.annee_construction.value;
	cfcObj.nbre_pieces = document.form3.nbre_pieces.value;
	cfcObj.dependances = document.form3.dependances.value;
	cfcObj.id_expert = document.form3.id_expert.value;
	cfcObj.tarif = document.form3.tarif.value;
	cfcObj.termites = document.form3.termites.value;
	var lesdiag = document.form3.diag;
	cfcObj.listDiag = new Array();
	for(i=0;i<lesdiag.length;i++){
		if(lesdiag[i].checked == true){
			cfcObj.listDiag.push(lesdiag[i].value);
		}
	}
	cfcObj.civilite = document.form3.civilite.options[document.form3.civilite.selectedIndex].value;
	cfcObj.nom = document.form3.nom.value;
	cfcObj.prenom = document.form3.prenom.value;
	cfcObj.adresse = document.form3.adresse.value;
	cfcObj.cp = document.form3.cp.value;
	cfcObj.ville = document.form3.ville.value;
	cfcObj.tel = document.form3.tel.value;
	cfcObj.email = document.form3.email.value;
	// on vérifie le formulaire
	if(cfcObj.listDiag.length == 0){
		alert("Vous devez sélectionner au moins un diagnostic.");
	}else if(trim(cfcObj.nom) == ""){
		alert("Vous devez saisir votre nom.");
	}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{
		// on désactive le bouton
		document.form3.submit3.style.visibility = "hidden";
		// on affiche traitement en cours ...
		document.getElementById('btnS3').innerHTML = "<img src='/images/traitement_en_cours.gif'>";
		
		// ok, on envoie l'objet au cfc
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'step2', cfcObj, doQueryEndResults);	
	}
}
function doQueryEndResults(r){
	if(r.getRowCount() >=1 && r.resultat[0] == "pdfsent"){
		// pdf envoyé -> page remerciement en conséquence
		str = "";
		if(r.type_besoin[0] == 1){
			var titre = "VOUS VENDEZ ? NOUS DIAGNOSTIQUONS !";
			var type = "Votre demande concerne les diagnostics li&eacute;s &agrave; la vente de votre ";
		}else if(r.type_besoin[0] == 2){
			var titre = "VOUS LOUEZ ? NOUS DIAGNOSTIQUONS !";
			var type = "Votre demande concerne les diagnostics li&eacute;s &agrave; la location de votre ";
		}else{
			var titre = "VOUS VENDEZ ? VOUS LOUEZ ? NOUS DIAGNOSTIQUONS !";
			var type = "Votre demande concerne les diagnostics de votre ";
		}
		if(r.type_de_bien[0] == 1){
			var bien = "appartement ";
		}else if(r.type_de_bien[0] == 2){
			var bien = "maison individuelle ";
		}else if(r.type_de_bien[0] == 3){
			var bien = "maison en copropri&eacute;t&eacute; ";
		}else if(r.type_de_bien[0] == 4){
			var bien = "bureau ou local commercial ";
		}else if(r.type_de_bien[0] == 5){
			var bien = r.type_de_bien_autre[0] + " ";
		}
		if(r.annee_construction[0] == 1){
			var annee = "avant 1949";
		}else if(r.annee_construction[0] == 2){
			var annee = "entre 1949 et le 1er juillet 1997*";
		}else if(r.annee_construction[0] == 3){
			var annee = "apr&egrave; le 1er juillet 1997*";
		}
		//str = str + "<h1>" + titre + "</h1>";
		str = str + "<p>Nous avons bien not&eacute; votre demande de devis et vous remercions de la confiance que vous nous accordez.<br/><br/>";
		str = str + type + bien + "dont l'ann&eacute;e de construction se situe " + annee + " et dispose de " + r.nbre_pieces[0] + " pi&egrave;ce(s) principale(s), ";
		str = str + "pour les diagnostics : <br /><br /><strong>";
		var nbDiag = r.listdiag[0].length;
		var special = false;
		for(var i=0; i<nbDiag; i++){
			if(r.listdiag[0][i] == "amiante"){
				str = str + "- Amiante (permis de construire ant&eacute;rieur au 01/07/97)<br />";
			}else if(r.listdiag[0][i] == "carrez"){
				str = str + "- M&eacute;trage - Loi Carrez<br />";
			}else if(r.listdiag[0][i] == "dpe_l" || r.listdiag[0][i] == "dpe_t"){
				str = str + "- Diagnostic Performance &Eacute;nerg&eacute;tique<br />";
			}else if(r.listdiag[0][i] == "edl"){
				str = str + "- &Eacute;tat des lieux<br />";
			}else if(r.listdiag[0][i] == "ernt_l" || r.listdiag[0][i] == "ernt"){
				str = str + "- &Eacute;tat des Risques Naturels ou Technologiques<br />";
			}else if(r.listdiag[0][i] == "gaz"){
				str = str + "- Diagnostic Gaz<br />";
			}else if(r.listdiag[0][i] == "logdec"){
				str = str + "- Logement D&eacute;cent<br />";
			}else if(r.listdiag[0][i] == "plomb_l" || r.listdiag[0][i] == "plomb"){
				str = str + "- Diagnostic Plomb<br />";
			}else if(r.listdiag[0][i] == "ptz"){
				str = str + "- Normes de surfaces et Habitabilit&eacute; (PTZ)<br />";
			}else if(r.listdiag[0][i] == "robien"){
				str = str + "- Constat de Robien<br />";
			}else if(r.listdiag[0][i] == "elec"){
				str = str + "- Electricit&eacute;<br />";
			}else if(r.listdiag[0][i] == "termites"){
				str = str + "- Termites<br />";
			}else if(r.listdiag[0][i] == "milliemes"){
				special = true;
				str = str + "- Milli&egrave;mes de copropri&eacute;t&eacute;<br />";
			}else if(r.listdiag[0][i] == "dti"){
				special = true;
				str = str + "- Diagnostic Technique Immobilier<br />";
			}
		}
		str = str + "</strong><br />Lieu d'expertise : " + r.code_postal[0] + "<br /><br />";
		str = str + "Nous vous envoyons dans les plus brefs d&eacute;lais votre devis d&eacute;taill&eacute; et personnalis&eacute;.";
		if(special){
			str = str + " <em>Une partie de votre demande n&eacute;cessite une &eacute;tude plus approfondie, aussi nous vous contacterons dans les meilleurs d&eacute;lais</em>.<br /><br />";
		}else{
			str = str + "<br /><br />";	
		}
		str = str + "Si vous ne recevez pas de message, merci de v&eacute;rifier que l'adresse email que vous avez saisie <em>" + r.email[0] + "</em> est correcte.<br />"
		str = str + "Vous pouvez aussi nous appeler au " + r.exp_tel[0] + ".</p>";
		str = str + "<p><table width='100%' border='0'>";
		str = str + "<tr><td width='50%' align='center'>";
		if(r.type_besoin[0] == 1){
			str = str + "<a href='/components/tableauxInternet.cfc?method=printTabVierge&type_besoin=1' target='_blank'>T&eacute;l&eacute;chargez le tableau r&eacute;capitulatif des obligations li&eacute;es &agrave; la transaction<br /><img src='/images/agenda-diagnostic-immobilier-tableau-recapitulatif.jpg' alt='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' title='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' border='0'></a>";
		}else if(r.type_besoin[0] == 2){
			str = str + "<a href='/components/tableauxInternet.cfc?method=printTabVierge&type_besoin=2' target='_blank'>T&eacute;l&eacute;chargez le tableau r&eacute;capitulatif des obligations li&eacute;es &agrave; la location<br /><img src='/images/agenda-diagnostic-immobilier-tableau-recapitulatif.jpg' alt='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la location.' title='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la location.' border='0'></a>";
		}else{
			str = str + "<a href='/components/tableauxInternet.cfc?method=printTabVierge&type_besoin=1' target='_blank'>T&eacute;l&eacute;chargez le tableau r&eacute;capitulatif des obligations li&eacute;es &agrave; la transaction<br /><img src='/images/agenda-diagnostic-immobilier-tableau-recapitulatif.jpg' alt='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' title='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' border='0'></a>";
		}
		str = str + "</td><td width='50%' align='center'>";
		str = str + "<a href='/Agenda-diagnostic-immobilier-exemple-de-rapport.cfm'>Visualiser un rapport AGENDA</a> conforme &agrave; la r&eacute;glementation avec croquis, cartographie, photos, ...";
		str = str + "</td></tr></table></p>";

		str2 = "<div style='position:absolute;top:30px;'>";
		str2 = str2 + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='288' height='350' title='Les 5 &eacute;tapes du diagnostic Agenda'>";
		str2 = str2 + "    <param name='movie' value='movies/5-etapes.swf' />";
		str2 = str2 + "    <param name='quality' value='high' />";
		str2 = str2 + "    <param name='menu' value='false' />";
		str2 = str2 + "<embed src='movies/5-etapes.swf' width='288' height='350' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' menu='false'></embed>";
		str2 = str2 + "</object>";
		str2 = str2 + "</div>";
		// TAG Google
		str2 = str2 + "<img height=1 width=1 border=0 src=\"http://www.googleadservices.com/pagead/conversion/1064844388/imp.gif?value=1&label=signup&script=0\">";
		// TAG DOUBLECLICK
		str2 = str2 + "<img src='http://ad.fr.doubleclick.net/activity;src=1639101;type=devis829;cat=paged813;ord=1?' width=1 height=1 border=0>";
		$('bloc-central').innerHTML = str;
		$('a-retenir').innerHTML = str2;
		
	}else if(r.getRowCount() >=1 && r.resultat[0] == "nopdf"){
		// email envoyé sans pdf (pas de tarif dispo)
		str = "";
		if(r.type_besoin[0] == 1){
			var titre = "VOUS VENDEZ ? NOUS DIAGNOSTIQUONS !";
			var type = "Votre demande concerne les diagnostics li&eacute;s &agrave; la vente de votre ";
		}else if(r.type_besoin[0] == 2){
			var titre = "VOUS LOUEZ ? NOUS DIAGNOSTIQUONS !";
			var type = "Votre demande concerne les diagnostics li&eacute;s &agrave; la location de votre ";
		}else{
			var titre = "VOUS VENDEZ ? VOUS LOUEZ ? NOUS DIAGNOSTIQUONS !";
			var type = "Votre demande concerne les diagnostics de votre ";
		}
		if(r.type_de_bien[0] == 1){
			var bien = "appartement ";
		}else if(r.type_de_bien[0] == 2){
			var bien = "maison individuelle ";
		}else if(r.type_de_bien[0] == 3){
			var bien = "maison en copropri&eacute;t&eacute; ";
		}else if(r.type_de_bien[0] == 4){
			var bien = "bureau ou local commercial ";
		}else if(r.type_de_bien[0] == 5){
			var bien = r.type_de_bien_autre[0] + " ";
		}
		if(r.annee_construction[0] == 1){
			var annee = "avant 1949";
		}else if(r.annee_construction[0] == 2){
			var annee = "entre 1949 et le 1er juillet 1997*";
		}else if(r.annee_construction[0] == 3){
			var annee = "apr&egrave; le 1er juillet 1997*";
		}
		//str = str + "<h1>" + titre + "</h1>";
		str = str + "<p>Nous avons bien not&eacute; votre demande de devis et vous remercions de la confiance que vous nous accordez.<br/><br/>";
		str = str + type + bien + "dont l'ann&eacute;e de construction se situe " + annee + " et dispose de " + r.nbre_pieces[0] + " pi&egrave;ce(s) principale(s), ";
		str = str + "pour les diagnostics : <br /><br /><strong>";
		var nbDiag = r.listdiag[0].length;
		for(var i=0; i<nbDiag; i++){
			if(r.listdiag[0][i] == "amiante"){
				str = str + "- Amiante (permis de construire ant&eacute;rieur au 01/07/97)<br />";
			}else if(r.listdiag[0][i] == "carrez"){
				str = str + "- M&eacute;trage - Loi Carrez<br />";
			}else if(r.listdiag[0][i] == "dpe_l" || r.listdiag[0][i] == "dpe_t"){
				str = str + "- Diagnostic Performance &Eacute;nerg&eacute;tique<br />";
			}else if(r.listdiag[0][i] == "edl"){
				str = str + "- &Eacute;tat des lieux<br />";
			}else if(r.listdiag[0][i] == "ernt_l" || r.listdiag[0][i] == "ernt"){
				str = str + "- &Eacute;tat des Risques Naturels ou Technologiques<br />";
			}else if(r.listdiag[0][i] == "gaz"){
				str = str + "- Diagnostic Gaz<br />";
			}else if(r.listdiag[0][i] == "logdec"){
				str = str + "- Logement D&eacute;cent<br />";
			}else if(r.listdiag[0][i] == "plomb_l" || r.listdiag[0][i] == "plomb"){
				str = str + "- Diagnostic Plomb<br />";
			}else if(r.listdiag[0][i] == "ptz"){
				str = str + "- Normes de surfaces et Habitabilit&eacute; (PTZ)<br />";
			}else if(r.listdiag[0][i] == "robien"){
				str = str + "- Constat de Robien<br />";
			}else if(r.listdiag[0][i] == "elec"){
				str = str + "- Electricit&eacute;<br />";
			}else if(r.listdiag[0][i] == "termites"){
				str = str + "- Termites<br />";
			}else if(r.listdiag[0][i] == "milliemes"){
				str = str + "- Milli&egrave;mes de copropri&eacute;t&eacute;<br />";
			}else if(r.listdiag[0][i] == "dti"){
				str = str + "- Diagnostic Technique Immobilier<br />";
			}
		}
		str = str + "</strong><br />Lieu d'expertise : " + r.code_postal[0] + "<br /><br />";
		str = str + "Votre demande n&eacute;cessite une &eacute;tude plus approfondie, aussi nous vous contacterons dans les meilleurs d&eacute;lais.<br /><br />";
		str = str + "Vous pouvez aussi nous appeler au " + r.exp_tel[0] + ".</p>";

		str = str + "<p><table width='100%' border='0'>";
		str = str + "<tr><td width='50%' align='center'>";
		if(r.type_besoin[0] == 1){
			str = str + "<a href='/components/tableauxInternet.cfc?method=printTabVierge&type_besoin=1' target='_blank'>T&eacute;l&eacute;chargez le tableau r&eacute;capitulatif des obligations li&eacute;es &agrave; la transaction<br /><img src='/images/agenda-diagnostic-immobilier-tableau-recapitulatif.jpg' alt='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' title='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' border='0'></a>";
		}else if(r.type_besoin[0] == 2){
			str = str + "<a href='/components/tableauxInternet.cfc?method=printTabVierge&type_besoin=2' target='_blank'>T&eacute;l&eacute;chargez le tableau r&eacute;capitulatif des obligations li&eacute;es &agrave; la location<br /><img src='/images/agenda-diagnostic-immobilier-tableau-recapitulatif.jpg' alt='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la location.' title='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la location.' border='0'></a>";
		}else{
			str = str + "<a href='/components/tableauxInternet.cfc?method=printTabVierge&type_besoin=1' target='_blank'>T&eacute;l&eacute;chargez le tableau r&eacute;capitulatif des obligations li&eacute;es &agrave; la transaction<br /><img src='/images/agenda-diagnostic-immobilier-tableau-recapitulatif.jpg' alt='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' title='T&eacute;l&eacute;chargez le tableau r&eacute;capitulatifs des obligations li&eacute;es &agrave; la transaction.' border='0'></a>";
		}
		str = str + "</td><td width='50%' align='center'>";
		str = str + "<a href=''/Agenda-diagnostic-immobilier-exemple-de-rapport.cfm'>Visualiser un rapport AGENDA</a> conforme &agrave; la r&eacute;glementation avec croquis, cartographie, photos, ...";
		str = str + "</td></tr></table></p>";
		
		str2 = "<div style='position:absolute;top:30px;'>";
		str2 = str2 + "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='288' height='350' title='Les 5 &eacute;tapes du diagnostic Agenda'>";
		str2 = str2 + "    <param name='movie' value='movies/5-etapes.swf' />";
		str2 = str2 + "    <param name='quality' value='high' />";
		str2 = str2 + "    <param name='menu' value='false' />";
		str2 = str2 + "<embed src='movies/5-etapes.swf' width='288' height='350' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' menu='false'></embed>";
		str2 = str2 + "</object>";
		str2 = str2 + "</div>";
		// TAG Google
		str2 = str2 + "<img height=1 width=1 border=0 src=\"http://www.googleadservices.com/pagead/conversion/1064844388/imp.gif?value=1&label=signup&script=0\">";
		// TAG DOUBLECLICK
		str2 = str2 + "<img src='http://ad.fr.doubleclick.net/activity;src=1639101;type=devis829;cat=paged813;ord=1?' width=1 height=1 border=0>";
		
		$('bloc-central').innerHTML = str;
		$('a-retenir').innerHTML = str2;
	}
}
