var MyForm1;
Ext.onReady(function() {
	var Q1Label = "Votre mutualité actuelle";
	var Q1questions = new Array(
			"Inscrit auprès de Partenamut",
			"Inscrit auprès d’une autre mutualité belge",
			"Inscrit auprès d’un autre régime belge de soins de santé (Ossom, SNCB...)",
			"Inscrit auprès d’un organisme de droit européen ayant son siège social en Belgique (OTAN, Shape, UE…)",
			"Arrivé de l’étranger");

	var Q2questions = new Array("Personnellement comme titulaire",
			"Comme personne à charge");

	var Q3Label = "Votre Situation";
	var Q3questions = new Array("Employé", "Agent du service public", "Ouvrier",
			 "Indépendant", "Demandeur d'emploi indemnisé", "Pensionné",
			"Etudiant", "Handicapé", "Veuf", "Résident", "Pas repris");

	var Q4Label = "Votre état civil";
	var Q4questions = new Array("Célibataire", "Marié", "Veuf", "Séparé",
			"Divorcé", "Cohabitant légal");

	var Q7Label = "Vous souhaitez vous affilier à";
	var Q7questions = "Hospitalia Plus &nbsp;";

	var Q8Label = "Vous souhaitez vous affilier à";
	var Q8questions = "Dentalia Plus &nbsp;";
	

	var Q9Label = 'Etes-vous inscrit au Guichet en ligne';
	var Q9questions = new Array("Non", "Oui");

	var Q10Label = "Etes vous d\'accord d\'utiliser le Guichet en ligne?";
	var Q10questions = new Array("Non", "Oui");

	var Q11Label = "Voulez-vous vous inscrire au Guichet en ligne?";
	var Q11questions = new Array("Non", "Oui");
	
	
	var lblSmryNom = "<strong>Nom</strong>";
	var lblSmryPrenom = "<strong>Prenom</strong>";
	var lblSmrySexe = "<strong>Sexe</strong>";
	var lblSmryDna = "<strong>Date de naissance</strong> ";
	var lblSmryDnaFormat = " <br /><strong>(jj/mm/aaaa)</strong>";
	var lblSmryNat = "<strong>Nationalité</strong>";
	var lblSmryNrn = "<strong>N° de registre national</strong>";
	var lblSmryRue = "<strong>Rue</strong>";
	var lblSmryNum = "<strong>N°</strong>";
	var lblSmryBp = "<strong>Boite</strong>";
	var lblSmryCp = "<strong>Code Postal</strong>";
	var lblSmryVille = "<strong>Ville</strong>";
	var lblSmryPays = "<strong>Pays</strong>";
	var lblSmryTel = "<strong>N° de GSM/tel</strong>";
	var lblSmryEmail = "<strong>Adresse e-mail</strong>";
	var lblSmryNumCompte = "<strong>Numéro de compte</strong>";
	var lblSmryIban = "<strong>Compte IBAN</strong>";
	var lblSmryMethPay = "Paiement par";
	var lblSmrySis = "<strong>Carte SIS</strong>";
	var lblSmryDateSis = "<strong>Date de validité (carte SIS)</strong>";
	var msgErrorForm= "<p class='msgError'>Une erreur est présente dans le formulaire, veuillez vérifier vos donnnées personnelles.</p>";
	var lblMethPay = new Array("Domiciliation mensuelle",
			"Virement trimestriel", "Virement semestriel", "Virement annuel");
			
	var ttp1TxtTitre = "Hospitalia";			
	var ttp1Txt = 	"Hospitalia est une assurance facultative offrant plusieurs niveaux de couverture des frais liés à une hospitalisation."
					+"L’affiliation à Hospitalia n’est possible qu’avant l’âge de 66 ans (60 ans pour Hospitalia ambulatoire)";
	var ttp2TxtTitre = "Dentalia Plus";			
	var ttp2Txt = "Dentalia Plus est une couverture soins dentaires facultative "
					+"La liste des prestations remboursées par Dentalia Plus est longue : les soins dentaires préventifs et curatifs, les prothèses et implants, sans oublier l’orthodontie. "
					+"L'affiliation à Dentalia Plus n'est possible qu'avant l'âge de 65 ans.";
	var ttp3TxtTitre = "Le guichet en ligne";			
	var ttp3Txt = "Le guichet en ligne \"Partenamut@home\" est un espace sécurisé et réservé aux clients de Partenamut, qui vous offre les facilités suivantes : "
+"consulter et imprimer des détails des remboursements, "
+"être averti par e-mail d'un remboursement, "
+"imprimer les documents d'intervention de l'assurance complémentaire, "
+"consulter et imprimer le détail de vos indemnités en cas d'incapacité de travail, "
+"consulter votre dossier personnel et en modifier certains paramètres ou données, "
+"commander des documents (vignettes, séjour à l'étranger, ?). "
+"vous connecter via votre carte d'identité électronique (eID), "
+"donner ou retirer une procuration pour une personne à charge, "
+"consulter les accords du médecin conseil, "
+"calculer les économies possibles en cas d'utilisation des médicaments génériques. ";
	var ttp4TxtTitre = "Personne à charge";			
	var ttp4Txt = "Une personne à charge est une personne qui dispose des droits aux soins de santé par l’intermédiaire d’un titulaire. Il peut s’agir d’un enfant, d’un conjoint, d’un cohabitant ou d’un ascendant pour autant que ses revenus annuels n’excèdent pas 2.191,85 EUR bruts par trimestre.";
	var ttp5TxtTitre = "Paiement cotisation";			
	var ttp5Txt = "L'affiliation à l'assurance complémentaire est obligatoire pour tout membre de Partenamut. Toutefois, une seule cotisation à l'assurance complémentaire est due par ménage."
				+ "<br>Les cotisations sont payables anticipativement. "
				+ "<br>Vous avez le choix de l'étalement. Vous pouvez payer mensuellement (domiciliation bancaire obligatoire), trimestriellement, ou annuellement.";
	
	var ttp6TxtTitre = 'Titulaire';
	var ttp6Txt = 'Personne qui dispose d\'une inscription auprès de la mutualité à titre personnel et qui a donc droit à des indemnités et des remboursements de soins de santé pour elle-même et pour ses personnes à charge';
	var ttTravIndTitre= 'Demandeur d’emploi indemnisé';
	var ttTravIndTxt= 'Un demandeur d’emploi indemnisé est une personne sans emploi qui a terminé son stage d’attente et perçoit des indemnités de chômage';
	var ttResidentTitre= 'Résident';
	var ttResidentTxt= 'Les personnes visées sont les personnes qui : '; 
	ttResidentTxt+='<br>- résident officiellement en Belgique et sont inscrites dans les registres de la population (registre d\'attente/registre bis)'; 
	ttResidentTxt+='<br>ou';
    ttResidentTxt+='<br>- viennent de l\'étranger et sont en possession des documents légaux pouvant justifier leur qualité ';
    var ttAscendantTitre='Ascendant';
    var ttAscendantTxt='L\'ascendant a un lien de parenté plus élevé avec le titulaire ou son conjoint. Il peut s\'agir de la mère ou du père, de la belle-mère ou du beau-père, de la grand-mère ou du grand-père, de l\'arrière-grand-mère ou de l\'arrière-grand-père';
    var ttNrnTitre='N° de registre national';
    var ttNrnTxt='Le numéro de registre national est attribué par  le Registre national en vue de l\'identification de toute personne et  utilisé comme numéro d\'identification de la Sécurité Sociale.';    
    ttNrnTxt+='<br>Ce numéro se compose de 11 chiffres (6 positions - 3 positions - 2 positions). Vous trouvez ce numéro qui commence par la date de naissance inversée au verso de votre carte d\'identité,  en haut à droite de votre carte SIS ou sur vos vignettes.';
    var ttSisTitre='Carte SIS';
    var ttSisTxt='La carte SIS (Système d’Information System) a pour objectif : d’améliorer l’identification des personnes bénéficiant du système de la sécurité sociale, de permettre aux prestataires de soins  (pharmaciens,'; 
    ttSisTxt+='hôpitaux..) d’accéder facilement  aux données personnelles de la sécurité sociale, et de simplifier les démarches.';
    ttSisTxt+='La carte SIS possède  une puce électronique qui contient des informations. Pour les lire ou les mettre à jour, la mutualité utilisera un lecteur de carte SIS. Seules certaines institutions '; 
    ttSisTxt+='bien spécifiques peuvent lire ou modifier vos données.';
    ttNumSisTitre='';
    ttNumSisTxt='Le numéro de votre carte SIS se compose de 10 chiffres. Ce numéro se trouve dans la partie inférieure gauche de votre carte';
    ttDateSisTitre='';
    ttDateSisTxt='la date d’émission de votre carte SIS se trouve dans la partie inférieure droite de votre carte SIS';
	var regNationExpl = "Le numéro national nous permet de traiter rapidement et correctement votre dossier. Si vous n’avez pas ce numéro sous la main, vous pouvez passer à la suite du formulaire et remplir cette donnée ultérieurement. ";
	
	
	Ext.QuickTips.init();
	Ext.QuickTips.enable();
	Ext.BLANK_IMAGE_URL = 'scripts/ext/resources/images/default/s.gif';
	// turn on validation errors beside the field globally
	Ext.form.Field.prototype.msgTarget = 'side';
	var cp = new Ext.state.CookieProvider();
	Ext.state.Manager.setProvider(cp);
	var cook = Ext.state.Manager.getProvider();
	var form_bloc2_1;
	var form_bloc2_2;
	var form_bloc3;
	var form_bloc4;
	var idDB = 0;
	var label_bloc2_1;
	var label_bloc2_2;
	var label_bloc3;
	var label_bloc4;
	var form_bloc5;
	var rb_titut_1;
	var rb_persacharg_1;
	var rb_titut_2;
	var rb_persacharg_2;
	var lbl_cmb_mut;
	var cmb_mut;
	var gridForm;
	var formContact;
	var objInstantStep = {
		nom : "",
		prenom : "",
		mail : ""
	};
	// Define title form
	var ds = new Ext.data.Store({
				reader : new Ext.data.ArrayReader({}, [{
									name : 'persacharg_nom'
								}, {
									name : 'persacharg_prenom'
								}, {
									name : 'persacharg_dna',
									dateFormat : 'd/m/Y'
								}, {
									name : 'persacharg_type'
								}, {
									name : 'persacharg_inscr'
								}, {
									name : 'persacharg_tit'
								}])
			});
	// test
	var store_mut = new Ext.data.JsonStore({
				url : 'servlet/ManageNumMut',
				root : 'json',
				fields : ['id', 'name']
			});
	var store_country = new Ext.data.JsonStore({
		url : 'servlet/GetCountry',
		root : 'json',
		fields : ['id', 'name']
	});
	store_country.load();
	function saveDNA(ev,newValue,oldValue) {
		Ext.Ajax.request({
		   url: 'servlet/SaveDNA',
		   params: { DNA: newValue.format("d/m/Y"),
			         id : idDB}
		});
	}
	function saveTel(ev,newValue,oldValue) {
		Ext.Ajax.request({
		   url: 'servlet/SaveTel',
		   params: {
			prefix: MyForm1.getForm().findField("frmCont_prefixe").getValue(),
			tel: newValue,
			id : idDB
		   }
		});
	}
	
	function googleFct(adr) {
//		try {
//			var pageTracker = _gat._getTracker("UA-9290762-1");
//			pageTracker._trackPageview(adr);
//		} catch(err) {}
	}
	function addFieldSet(fieldSet, index, somethingToAdd) {
		
		Ext.getCmp("panel1").enable();
		Ext.getCmp("panel2").disable();
		Ext.getCmp("panel3").disable();
		Ext.getCmp("panel4").disable();

		for (var i = MyForm1.findById("panel1").items.keys.length - 1; i > index; i--) {
			MyForm1.findById("panel1").remove(MyForm1.findById("panel1").items
					.itemAt(i));
		}
		if (somethingToAdd) {
			MyForm1.findById("panel1").remove(MyForm1.findById("jauge"));
			var jaugeValue= 0;
			var items = MyForm1.findById("panel1").items.keys.length;
			if (items < 4) 
			 	jaugeValue = items * 20;
			else 
				jaugeValue = 60 + (items -3) * 10;
			jauge_bloc = new Ext.form.Label({
				name : "jauge",
				id : "jauge",
				html : "<a name='show_"
						+ fieldSet.id
						+ "'>&nbsp;</a><div id='ProgresBar'><span class='TitlePercent'>Saisie de vos données personnelles faite à: </span> <img class='ImgPercent' src='images/loader_"
						+ jaugeValue + ".gif'/><span class='TxTPercent'>&nbsp;&nbsp;"
						+ jaugeValue + "%</span></div>"
			});
			MyForm1.findById("panel1").items
					.itemAt(MyForm1.findById("panel1").items.keys.length - 1)
					.removeClass("extHL");
			fieldSet.addClass("extHL");
			MyForm1.findById("panel1").add(jauge_bloc);
			MyForm1.findById("panel1").add(fieldSet);
			MyForm1.doLayout();
			buildToolTip();
			fieldSet.form = MyForm1.getForm();
			MyForm1.initFields.call(fieldSet);

			strQueryAll = Ext.DomQuery.select("img[src*=formArrow]");
			for (var i = 0; i < strQueryAll.length; i++) {
				Ext.get(strQueryAll[i]).remove();
			}
			strQuery = "#" + fieldSet.id + " h1";
			Ext
					.get(Ext.DomQuery.select(strQuery)[0])
					.insertHtml("beforeBegin",
							"<img src='images/formArrow.png' style='float:left; height:14px'/>");

			var staticHeight = 500;
			var vpHeight = Ext.getBody().getViewSize().height;
			var heightForm = MyForm1.getSize().height;
			var totalHeight = staticHeight + heightForm;
			if (totalHeight > vpHeight) {
				/*Scroll method from extJs are buggy
				 * switch to pur javascript to get the scroll offset*/
				var scrOfY = 0
				if (typeof(window.pageYOffset) == 'number') {
					// Netscape compliant
					scrOfY = window.pageYOffset;
				} else if (document.body
						&& (document.body.scrollLeft || document.body.scrollTop)) {
					// DOM compliant
					scrOfY = document.body.scrollTop;
				} else if (document.documentElement
						&& (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
					// IE6 standards compliant mode
					scrOfY = document.documentElement.scrollTop;
				}
				var scrollValue = totalHeight - vpHeight - scrOfY;
				window.scrollBy(0, scrollValue);
			};

		}
	}
	function chooseBank(item, checked) {
		if (item.inputValue == '1' && checked == true) {
			/*Ext.getCmp("panel_iban").hide();
			Ext.getCmp("panel_bank").show();*/
			MyForm1.getForm().findField("frmCont_numCompt1").enable();
			MyForm1.getForm().findField("frmCont_numCompt2").enable();
			MyForm1.getForm().findField("frmCont_numCompt3").enable();	
			
			MyForm1.getForm().findField("frmCont_numIban1").disable();
			MyForm1.getForm().findField("frmCont_numIban2").disable();
			MyForm1.getForm().findField("frmCont_numIban3").disable();
			MyForm1.getForm().findField("frmCont_numIban4").disable();
		} else if (item.inputValue == '2' && checked == true) {
			/*Ext.getCmp("panel_bank").hide();
			Ext.getCmp("panel_iban").show();*/
			MyForm1.getForm().findField("frmCont_numCompt1").disable();
			MyForm1.getForm().findField("frmCont_numCompt2").disable();
			MyForm1.getForm().findField("frmCont_numCompt3").disable();
			
			MyForm1.getForm().findField("frmCont_numIban1").enable();
			MyForm1.getForm().findField("frmCont_numIban2").enable();
			MyForm1.getForm().findField("frmCont_numIban3").enable();
			MyForm1.getForm().findField("frmCont_numIban4").enable();
		}
	}
	function chooseQuestGok(item, checked) {
		MyForm1.getForm().submit({
			url : 'servlet/ProcessQ9',
			params : {
				id : idDB
			},
			success : function(form, action) {
				if (item.inputValue == '1' && checked == true) {
					idToInsert = MyForm1.findById("panel1").items
							.indexOfKey("idQuestionGok");
					addFieldSet(buildUseGok(), idToInsert, true);
					MyForm1.doLayout();
				} else if (item.inputValue == '0' && checked == true) {
					idToInsert = MyForm1.findById("panel1").items
							.indexOfKey("idQuestionGok");
					addFieldSet(buildInscriptionGok(), idToInsert, true);
					MyForm1.doLayout();
				}
			}
		});
	}
	function chooseUseGok(item, checked) {
		MyForm1.getForm().submit({
			url : 'servlet/ProcessQ10',
			params : {
				id : idDB
			},
			success : function(form, action) {
				if (item.inputValue == '1' && checked == true) {
					window.open(
							'https://www.partenamut.be/jsp/mah/mutathome2.jsp',
							'_blank');
				} else if (item.inputValue == '0' && checked == true) {
					idToInsert = MyForm1.findById("panel1").items
							.indexOfKey("idUseGok");
					addFieldSet(buildNrn(), idToInsert, true);
					MyForm1.doLayout();
				}
			}
		});
	}
	function chooseInscrGok(item, checked) {
		MyForm1.getForm().submit({
			url : 'servlet/ProcessQ11',
			params : {
				id : idDB
			},
			success : function(form, action) {
				if (item.inputValue == '1' && checked == true) {
					window.open(
							'https://www.partenamut.be/jsp/mah/mutathome2.jsp',
							'_blank');
				} else if (item.inputValue == '0' && checked == true) {
					idToInsert = MyForm1.findById("panel1").items
							.indexOfKey("idInscriptionGok");
					addFieldSet(buildNrn(), idToInsert, true);
					MyForm1.doLayout();
				}
			}
		});
	}
	function buildMissField() {
		var resultMissField = "<ul id='missingData'>"
		var checkSis = 0
		for (var keyForm in valForm) {
			if (valForm[keyForm] == "") {
				switch (keyForm) {
					case "frmCont_numRegNat" :
						resultMissField += "<li>" + lblSmryNrn + "</li>";
						break;
					case "frmCont_pays" :
						resultMissField += "<li>" + lblSmryPays + "</li>";
						break;
					case "frmCont_dateSis" :
						resultMissField += "<li>" + lblSmryDateSis + "</li>";
						break;
					case "frmCont_bp" :
						break;
					case "frmCont_cour_bp" :
						break;
					default :
						if (keyForm.indexOf('frmCont_cartSis') != -1
								&& checkSis == 0) {
							resultMissField += "<li>" + lblSmrySis + "</li>";
							checkSis = 1;
						}
						break;
				}
			}
		}
		if (MyForm1.getForm().findField('frmCont_rb_compte').getValue()) {
			if ((MyForm1.getForm().findField('frmCont_numCompt1')
						.getRawValue() == "")
						|| (MyForm1.getForm().findField('frmCont_numCompt2')
								.getRawValue() == "") || (MyForm1.getForm()
						.findField('frmCont_numCompt3').getRawValue() == "")) {
				resultMissField += "<li>Données bancaires manquantes</li>";
			}
		} else {
			if ((MyForm1.getForm().findField('frmCont_numIban1')
				.getRawValue() == "")
				|| (MyForm1.getForm().findField('frmCont_numIban2')
						.getRawValue() == "")
				|| (MyForm1.getForm().findField('frmCont_numIban3')
						.getRawValue() == "")
				|| (MyForm1.getForm().findField('frmCont_numIban4')
						.getRawValue() == "")) {
				resultMissField += "<li>Données bancaires manquantes</li>";
			}
		}
		resultMissField += "</ul>";
		return resultMissField;
	}
	function fctReturnBegin() {
		window.location.hash = "#show_contact";
		Ext.getCmp("panel1").enable();
		Ext.getCmp("panel2").enable();
		Ext.getCmp("panel3").enable();
		Ext.getCmp("idTabPanel").activate(0);
		MyForm1.doLayout();
	}
	function confirmForm() {
		var json;
		json = '[';
		var grid = Ext.getCmp('company-grid');
		if (grid != null) {
			var store = grid.getStore();
			try {
				store.each(function(store) {
							if (typeof(store.data.persacharg_dna) == "object") {
								store.data.persacharg_dna = store.data.persacharg_dna
										.format("d/m/Y");
							}
							json += Ext.util.JSON.encode(store.data) + ',';
						});
			} catch (err) {
				Ext.MessageBox.alert('ERROR', 'Could not encode');
			}
			if (json.length > 1) {
				json = json.substring(0, json.length - 1);
			}
		}
		json += ']';
		var myParams = {
			gridStore : json,
			foo : 'bar',
			id : idDB
		};
		if (MyForm1.getForm().isValid()) {
			MyForm1.getForm().submit({
				url : 'servlet/ProcessFullForm',
				params : myParams,
				waitMsg: 'Veuillez patienter, votre demande est en cours de traitement...',
				success : function(form, action) {
					window.location.hash = "#show_contact";
					Ext.getCmp("panel1").disable();
					Ext.getCmp("panel2").disable();
					Ext.getCmp("panel3").disable();
					Ext.getCmp("panel4").enable();
					Ext.getCmp("idTabPanel").activate(3);
					MyForm1.doLayout();
					valForm = MyForm1.getForm().getValues();
					_gaq.push(['_trackPageview', '/analytics/affiliationExpress/documents']);
					googleFct('/documents');
					Ext.get("downloadContent").update('<img height="1" width="1" border="0" src="https://www.googleadservices.com/pagead/conversion/1071984101/?label=4IznCKb8hwEQ5duU_wM&amp;guid=ON&amp;script=0"/><img src="http://action.metaffiliation.com/suivi.php?mclic=S432751013&argann='+idDB+'" width="1" height="1" border="0">');
					if (MyForm1.getForm().findField("rb_download").getGroupValue()==1) {
						Ext.get("downloadContent").insertHtml("beforeEnd","<div id='id_show_packages'></div>");					
						var txtDownloadFormality="Complétez les données non remplies, signez ces documents et renvoyez-les à : <br />";
						txtDownloadFormality+="<strong>";
						txtDownloadFormality+="Partenamut - Service Clients<br />";
						txtDownloadFormality+="Boulevard Anspach 1<br />";
						txtDownloadFormality+="1000 Bruxelles.</strong>";
						txtDownloadFormality+="Ou déposez-les dans une de <a href='http://www.partenamut.be/web/guest/nos-adresses' title='' target='_blank'>nos agences Partenamut</a>.<br /><br />";
						txtDownloadFormality+="N'oubliez pas de coller une vignette de votre mutualité actuelle sur le document d’affiliation.<br />";
						txtDownloadFormality+="Nous nous chargeons de toutes les formalités avec votre ancienne mutualité et nous reprendrons contact avec vous dans les meilleurs délais.";
						
						Ext.get("downloadContent").insertHtml("beforeEnd","<p class='downloadFormality'>"+txtDownloadFormality+"</p>");
						Ext.get("downloadContent").insertHtml("beforeEnd","<div id='id_sumary_miss_field2'></div>");
						Ext.get("id_sumary_miss_field2").insertHtml("beforeEnd","<strong>Attention, vous n’avez pas encore complété les données suivantes :</strong>");
						Ext.get("id_sumary_miss_field2").insertHtml("beforeEnd",buildMissField());
						Ext.get("id_sumary_miss_field2").insertHtml("beforeEnd","<p class='downloadFormality'>L'absence de ces données peut entraîner un retard dans le traitement de votre demande.</p>");
						var txt_pack="";
					
						txt_pack+="<h2>Nous vous remercions pour votre demande d’inscription.</h2>";
						txt_pack+="<h3>Voici les documents à télécharger</h3>";
						txt_pack+="<ul id='pdfList'>";
						var jsonPdf=action.result.jsonPdf;
						for(var i=0;i<jsonPdf.length;i++) {
							txt_pack+="<li><a target='_blank' href='"+jsonPdf[i]["URL"]+"'>"+jsonPdf[i]["NAME"]+"</a></li>";
						}
						Ext.get("id_show_packages").insertHtml("beforeEnd",txt_pack);
					} 
					else {
						Ext.get("downloadContent").insertHtml("beforeEnd","<div id='id_show_packages'></div>");					
						var txtDownloadFormality="Il vous suffit de les compléter, de les signer et de nous les renvoyer à l’adresse suivante : <br />";
						txtDownloadFormality+="<strong>";
						txtDownloadFormality+="Partenamut - Service Clients<br />";
						txtDownloadFormality+="Boulevard Anspach 1<br />";
						txtDownloadFormality+="1000 Bruxelles.</strong>";
						txtDownloadFormality+="Ou déposez-les dans une de <a href='http://www.partenamut.be/web/guest/nos-adresses' title='' target='_blank'>nos agences Partenamut</a>.<br /><br />";
						txtDownloadFormality+="Dès réception des documents signés, nous reprendrons contact avec vous dans les meilleurs délais.";
						if(MyForm1.getForm().findField("id_rb_autre").checked) {
							txtDownloadFormality+="<br />Nous nous chargeons de toutes les formalités avec votre ancienne mutualité.<br />";
							txtDownloadFormality+="N’oubliez pas de coller une vignette de votre mutualité sur le document affiliation.";
						}
						Ext.get("downloadContent").insertHtml("beforeEnd","<p class='downloadFormality'>"+txtDownloadFormality+"</p>");						
						var txt_pack="";					
						txt_pack+="<h2>Nous vous remercions pour votre demande d’inscription.</h2>";
						txt_pack+="<h3>Vous recevrez sous peu par la poste vos documents d'affiliation.</h3>";
						Ext.get("id_show_packages").insertHtml("beforeEnd",txt_pack);
					}
				}
			});
		}
	}
	function getFrmCont() {
		var frmCont = new Ext.form.FieldSet({
					id : 'id_frm_cour',
					autoHeight : true,
					items : [{
								xtype : 'textfield',
								name : 'frmCont_cour_rue',
								allowBlank : false,
								validateOnBlur : false,
								width : '200px',
								fieldLabel : 'Rue'
							}, {
								xtype : 'textfield',
								name : 'frmCont_cour_num',
								allowBlank : false,
								validateOnBlur : false,
								width : '200px',
								fieldLabel : 'N°'
							}, {
								xtype : 'textfield',
								name : 'frmCont_cour_bp',
								width : '200px',
								fieldLabel : 'Boite'
							}, {
								xtype : 'textfield',
								name : 'frmCont_cour_CP',
								allowBlank : false,
								validateOnBlur : false,
								width : '200px',
								fieldLabel : 'Code Postal'
							}, {
								xtype : 'textfield',
								name : 'frmCont_cour_ville',
								allowBlank : false,
								validateOnBlur : false,
								width : '200px',
								fieldLabel : 'Ville'
							}, {
								xtype: "combo",
								name : "frmCont_cour_pays",
								//labelStyle : 'width:160px',
								width : '200px',
								fieldLabel : 'Pays',
								store : store_country,
								displayField : 'name',
								mode : 'local',
								triggerAction : 'all',
								editable : false,
								listWidth : 200,
								allowBlank : false,
								validateOnBlur : false,
								hiddenName : 'frmCont_cour_pays',
								valueField : 'id',
								emptyText : 'Sélectionnez un pays'
							}]
				});
		return frmCont;
	}
	function getLabel_bloc2_1() {
		label_bloc2_1 = new Ext.form.Label({
					name : "label_bloc2_1",
					html : "<h1>Vous êtes inscrit auprès de Partenamut</h1>"
				});
		return label_bloc2_1;
	}

	function getLabel_bloc2_2() {
		label_bloc2_2 = new Ext.form.Label({
			name : "label_bloc2_2",
			html : "<h1>Vous êtes inscrit auprès d’une autre mutualité belge</h1>"
		});
		return label_bloc2_2;
	}

	function buildTitle(id, msg) {
		title = new Ext.form.Label({
					id : "id_title" + id,
					html : "<span class='TitleSection'>" + msg + "</span>"
				});
		return title;
	}
	function changeTitle(id, msg) {
		title = new Ext.form.Label({
					id : "id_title" + id,
					html : "<span class='TitleSection'>" + msg + "</span>"
				});
	}
	function nextTab(ev, target, obj_arg) {
		if (ev.getValue().length == this.length) {
			Ext.get(this.nextId).focus();
		}
	}
	function validCompt1() {
		if (this.getValue().length == 3) {
			Ext.get("frmCont_numCompt2").focus();
		}
	}
	function validCompt2() {
		if (this.getValue().length == 7) {
			Ext.get("frmCont_numCompt3").focus();
		}
	}
	function validSis1() {
		if (this.getValue().length == 5) {
			Ext.get("frmCont_cartSis2").focus();
		}
	}
	function validSis2() {
		if (this.getValue().length == 3) {
			Ext.get("frmCont_cartSis3").focus();
		}
	}

	function getTitle1() {
		title1 = new Ext.form.Label({
					name : "label_bloc1",
					id : "id_title1",
					html : "<h1>" + Q1Label
							+ "</h1>A ce jour, vous êtes : "
				});
		return title1;
	}

	function getTitle2() {
		title2 = new Ext.form.Label({
			name : "label_bloc3",
			id : "id_title2",
			html : "<h1>Votre Situation.</h1>Vous demandez votre inscription comme:"
		});
		return title2;
	}

	function getTitle3() {
		title3 = new Ext.form.Label({
					name : "label_bloc4",
					id : "id_title3",
					html : "<h1>Votre situation familiale</h1>"
				});
		return title3;
	}

	function getTitle4() {
		title4 = new Ext.form.Label({
					name : "label_bloc4",
					id : "id_title4",
					html : "<h1>Vos données personnelles</h1>"
				});
		return title4;
	}
	function checkAssCompl() {
		if ((Ext.get("id_hosp").dom.checked == true)
				|| (Ext.get("id_dent").dom.checked == true)) {
			MyForm1.getForm().submit({
				url : 'servlet/ProcessQ6',
				params : {
					id : idDB
				},
				success : function(form, action) {
					//console.log('ProcessQ6');					
				}
			});
			if (Ext.get("idQuestionAssurance") && Ext.get("formContact")) {
			  	MyForm1.findById("formContact").remove(MyForm1.findById("idQuestionAssurance"));
			} 
			idToInsert = MyForm1.findById("panel1").items.indexOfKey("idQuestionAssurance");
			addFieldSet(buildQuestionGok(), idToInsert, true);
			MyForm1.doLayout();
			if (Ext.get("ttp3")) {
				var ttp3 = new Ext.ToolTip({
							target : "ttp3",
							title : ttp3TxtTitre,
							dismissDelay:0,
							html : ttp3Txt
						});
			}
		}
	}
	function checkNrn() {
		MyForm1.getForm().submit({
			url : 'servlet/ProcessQ8',
			params : {
				id : idDB
			},
			success : function(form, action) {
				/*
				shortForm = buildFormContact(true);
				if (MyForm1.findById("panel2").items != null) {
					for (var i = 0; i < MyForm1.findById("panel2").items.keys.length; i++) {
						MyForm1.findById("panel2").remove(MyForm1
								.findById("panel2").items.itemAt(i));
					}
				}
				MyForm1.findById("panel2").add(shortForm);
				Ext.getCmp("panel2").enable();
				Ext.getCmp("idTabPanel").activate(1);
				MyForm1.doLayout();
				shortForm.form = MyForm1.getForm();
				MyForm1.initFields.call(shortForm);
				window.location.hash = "#show_contact";
				Ext.getCmp("panel2").doLayout()
				*/
				step4 = buildStep4();
				idToInsert = MyForm1.findById("panel1").items.indexOfKey("idQuestionNrn");
				addFieldSet(step4, idToInsert, true);
				MyForm1.doLayout();
			}
		});
	}
	function getQuestionSitFam1() {
		questionSitFam = new Ext.form.Label({
			name : "label_questionSitFam",
			html : "<h1>Voulez-vous inscrire votre conjoint chez Partenamut? :</h1>"
		});
		return questionSitFam;
	}
	function getQuestionSitFam2() {
		questionSitFam = new Ext.form.Label({
			name : "label_questionSitFam",
			html : "<h1>Faut-il inscrire des personnes à votre charge? :</h1>"
		});
		return questionSitFam;
	}
	function getQuestionSitFam3() {
		questionSitFam = new Ext.form.Label({
			name : "label_questionSitFam",
			html : "<h1>Voulez vous inscrire votre compagnon(compagne) chez Partenamut? :</h1>"
		});
		return questionSitFam;
	}

	function getTitreAssurance() {
		var titre = "Souhaitez-vous vous affilier à : ";
		if (Ext.getCmp("id_rb_insc"))
			if (Ext.getCmp("id_rb_insc").checked)
				titre = "Vous souhaitez vous affilier à";
		return titre;
	}

	function getQuestionAssurance() {
		var titreAssurance = getTitreAssurance();
		var questionAssurance = new Ext.form.FieldSet({
			name : 'questionAssurance',
			id : 'idQuestionAssurance',
			autoHeight : true,
			items : [{
						xtype : 'label',
						html : "<h1>" + titreAssurance + "</h1>"
					}, {
						xtype : 'panel',
						layout : 'column',
						bodyBorder : false,
						border : false,
						hideBorders : true,
						items : [{
							xtype : "checkbox",
							boxLabel : Q7questions,
							name : "repQ7",
							id : "id_hosp",
							inputValue : "1",
							hideLabel : true
							}, {
							html : ' <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttp1">'
						}]
					}, {
						xtype : 'panel',
						layout : 'column',
						bodyBorder : false,
						border : false,
						hideBorders : true,
						items : [{
							xtype : "checkbox",
							boxLabel : Q8questions,
							name : "repQ8",
							id : "id_dent",
							inputValue : "1",
							hideLabel : true
							}, {
							html : ' <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttp2">'
						}]
					}]

		});
		return questionAssurance;
	}

	function buildToolTip() {
		if (Ext.get("ttp1")) {
			var ttp1 = new Ext.ToolTip({
						target : "ttp1",
						title : ttp1TxtTitre,
						dismissDelay:0,
						html : 	ttp1Txt
						});
		}
		if (Ext.get("ttp2")) {
			var ttp2 = new Ext.ToolTip({
						target : "ttp2",
						title : ttp2TxtTitre,
						dismissDelay:0,
						html : 	ttp2Txt
					});
		}
		if (Ext.get("ttp5")) {
			var ttp5 = new Ext.ToolTip({
						target : "ttp5",
						title : ttp5TxtTitre,
						dismissDelay:0,
						html : ttp5Txt
					});
		}
		
		if (Ext.get("tt3")) {
			tt3 = new Ext.ToolTip({
					target : 'tt3',
					title : ttp6TxtTitre ,
					dismissDelay:0,
					html : ttp6Txt
				});
		}	
		if (Ext.get("tt4")) {
			tt4 = new Ext.ToolTip({
				target : 'tt4',
				title : ttp4TxtTitre,
				dismissDelay:0,
				html : ttp4Txt
			});
		}
		if (Ext.get("tt1")) {
			tt1 = new Ext.ToolTip({
					target : 'tt1',
					title : ttp6TxtTitre,
					dismissDelay:0,
					html : ttp6Txt
				});
		}	
		if (Ext.get("tt2")) {
			tt2 = new Ext.ToolTip({
				target : 'tt2',
				title : ttp4TxtTitre,
				dismissDelay:0,
				html : ttp4Txt
			});
		}	
		
		if (Ext.get("ttp8")) {
			ttp8 = new Ext.ToolTip({
					target : 'ttp8',
					title : ttp6TxtTitre,
					dismissDelay:0,
					html : ttp6Txt
				});
		}	
		if (Ext.get("ttp7")) {
			ttp7 = new Ext.ToolTip({
				target : 'ttp7',
				title : ttp4TxtTitre,
				dismissDelay:0,
				html : ttp4Txt
			});
		}
		if (Ext.get("ttTravInd")) {
			ttTravInd = new Ext.ToolTip({
				target : 'ttTravInd',
				title : ttTravIndTitre,
				dismissDelay:0,
				html : ttTravIndTxt
			});
		}	
		if (Ext.get("ttResident")) {
			ttTravInd = new Ext.ToolTip({
				target : 'ttResident',
				title : ttResidentTitre,
				dismissDelay:0,
				html : ttResidentTxt
			});
		}			
		if (Ext.get("ttAscendant")) {
			ttAscendant = new Ext.ToolTip({
				target : 'ttAscendant',
				title : ttAscendantTitre,
				dismissDelay:0,
				html : ttAscendantTxt
			});
		}	
		if (Ext.get("ttNrn")) {
			ttNrn = new Ext.ToolTip({
				target : 'ttNrn',
				title : ttNrnTitre,
				dismissDelay:0,
				html : ttNrnTxt
			});
		}
		if (Ext.get("ttSis")) {
			ttSis = new Ext.ToolTip({
				target : 'ttSis',
				title : ttSisTitre,
				dismissDelay:0,
				html : ttSisTxt
			});
		}
		if (Ext.get("ttNumSis")) {
			ttNumSis = new Ext.ToolTip({
				target : 'ttNumSis',
				title : ttNumSisTitre,
				dismissDelay:0,
				html : ttNumSisTxt
			});
		}
		if (Ext.get("ttDateSis")) {
			ttDateSis = new Ext.ToolTip({
				target : 'ttDateSis',
				title : ttDateSisTitre,
				dismissDelay:0,
				html : ttDateSisTxt
			});
		}
	}
	
	
	
	

	function getQuestionSubscription() {
		var questionSubscript = new Ext.form.FieldSet({
			name : 'questionSubscript',
			id : 'idQuestionSubscript',
			autoHeight : true,
			items : [{
				xtype : 'label',
				html : "Pour votre facilité et votre sécurité, ainsi que pour le traitement rapide de votre demande, "
						+ "nous vous conseillons de réaliser la souscription via notre guichet en ligne  (?) (cf question 1)."
						+ "Si vous n’êtes pas encore inscrit à notre guichet en ligne, il suffit de vous y enregistrer et ensuite "
						+ "de souscrire à l’assurance de votre choix."
			}, {
				xtype : "radio",
				boxLabel : "Je suis déjà enregistré dans le guichet en ligne",
				name : "rb_question_sub",
				inputValue : "1",
				hideLabel : true
			}, {
				xtype : "radio",
				boxLabel : "Je ne suis pas encore enregistré au guichet en ligne / j’ai oublié mon mot de passe",
				name : "rb_question_sub",
				inputValue : "2",
				hideLabel : true
			}, {
				xtype : "radio",
				boxLabel : "Je ne souhaite pas utiliser le guichet en ligne pour souscrire à Hospitalia ou Dentalia Plus",
				name : "rb_question_sub",
				inputValue : "3",
				hideLabel : true
			}]
		});
		return questionSubscript;
	}
	var bd = Ext.get('content_center');

	var myData = [['fdsfs', 'hello', '9/1 12:00am', 'dqsdsq'],
			['fdscxwfs', 'helcxwlo', '9/1 12:00am', 'dqcxwsdsq']];
	var store_union = new Ext.data.SimpleStore({
				fields : ['union', 'idunion'],
				data : [
						['Alliance Nationale des Mutualités Chrétiennes', 1],
						['Union Nationale des Mutualités Neutres', 2],
						['Union Nationale des Mutualités Socialistes', 3],
						['Union Nationale des Mutualités Libérales', 4],
						['Union Nationale des Mutualités Libres', 5],
						['Caisse Auxiliaire d\'Assurance Maladie-Invalidité', 6],
						['Caisse des Soins de santé de la SNCB Holding', 9],
						['Je ne sais pas', 0]]
			});

	var sm2 = new Ext.grid.CheckboxSelectionModel({
				singleSelect : true,
				header : "",
				listeners : {
					rowselect : function(sm, row, rec) {
						// console.log(row);
						// Ext.getCmp("company-form").getForm().loadRecord(rec);
					}
				}
			});

	// ds.loadData(myData);

	// example of custom renderer function
	function italic(value) {
		return '' + value + '';
	}

	// example of custom renderer function
	function change(val) {
		if (val > 0) {
			return '' + val + '';
		} else if (val < 0) {
			return '' + val + '';
		}
		return val;
	}
	// example of custom renderer function
	function pctChange(val) {
		if (val > 0) {
			return '' + val + '%';
		} else if (val < 0) {
			return '' + val + '%';
		}
		return val;
	}

	// the DefaultColumnModel expects this blob to define columns. It can be
	// extended to provide
	// custom or reusable ColumnModels
	var colModel = new Ext.grid.ColumnModel([sm2, {
				id : 'persacharg_nom',
				header : "Nom",
				width : 150,
				sortable : true,
				menuDisabled: true,
				dataIndex : 'persacharg_nom'
			}, {
				header : "Prenom",
				width : 150,
				sortable : true,
				menuDisabled: true,
				dataIndex : 'persacharg_prenom'
			}, {
				header : lblSmryDna,
				width : 100,
				sortable : true,
				renderer : Ext.util.Format.dateRenderer('d/m/Y'),
				menuDisabled: true,
				dataIndex : 'persacharg_dna'
			}, {
				header : "Type",
				width : 60,
				sortable : true,
				locked : false,
				menuDisabled: true,
				dataIndex : 'persacharg_type'
			}, {
				header : "Inscrire",
				width : 60,
				sortable : true,
				locked : false,
				menuDisabled: true,
				dataIndex : 'persacharg_inscr'
			}, {
				header : "Titulaire",
				width : 60,
				sortable : true,
				locked : false,
				menuDisabled: true,
				dataIndex : 'persacharg_tit'
			}]);

	function showStep(ev, target, obj_arg) {
		Ext.getCmp('id_form_bloc1').show();
		Ext.getCmp('id_title1').getEl().removeListener('click', showStep, this);
	}
	function addToGrid() {
		if (Ext.getCmp('idFormPac').getForm().isValid()) {
			if (Ext.getCmp('add_Conjoint_Tit') != null) {
				if (Ext.getCmp('add_Conjoint_Tit').checked) {
					repQtit = "oui";
				} else {
					repQtit = "non";
				}
			} else {
				repQtit = "";
			}
			if (Ext.getCmp('add_conj_oui') != null
					&& Ext.getCmp('add_conj_oui').checked) {
				repIns = "oui";
			} else if (Ext.getCmp('add_conj_non') != null
					&& Ext.getCmp('add_conj_non').checked) {
				repIns = "non";
			} else if (Ext.getCmp('add_conj_deja') != null
					&& Ext.getCmp('add_conj_deja').checked) {
				repIns = "Déja inscrit";
			} else {
				repIns = "oui";
			}
			myData = [[Ext.getCmp('add_nom').getValue(),
					Ext.getCmp('add_prenom').getValue(),
					Ext.getCmp('add_DNA').getValue(),
					Ext.getCmp('add_Type').lastSelectionText, repIns, repQtit]];
			ds.loadData(myData, true);
			winForm.close();
		}
	}
	function editGrid() {
		if (Ext.getCmp('idFormPac').getForm().isValid()) {
			recSel = sm2.getSelections();
			recSel[0].set('persacharg_nom', Ext.getCmp('add_nom').getValue());
			recSel[0].set('persacharg_prenom', Ext.getCmp('add_prenom')
							.getValue());
			recSel[0].set('persacharg_dna', Ext.getCmp('add_DNA').getValue());
			recSel[0].set('persacharg_type',
					Ext.getCmp('add_Type').lastSelectionText);
			if (Ext.getCmp('add_conj_oui') != null
					&& Ext.getCmp('add_conj_oui').checked) {
				repIns = "oui";
			} else if (Ext.getCmp('add_conj_non') != null
					&& Ext.getCmp('add_conj_non').checked) {
				repIns = "non";
			} else if (Ext.getCmp('add_conj_deja') != null
					&& Ext.getCmp('add_conj_deja').checked) {
				repIns = "Déja inscrit";
			} else {
				repIns = "oui";
			}
			recSel[0].set('persacharg_inscr', repIns);
			if (Ext.getCmp('add_Conjoint_Tit') != null && Ext.getCmp('add_conj_oui').checked) {
				if(Ext.getCmp('add_Conjoint_Tit').checked) {
					repQtit = "oui";
				} else {
					repQtit = "non";
				}
			}
			else {
				repQtit = "";
			}
			recSel[0].set('persacharg_tit', repQtit);
			winForm.close();
		}
	}
	function clickConjoint(item, checked) {
		if (item.inputValue == "1" && checked) {
			Ext.getCmp("modalForm").findById("lbl_conjoint_pac").show();
			Ext.getCmp("modalForm").findById("add_Conjoint_Pac").show();
			Ext.getCmp("modalForm").findById("add_Conjoint_Tit").show();
		} else if(checked){
			Ext.getCmp("modalForm").findById("lbl_conjoint_pac").hide();
			Ext.getCmp("modalForm").findById("add_Conjoint_Pac").hide();
			Ext.getCmp("modalForm").findById("add_Conjoint_Tit").hide();			
		}
	}
	function buildFormPac(editPac, quesSup, choixSitFam) {
		var dataType;
		if (quesSup == false) {
			dataType = [['3', 'Enfant'], ['4', 'Ascendant']];
		} else {
			dataType = [['1', 'Conjoint'], ['2', 'Cohabitant'],
					['3', 'Enfant'], ['4', 'Ascendant']];
		}
		btSave = {
			xtype : 'button',
			text : 'Ajouter',
			name : 'btAdd',
			handler : addToGrid
		};
		if (editPac) {
			btSave.handler = editGrid;
			btSave.text = 'Modifier';
		}
		returnItem = Array();
		returnItem = [{
					id : 'add_nom',
					fieldLabel : 'Nom',
					labelStyle : 'width:195px; margin-left:5px',
					name : 'FirstName',
					allowBlank : false
				}, {
					id : 'add_prenom',
					fieldLabel : 'Prénom',
					labelStyle : 'width:195px; margin-left:5px',
					name : 'LastName',
					allowBlank : false
				}, {
					id : 'add_DNA',
					xtype : 'datefield',
					labelStyle : 'width:195px; margin-left:5px',
					fieldLabel : lblSmryDna + lblSmryDnaFormat,
					//hideTrigger : true,					
					invalidText : "Le format de la date doit être jj/mm/aaaa",
					name : 'DNA',
					format : 'd/m/Y',
					altFormats : 'dmY|d/m/Y|d-m-Y',
					allowBlank : false
				}, {
					id : 'add_Type',
					xtype : 'combo',
					name : "cmb_type",
					fieldLabel : 'Type',
					labelStyle : 'width:195px; margin-left:5px',
					store : dataType,
					triggerAction : 'all',
					editable : false,
					hiddenName : 'cmb_type',
					allowBlank : false
				}];
		if (quesSup) {
			itemConjointQ1 = [{
						xtype : 'label',
						html : 'Voulez vous inscrire votre conjoint chez Partenamut?',
						style : 'margin-left:5px'
					}, {
						xtype : "radio",
						boxLabel : "Oui",
						name : "radioChoixInscFam",
						id : "add_conj_oui",
						inputValue : "1",
						hideLabel : true,
						checked : false,
						handler : clickConjoint

					}, {
						xtype : "radio",
						boxLabel : "Non",
						name : "radioChoixInscFam",
						id : "add_conj_non",
						inputValue : "0",
						hideLabel : true,
						checked : false,
						handler : clickConjoint
					}, {
						xtype : "radio",
						boxLabel : "Déjà inscrit",
						name : "radioChoixInscFam",
						id : "add_conj_deja",
						inputValue : "2",
						hideLabel : true,
						checked : false,
						handler : clickConjoint
					}];
			itemConjointQ2 = [{
						xtype : 'label',
						id : 'lbl_conjoint_pac',
						html : 'Inscire votre conjoint en tant que :',
						hidden : 'true'
					}, {
						xtype : "radio",
						id : "add_Conjoint_Pac",
						boxLabel : 'Personne à charge <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttp7">',
						name : "radioChoixTit",
						inputValue : "0",
						hideLabel : true,
						checked : false,
						hidden : 'true'
					}, {
						xtype : "radio",
						id : 'add_Conjoint_Tit',
						boxLabel : 'Titulaire  <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttp8">',
						name : "radioChoixTit",
						inputValue : "1",
						hideLabel : true,
						checked : false,
						hidden : 'true'
					}];
			// if(!editPac) {
			returnItem = returnItem.concat(itemConjointQ1);
			/*
			 * } else{ itemConjointQ2[0].hidden=false;
			 * itemConjointQ2[1].hidden=false; itemConjointQ2[2].hidden=false; }
			 */
			returnItem = returnItem.concat(itemConjointQ2);
			if (choixSitFam == 2) {
				returnItem[3].value = 1;
			} else if (choixSitFam == 6) {
				returnItem[3].value = 2;
			}
		}
		returnItem.push(btSave);
		if (editPac) {
			recSel = sm2.getSelections();
			returnItem[0].value = recSel[0].get('persacharg_nom');
			returnItem[1].value = recSel[0].get('persacharg_prenom');
			returnItem[2].value = recSel[0].get('persacharg_dna');
			returnItem[3].value = recSel[0].get('persacharg_type');
			if (quesSup) {
				if(recSel[0].get('persacharg_inscr') == "oui") {
					returnItem[8].hidden = false;
					returnItem[9].hidden = false;
					returnItem[10].hidden = false;
					returnItem[5].checked = true;
				}
				else if(recSel[0].get('persacharg_inscr') == "non") {
					returnItem[6].checked = true;
				}
				else if(recSel[0].get('persacharg_inscr') == "Déjà inscrit") {
					returnItem[7].checked = true;
				}
				if (recSel[0].get('persacharg_tit') != "oui") {
					returnItem[9].checked = true;
				} else {
					returnItem[10].checked = true;
				}
			}
		}
		return returnItem;
	}
	function addPerson(conjoint) {
		if (conjoint != true) {
			conjoint = false;
		}
		itemsPac = buildFormPac(false, false, -1);
		winForm = new Ext.Window({
					id : "modalForm",
					modal : true,
					width : 400,
					title : 'Ajouter des personnes à votre charge',
					items : [{
								xtype : 'form',
								id : 'idFormPac',
								labelWidth : 195,
								defaultType : 'textfield',
								autoHeight : true,
								border : false,
								items : itemsPac
							}]
				});
		winForm.show();
		
	}
	function addPersonConjoint(choixSitFam) {
		itemsPac = buildFormPac(false, true, choixSitFam);
		winForm = new Ext.Window({
					id : "modalForm",
					modal : true,
					width : 400,
					title : 'Introduisez les coordonnées de votre conjoint/cohabitant',
					items : [{
								xtype : 'form',
								id : 'idFormPac',
								labelWidth : 195,
								defaultType : 'textfield',
								autoHeight : true,
								border : false,
								items : itemsPac
							}]
				});
			
		winForm.show();
		buildToolTip();	
		
	}

	function editPerson(conjoint) {
		recSel = sm2.getSelections();
		if (recSel[0].get('persacharg_tit') == "oui") {
			repQtit = true;
		} else {
			repQtit = false;
		}
		var quesSup = false
		if (Ext.getCmp("id_rb_marie").checked == true
				|| Ext.getCmp("id_rb_cohab").checked == true) {
			quesSup = true
		}
		itemsPac = buildFormPac(true, quesSup, -1);
		winForm = new Ext.Window({
					id : "modalForm",
					modal : true,
					width : 400,
					title : 'Modifier les infos de la personne',
					items : [{
								xtype : 'form',
								id : 'idFormPac',
								labelWidth : 195,
								defaultType : 'textfield',
								autoHeight : true,
								border : false,
								items : itemsPac
							}]
				});
		winForm.show();
	}

	var submitGrid = function() {
		var form, values, json;
		json = '[';
		form = MyForm1.getForm();
		var grid = Ext.getCmp('company-grid');
		var store = grid.getStore();

		try {
			store.each(function(store) {
						if (typeof(store.data.persacharg_dna) == "object") {
							store.data.persacharg_dna = store.data.persacharg_dna
									.format("d/m/Y");
						}
						json += Ext.util.JSON.encode(store.data) + ',';
					});
		} catch (err) {
			Ext.MessageBox.alert('ERROR', 'Could not encode');
		}
		if (json.length > 1) {
			json = json.substring(0, json.length - 1);
		}
		json += ']';
		var myParams = {
			gridStore : json,
			foo : 'bar',
			id : idDB
		};
		values = form.getValues();
		form.submit({
			method : 'POST',
			url : 'servlet/ProcessQ6',
			scope : gridForm,
			params : myParams,
			waitMsg : this.waitMsg,
			waitTitle : this.waitTitle
				// will only be applicable if no waitMsgTarget specified
			});
	};

	function buildQuestionGok() {
		var questionGok = new Ext.form.FieldSet({
			name : 'questionGok',
			autoHeight : true,
			id : 'idQuestionGok',
			items : [{
				xtype : 'label',
				html : '<h1>La souscription à Hospitalia ou Dentalia Plus se fait plus facilement <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;et rapidement par le guichet en ligne <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Etes-vous déjà inscrit à notre guichet en ligne ?<img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttp3"></h1>'
			}, {
				xtype : "radio",
				boxLabel : Q9questions[1],
				name : "repQ9",
				inputValue : "1",
				handler : chooseQuestGok,
				hideLabel : true
			}, {
				xtype : "radio",
				boxLabel : Q9questions[0],
				name : "repQ9",
				inputValue : "0",
				handler : chooseQuestGok,
				hideLabel : true
			}]
		});
		return questionGok;
	}

	function buildUseGok() {
		var useGok = new Ext.form.FieldSet({
			name : 'useGok',
			autoHeight : true,
			id : 'idUseGok',
			items : [{
						xtype : 'label',
						html : '<h1>Voulez-vous utiliser le guichet en ligne ?</h1>'
					}, {
						xtype : "radio",
						boxLabel : Q10questions[1],
						name : "repQ10",
						inputValue : "1",
						handler : chooseUseGok,
						hideLabel : true
					}, {
						xtype : "radio",
						boxLabel : Q10questions[0],
						name : "repQ10",
						inputValue : "0",
						handler : chooseUseGok,
						hideLabel : true
					}]
		});
		return useGok;
	}

	function buildInscriptionGok() {
		var inscriptionGok = new Ext.form.FieldSet({
					name : 'inscriptionGok',
					autoHeight : true,
					id : 'idInscriptionGok',
					items : [{
								xtype : 'label',
								html : '<h1>Voulez-vous vous inscrire au Guichet en ligne?</h1>'
							}, {
								xtype : "radio",
								boxLabel : Q11questions[1],
								name : "repQ11",
								inputValue : "1",
								handler : chooseInscrGok,
								hideLabel : true
							}, {
								xtype : "radio",
								boxLabel : Q11questions[0],
								name : "repQ11",
								inputValue : "0",
								handler : chooseInscrGok,
								hideLabel : true
							}]
				});
		return inscriptionGok;
	}

	function buildNrn() {
		var questionNrn = new Ext.form.FieldSet({
					name : 'questionNrn',
					id : 'idQuestionNrn',
					autoHeight : true,
					items : [{
								xtype : 'label',
								html : 'Indiquez votre numéro national?'
							}, {
								xtype : "textfield",
								name : "txt_Nrn",
								fieldLabel : "Numéro",
								selectOnFocus : true	
							}
							/*
							 * ,{ xtype: 'label', html: 'ou votrenuméro
							 * d\'affilié Partenamut qui se trouve sur vos
							 * vignettes de mutuelle?' },{ xtype: "textfield",
							 * name: "txt_num_aff", fieldLabel: "Numéro affilié" }
							 */
							, {
								xtype : "button",
								name : "bt_Nrn",
								text : "continuer",
								handler : checkNrn
							}]
				});
		return questionNrn;
	}
	function buildTxtNrn() {

	}

	function getItemsShortForm() {
		var items = [ {
					xtype : 'label',
					html : '<br /><p style="position:absolute; bottom: 40px; right: 20px;font-style: italic; font-size: 11px;" id="mandat_field">* champs obligatoires</p>'
				},{
					xtype : 'label',
					html : '<h1>Votre identité</h1>'
				}, {
					xtype : 'textfield',
					name : 'frmCont_nom',
					fieldLabel : 'Nom (de jeune fille)*',
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					value : objInstantStep.nom
				}, {
					xtype : 'textfield',
					name : 'frmCont_prenom',
					fieldLabel : 'Prénom*',
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					value : objInstantStep.prenom
				}, {
					xtype : 'combo',
					name : 'frmCont_sexe',
					fieldLabel : 'Sexe*',
					store : [['1', 'Masculin'], ['2', 'Féminin']],
					mode : 'local',
					triggerAction : 'all',
					editable : false,
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					hiddenName : 'frmCont_sexe'
				}, {
					xtype : 'datefield',
					name : 'frmCont_DNA',
					format : 'd/m/Y',
					altFormats : 'dmY|d/m/Y|d-m-Y',
					labelStyle : 'width:160px',
					//hideTrigger : true,
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					fieldLabel : lblSmryDna + lblSmryDnaFormat +' *',
					listeners:{
					    'change' : {
				        	fn: saveDNA
				    	}
					}
				}, {
					xtype: "combo",
					name : "frmCont_nat",
					labelStyle : 'width:160px',
					width : '200px',
					fieldLabel : 'Nationalité*',
					store : store_country,
					displayField : 'name',
					mode : 'local',
					triggerAction : 'all',
					listWidth : 200,
					hiddenName : 'frmCont_nat',
					allowBlank : false,
					validateOnBlur : false,
					value : 'B              ',
					valueField : 'id',
					emptyText : 'Sélectionnez un pays'
				}, {
					xtype : 'textfield',
					id : 'id_frm_nrn',
					autoCreate : {
						tag : "input",
						type : "text",
						maxlength : 11
					},
					minLength : 11,
					allowDecimals : false,
					allowNegative : false,
					validateOnBlur : false,
					name : 'frmCont_numRegNat',
					selectOnFocus : true ,
					labelStyle : 'width:160px',
					width : '200px',
					fieldLabel : 'N° de registre national'+' <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttNrn">'
				}, {
					xtype : 'label',
					id : 'frmCont_TxtRegExp',
					html : regNationExpl 
				}, {
					xtype : 'label',
					html : '<h1><br />Vos coordonnées</h1>'
				}, {
					xtype : 'textfield',
					name : 'frmCont_rue',
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					fieldLabel : 'Rue*'
				}, {
					xtype : 'textfield',
					name : 'frmCont_num',
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					fieldLabel : 'N°*'
				}, {
					xtype : 'textfield',
					name : 'frmCont_bp',
					labelStyle : 'width:160px',
					width : '200px',
					fieldLabel : 'Boite'
				}, {
					xtype : 'textfield',
					name : 'frmCont_cp',
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					fieldLabel : 'Code Postal*'
				}, {
					xtype : 'textfield',
					name : 'frmCont_ville',
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					fieldLabel : 'Ville*'
				}, {
					xtype: "combo",
					name : "frmCont_pays",
					labelStyle : 'width:160px',
					width : '200px',
					fieldLabel : 'Pays*',
					store : store_country,
					displayField : 'name',
					mode : 'local',
					triggerAction : 'all',
					listWidth : 200,
					hiddenName : 'frmCont_pays',
					allowBlank : false,
					validateOnBlur : false,
					value : 'B              ',
					valueField : 'id',
					emptyText : 'Sélectionnez un pays'
				}, {
					xtype : 'panel',
					layout : 'column',
					id:'id_frmgsm',
					bodyBorder : false,
					border : false,
					hideBorders : true,
					items : [{
						xtype : 'label',
						html : 'N° de GSM/Tel (où l\'on peut <br/>vous joindre pendant les <br/>heures de bureau)*&nbsp;',
						width : '153px'
					}, {
						xtype : 'label',
						html : '+&nbsp;'
					}, {
						xtype : 'numberfield',
						name : 'frmCont_prefixe',
						width : '25px',
						allowBlank : false,
						allowDecimals : false,
						allowNegative : false,
						validateOnBlur : false,
						selectOnFocus : true ,
						value : '32',
						fieldLabel : 'préfixe international'
					}, {
						xtype : 'label',
						html : '&nbsp;&nbsp;/&nbsp;&nbsp;'
					}, {
						xtype : 'numberfield',
						name : 'frmCont_tel',
						width : '120px',
						selectOnFocus : true ,
						validateOnBlur : false,
						allowBlank : false,
						listeners:{
						    'change' : {
					        	fn: saveTel
					    	}
						}
					}]
				}, {
					xtype : 'textfield',
					name : 'frmCont_email',
					vtype : 'email',
					fieldLabel : 'Adresse e-mail*',
					labelStyle : 'width:160px',
					width : '200px',
					allowBlank : false,
					validateOnBlur : false,
					value : objInstantStep.mail
				}];
		return items;
	}
	function buildFormContact(shortForm) {
		var itemsForm;
		var itemsFormShort;
		var itemsFormLong;
		var btNext = {
			xtype : 'button',
			text : 'Continuer',
			id : "continuerFormContact",
			handler : submitFullForm
		};
		var lblError = {
			xtype : 'label',
			html : '<div id=\'id_frm_error\'></div>'
		}
		//if (shortForm) {
		//	itemsForm = getItemsShortForm();
		//} else {
			itemsFormShort = getItemsShortForm();
			itemsFormLong = [{
				xtype : 'checkbox',
				name : 'frmCont_checkboxCour',
				boxLabel : "Adresse courrier (uniquement si différente du domicile)",
				inputValue : "1",
				hideLabel : true,
				id : "id_cb_cour",
				handler : showHideFrmCour
			}, {
				xtype : 'label',
				html : '<h1><br />Vos coordonnées financières</h1><p class="SubtitleP">Encodez ici le numéro de votre compte bancaire (sur lequel seront'
						+ ' versés vos remboursements)</p>'
			},  {
				xtype : 'panel',
				autoHeight : false,
				height : 30,						
				layout : 'column',		
				id : "panel_bank",
				bodyBorder : false,
				border : false,
				hideBorders : true,
				items : [{
							xtype : 'radio',
							boxLabel : "Numéro de compte",
							name : "frmCont_rb_compte",
							inputValue : "1",	
							columnWidth : .40,																																				
							handler : chooseBank,
							checked : true,
							hideLabel : true
							},{
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								selectOnFocus :"true",
								maxlength : 3
							},
							name : 'frmCont_numCompt1',
//							hideLabel : true,
							fieldLabel : 'toto',							
							labelStyle : 'width:160px',							
							enableKeyEvents : true,
							selectOnFocus : true ,
							listeners : {
								'keyup' : {
									fn : validCompt1
								}
							},
							width : '40px'
						}, {
							xtype : 'label',
							html : '&nbsp; - &nbsp;'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 7
							},
							name : 'frmCont_numCompt2',
							id : 'frmCont_numCompt2',
							hideLabel : true,
							selectOnFocus : true ,
							enableKeyEvents : true,
							listeners : {
								'keyup' : {
									fn : validCompt2
								}
							},
							width : '70px'
						}, {
							xtype : 'label',
							html : '&nbsp; - &nbsp;'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 2
							},
							name : 'frmCont_numCompt3',
							id : 'frmCont_numCompt3',
							selectOnFocus : true ,
							hideLabel : true,
							width : '40px'
						}]
			},  {
				xtype : 'panel',
				layout : 'column',
				id : "panel_iban",
				bodyBorder : false,
				autoHeight : false,
				height : 30,						
				border : false,
				hideBorders : true,
				//hidden : true,
				items : [{
							xtype : 'radio',
							boxLabel : "Compte IBAN &nbsp;",							
							name : "frmCont_rb_compte",
							inputValue : "2",
							columnWidth : .43,
							handler : chooseBank,
							hideLabel : true
						},
							{	
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 4
							},
							name : 'frmCont_numIban1',
							hideLabel : true,
							disabled : true,
							selectOnFocus : true ,
							enableKeyEvents : true,
							listeners : {
								'keyup' : nextTab,
								scope : {
									length : 4,
									nextId : "frmCont_numIban2"
								}
							},
							width : '40px'
						}, {
							xtype : 'label',
							html : '&nbsp; - &nbsp;'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 4
							},
							name : 'frmCont_numIban2',
							id : 'frmCont_numIban2',
							hideLabel : true,
							disabled : true,
							selectOnFocus : true ,
							enableKeyEvents : true,
							listeners : {
								'keyup' : nextTab,
								scope : {
									length : 4,
									nextId : "frmCont_numIban3"
								}
							},
							width : '40px'
						}, {
							xtype : 'label',
							html : '&nbsp; - &nbsp;'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 4
							},
							name : 'frmCont_numIban3',
							id : 'frmCont_numIban3',
							hideLabel : true,
							disabled : true,
							selectOnFocus : true ,
							enableKeyEvents : true,
							listeners : {
								'keyup' : nextTab,
								scope : {
									length : 4,
									nextId : "frmCont_numIban4"
								}
							},
							width : '40px'
						}, {
							xtype : 'label',
							html : '&nbsp; - &nbsp;'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 4
							},
							name : 'frmCont_numIban4',
							id : 'frmCont_numIban4',
							selectOnFocus : true ,
							hideLabel : true,
							disabled : true,
							width : '40px'
						}]
			}, {
				xtype : 'label',
				html : '<span class="SubtitleStrong">Vous souhaitez payer votre cotisation par : </span><img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttp5">'
			}, {
				xtype : 'radio',
				boxLabel : lblMethPay[0],
				name : "frmCont_methPay",
				inputValue : "1",
				hideLabel : true
			}, {
				xtype : 'radio',
				boxLabel : lblMethPay[1],
				name : "frmCont_methPay",
				inputValue : "2",
				hideLabel : true
			}, {
				xtype : 'radio',
				boxLabel : lblMethPay[2],
				name : "frmCont_methPay",
				inputValue : "3",
				hideLabel : true
			}, {
				xtype : 'radio',
				boxLabel : lblMethPay[3],
				name : "frmCont_methPay",
				inputValue : "4",
				hideLabel : true
			}, {
				xtype : 'label',
				html : '<h1><br />Votre carte SIS <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttSis"></h1>'
			}, {
				xtype : 'panel',
				layout : 'column',
				bodyBorder : false,
				border : false,
				autoHeight : false,
				height : 30,							
				hideBorders : true,
				items : [{
							xtype : 'label',
							html : 'Numéro de votre carte SIS <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttNumSis"> &nbsp;',
							width: '170px'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 5
							},
							name : 'frmCont_cartSis1',
							id : 'frmCont_cartSis1',
							selectOnFocus : true ,
							enableKeyEvents : true,
							hideLabel : true,
							listeners : {
								'keyup' : nextTab,
								scope : {
									length : 5,
									nextId : "frmCont_cartSis2"
								}
							},
							width : '70px'
						}, {
							xtype : 'label',
							html : '&nbsp; - &nbsp;'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 3
							},
							name : 'frmCont_cartSis2',
							id : 'frmCont_cartSis2',
							selectOnFocus : true ,
							enableKeyEvents : true,
							hideLabel : true,
							listeners : {
								'keyup' : nextTab,
								scope : {
									length : 3,
									nextId : "frmCont_cartSis3"
								}
							},
							width : '40px'
						}, {
							xtype : 'label',
							html : '&nbsp; - &nbsp;'
						}, {
							xtype : 'textfield',
							autoCreate : {
								tag : "input",
								type : "text",
								maxlength : 2
							},
							name : 'frmCont_cartSis3',
							id : 'frmCont_cartSis3',
							selectOnFocus : true ,
							enableKeyEvents : true,
							hideLabel : true,
							width : '40px'
						}]
			}, {
				xtype : 'datefield',
				name : 'frmCont_dateSis',
				//hideTrigger : true,
				format : 'd/m/Y',
				altFormats : 'dmY|d/m/Y|d-m-Y',
				fieldLabel : 'Date d\'émission de votre carte SIS (jj/mm/aaaa)  <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttDateSis">',
				labelStyle : 'width:167px'
			}, {
				xtype : 'label',
				html : 'Les données de votre carte SIS nous permettent de traiter rapidement et correctement votre demande. Si vous n’avez pas ces données sous la main, vous pouvez passer à la suite du formulaire et remplir cette donnée ultérieurement.'
			}];			
			itemsForm = itemsFormShort.concat(itemsFormLong);
			if (!shortForm) {
				itemsForm = itemsForm.concat(getQuestionAssurance());
			}
		//}
		itemsForm.push(btNext);
		itemsForm.push(lblError);
		formContact = new Ext.form.FieldSet({
					name : 'formContact',
					id : 'formContact',
					autoHeight : true,
					labelSeparator : ' : ',
					labelWidth: 160,
					defaults: {blankText : "Champ obligatoire"},
					items : itemsForm
				});
		return formContact;
	}

	function buildShowGridAss() {
		var gridForm = new Ext.form.FieldSet({
					id : 'id_blocGridAss',
					frame : true,
					labelAlign : 'left',
					title : 'Personne à charge',
					bodyStyle : 'padding:5px',
					autoHeight : true,
					items : [{
								layout : 'fit',
								items : {
									id : 'id_showGridAss',
									xtype : 'grid',
									ds : ds,
									cm : colModel,
									sm : sm2,
									autoExpandColumn : 'persacharg_nom',
									autoHeight : true,
									width : 500,
									forceFit : true,
									bodyBorder : false,
									border : false,
									hideBorders : true
								}
							}, {
								xtype : "button",
								text : "continuer",
								name : "btGoToContactForm",
								scope : this,
								handler : showContactForm
							}]
				});
		return gridForm;
	}

	/*
	 * Here is where we create the Form
	 */
	function toolTipPersonnesACharge() {
		if (Ext.get("ttp4")) {
			var ttp4 = new Ext.ToolTip({
						target : "ttp4",
						title : ttp4TxtTitre,
						dismissDelay:0,
						html :  ttp4Txt
					});
		}
	}

	function buildGridForm() {
		var gridForm = new Ext.form.FieldSet({
			id : 'company-form',
			frame : true,
			labelAlign : 'left',
			bodyStyle : 'padding:5px',
			autoHeight : true,
			items : [{
				xtype : 'label',
				html : '<h1>Encodez ici les personnes à inscrire à votre charge <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttp4"></h1>'
			}, {
				layout : 'fit',
				items : {
					id : 'company-grid',
					xtype : 'grid',
					ds : ds,
					cm : colModel,
					sm : sm2,
					/*
					 * sm: new Ext.grid.RowSelectionModel({ singleSelect: true,
					 * listeners: { rowselect: function(sm, row, rec) {
					 * //console.log(row) //
					 * Ext.getCmp("company-form").getForm().loadRecord(rec); } }
					 * }),
					 */
					tbar : [{
								text : 'Ajouter une personne',
								tooltip : 'Ajouter une personne',
								ctCls : 'x-btn-over',
								iconCls : 'add',
								handler : addPerson
							}, '-', {
								text : 'Modifier',
								tooltip : 'Modifier',
								ctCls : 'x-btn-over',
								Cls : "x-btn button",
								iconCls : 'edit',
								handler : editPerson
							}, '-', {
								text : 'Supprimer une personne',
								tooltip : 'Supprimer une personne',
								Cls : "x-btn button",
								ctCls : 'x-btn-over',
								iconCls : 'remove',
								handler : function() {
									recSel = sm2.getSelections();
									for (var i = 0; i < recSel.length; i++) {
										ds.remove(recSel[i]);
									}
								}
							}],
					autoExpandColumn : 'persacharg_nom',
					autoHeight : true,
					width : 500,
					forceFit : true,
					bodyBorder : false,
					border : false,
					hideBorders : true,
					listeners : {
						render : function(g) {
							g.getSelectionModel().selectRow(0);
						},
						delay : 10
						// Allow rows to be rendered.
					}
				}
			}, {
				xtype : "label",
				html : "<br/><br/>"
			}, {
				xtype : "button",
				text : "continuer",
				id: "continueTab1",
				name : "btGoToContactForm",
				scope : this,
				handler : showContactForm
			}]
		});
		return gridForm;
	}

	// Question type mutuelle
	var label_bloc1 = new Ext.form.Label({
				name : "label_bloc1",
				html : " "
			});
	var typ_mut1 = new Ext.form.Radio({
				xtype : "radio",
				boxLabel : Q1questions[0],
				name : "repQ1",
				id : "id_rb_insc",
				inputValue : "1",
				hideLabel : true,
				handler : StepChoose
			});
	var typ_mut2 = new Ext.form.Radio({
				xtype : "radio",
				boxLabel : Q1questions[1],
				name : "repQ1",
				id : "id_rb_autre",
				inputValue : "2",
				hideLabel : true,
				handler : StepChoose
			});
	var typ_mut3 = new Ext.form.Radio({
				xtype : "radio",
				boxLabel : Q1questions[2],
				name : "repQ1",
				inputValue : "3",
				hideLabel : true,
				handler : StepChoose
			});
	var typ_mut4 = new Ext.form.Radio({
				xtype : "radio",
				boxLabel : Q1questions[3],
				name : "repQ1",
				inputValue : "4",
				hideLabel : true,
				handler : StepChoose
			});
	var typ_mut5 = new Ext.form.Radio({
				xtype : "radio",
				boxLabel : Q1questions[4],
				name : "repQ1",
				inputValue : "5",
				hideLabel : true,
				handler : StepChoose
			});

	var form_bloc1 = new Ext.form.FieldSet({
				name : "fieldSet1",
				id : "id_form_bloc1",
				autoHeight : true,
				items : [label_bloc1, getTitle1(), typ_mut1, typ_mut2,
						typ_mut3, typ_mut4, typ_mut5]
			});

			
	MyForm1 = new Ext.FormPanel({
		xtype : "form",
		url : 'servlet/ProcessInstantStep',
		id : 'id_form1',		
		// autoShow: true,
		items : [{
			xtype : "tabpanel",
			id : "idTabPanel",
			activeTab : 0,
			bodyBorder : false,
			defaults : {
				autoHeight : true
			},
			layoutOnTabChange : true,
			items : [{
						xtype : "panel",
						id : "panel1",
						title : "Votre situation",
						defaults : {
							autoHeight : true
						},
						layout : "form",
						width : 360,
						items : [form_bloc1]
					}, {
						xtype : "panel",
						id : "panel2",
						title : "Vos données personnelles",
						disabled : true,
						defaults : {
							autoHeight : true
						},
						layout : "form",
						width : 360
					}, {
						xtype : "panel",
						id : "panel3",
						title : "Résumé",
						disabled : true,
						bodyStyle:'padding:10px 0 0 10px',						
						defaults : {
						autoHeight : true
						},
						layout : "form",
						items : [{
								xtype : "label",
								name : "lbl_resume",
								html : "<div id='id_sumary'></div><div id='id_sumary_miss_field'></div>"
							}, {
								xtype : "label",
								html : "<h1><br />Recevoir les documents :</h1>"
							},{
								xtype : "radio",
								boxLabel : "par téléchargement",
								name : "rb_download",
								inputValue : "1",
								hideLabel : true,
								checked: true
							}, {
								xtype : "radio",
								boxLabel : "par courrier",
								name : "rb_download",
								inputValue : "2",
								hideLabel : true
							}, {
  								 xtype : 'label',
   								 html : '<br />'
 						    },{
							xtype : 'button',
							text : 'Continuer',
							id : 'btConfirmForm',
							name : 'btConfirmForm',
							handler : confirmForm
						}, {
  							 xtype : 'label',
   							html : '<br />'
  							}],
						width : 360
					}, {
						xtype : "panel",
						id : "panel4",
						title : "Documents",
						disabled : true,
						defaults : {
							autoHeight : true
						},
						layout : "form",
						items : [{
							xtype : "label",
							name : "lbl_confirm1",
							html : "<div id='downloadContent'></div>"
						},{
							xtype : 'button',
							text : 'Recommencer',
							name : 'btReturnBegin',
							handler : fctReturnBegin
						}],
						width : 360
					}]
		}]
	});

	// end MyForm1
	function buildStep3() {
		Ext.getCmp('id_title1').getEl().on('click', showStep, this, {
					'num_step' : 1
				});
		form_bloc3 = new Ext.form.FieldSet({
			name : "fieldSet3",
			id : "id_fieldSet3",
			autoHeight : true,
			layout : 'table',
			layoutConfig : {
				columns : 2
			},
			items : [{
				xtype : "label",
				name : "label_bloc3",
				id : "id_title2",
				html : "<h1>"
						+ Q3Label
						+ "</h1>Vous demandez votre inscription comme :",
				colspan : 2
			}, {
				xtype : "radio",
				boxLabel : Q3questions[0],
				name : "repQ3",
				inputValue : "1",
				hideLabel : true,
				handler : StepChoose,
				width : 300
			}, {
				xtype : "radio",
				boxLabel : Q3questions[1],
				name : "repQ3",
				inputValue : "2",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[2]+' <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttTravInd">',
				name : "repQ3",
				inputValue : "3",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[3],
				name : "repQ3",
				inputValue : "4",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[4],
				name : "repQ3",
				inputValue : "5",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[5],
				name : "repQ3",
				inputValue : "6",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[6],
				name : "repQ3",
				inputValue : "7",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[7],
				name : "repQ3",
				inputValue : "8",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[8]+' <img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="ttResident">',
				name : "repQ3",
				inputValue : "9",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[9],
				name : "repQ3",
				inputValue : "10",
				hideLabel : true,
				handler : StepChoose
			}, {
				xtype : "radio",
				boxLabel : Q3questions[10],
				name : "repQ3",
				inputValue : "11",
				hideLabel : true,
				handler : StepChoose
			}]
		});
		return form_bloc3;
	}
	function buildStep4() {
		form_bloc4 = new Ext.form.FieldSet({
					name : "fieldSet4",
					id : "id_fieldSet4",
					autoHeight : true,
					layout : 'table',
					layoutConfig : {
						columns : 2
					},
					items : [{
								xtype : "label",
								name : "label_Civil",
								id : "id_title_Civil",
								html : "<h1>Quel est votre état civil?</h1>",
								colspan : 2
							}, {
								xtype : "radio",
								boxLabel : Q4questions[0],
								name : "repQ4",
								inputValue : "1",
								hideLabel : true,
								width : 300,
								handler : StepChoose
							}, {
								xtype : "radio",
								boxLabel : Q4questions[1],
								name : "repQ4",
								id : "id_rb_marie",
								inputValue : "2",
								hideLabel : true,
								handler : StepChoose
							}, {
								xtype : "radio",
								boxLabel : Q4questions[2],
								name : "repQ4",
								inputValue : "3",
								hideLabel : true,
								handler : StepChoose
							}, {
								xtype : "radio",
								boxLabel : Q4questions[3],
								name : "repQ4",
								inputValue : "4",
								hideLabel : true,
								handler : StepChoose
							}, {
								xtype : "radio",
								boxLabel : Q4questions[4],
								name : "repQ4",
								inputValue : "5",
								hideLabel : true,
								handler : StepChoose
							}, {
								xtype : "radio",
								boxLabel : Q4questions[5],
								name : "repQ4",
								id : "id_rb_cohab",
								inputValue : "6",
								hideLabel : true,
								handler : StepChoose
							}]
				});
		return form_bloc4;
	}
	function buildChoixInscFam() {
		form_bloc5 = new Ext.form.FieldSet({
					name : "fieldSet5",
					id : "id_fieldSet5",
					autoHeight : true,
					items : [{
								xtype : "radio",
								boxLabel : "Oui",
								name : "radioChoixInscFam",
								inputValue : "1",
								hideLabel : true,
								handler : StepChoose
							}, {
								xtype : "radio",
								boxLabel : "Non",
								name : "radioChoixInscFam",
								inputValue : "2",
								hideLabel : true,
								handler : StepChoose
							}, {
								xtype : "radio",
								boxLabel : "Déjà inscrit chez partenamut",
								name : "radioChoixInscFam",
								inputValue : "3",
								hideLabel : true,
								handler : StepChoose
							}]
				});
		return form_bloc5;
	}

	function submitFullForm() {
		var json;
		json = '[';
		var grid = Ext.getCmp('company-grid');
		if (grid != null) {
			var store = grid.getStore();
			try {
				store.each(function(store) {
							if (typeof(store.data.persacharg_dna) == "object") {
								store.data.persacharg_dna = store.data.persacharg_dna
										.format("d/m/Y");
							}
							json += Ext.util.JSON.encode(store.data) + ',';
						});
			} catch (err) {
				Ext.MessageBox.alert('ERROR', 'Could not encode');
			}
			if (json.length > 1) {
				json = json.substring(0, json.length - 1);
			}
		}
		json += ']';
		var myParams = {
			gridStore : json,
			foo : 'bar',
			id : idDB
		};
		if (MyForm1.getForm().isValid()) {
			MyForm1.getForm().submit({
				url : 'servlet/ValidFullForm',
				params : myParams,
				success : function(form, action) {
					window.location.hash = "#show_contact";
					Ext.getCmp("panel3").enable();
					Ext.getCmp("idTabPanel").activate(2);
					MyForm1.doLayout();
					valForm = MyForm1.getForm().getValues();
					// Ext.get("id_sumary_miss_field").update("");
					var resultInfo = ""
					Ext.get("id_sumary").update("");
					Ext.get("id_sumary_miss_field").update("");
					resultHospi="Non";
					resultDentalia="Non";
					_gaq.push(['_trackPageview', '/analytics/affiliationExpress/resume']);
					googleFct('/resume');
					for (var item in valForm) {
						switch (item) {
							case "repQ1" :
								resultInfo += '<h1><br />' + Q1Label + ': </h1><p>'
										+ Q1questions[valForm[item] - 1]
										+ '</p>';
								break;
							case "repQ2" :
								resultInfo += '<p>'
										+ Q2questions[valForm[item] - 1]
										+ '</p>';
								break;
							case "cmb_union" :
								resultInfo += '<p>'
										+ MyForm1.getForm()
												.findField("cmb_union").lastSelectionText
										+ '</p>';
								break;
							case "cmb_mut" :
								resultInfo += '<p>'
										+ MyForm1.getForm()
												.findField("cmb_mut").lastSelectionText
										+ '</p>';
								break;
							case "repQ3" :
								resultInfo += '<h1><br />' + Q3Label + ': </h1><p>'
										+ Q3questions[valForm[item] - 1]
										+ '</p>';
								break;
							case "repQ4" :
								resultInfo += '<h1><br />' + Q4Label + ': </h1><p>'
										+ Q4questions[valForm[item] - 1]
										+ '</p>';
								break;
							case "repQ7" :
								resultHospi="Oui";
								break;
							case "repQ8" :
								resultDentalia="Oui";
								break;
							case "repQ9" :
								resultInfo += '<h1><br />' + Q9Label + ': </h1><p>'
										+ Q9questions[valForm[item]] + '</p>';
								break;
							case "repQ10" :
								resultInfo += '<h1><br />' + Q10Label + ': </h1><p>'
										+ Q10questions[valForm[item]] + '</p>';
								break;
							case "repQ11" :
								resultInfo += '<h1><br />' + Q11Label + ': </h1><p>'
										+ Q11questions[valForm[item]] + '</p>';
								break;
							default :
								break;
						}
					}
					resultAffi="";
					if (valForm['repQ1'] == "1") {
							if (valForm['repQ2'] == "1") {
								resultAffi="Déjà affilié comme titulaire";
							} else if (valForm['repQ2'] == "2") {
								resultAffi="Affiliation comme titulaire";
							}
					} else{
						resultAffi="Demande d’affiliation";	
					}
					resultInfo += '<h1><br />' + Q7Label + ': </h1>';
					resultInfo += '<p>Partenamut : '+ resultAffi + '</p>';
					resultInfo += '<p>Hospitalia : '+ resultHospi + '</p>';
					resultInfo += '<p>Dentalia Plus : '+ resultDentalia + '</p>';
					if (grid != null && grid.getStore().getCount() > 0) {
						resultInfo += '<h1><br />Composition de famille :</h1><table cellspacing="4" width="500"><tr><th align="center"><span class="strongTable">Nom</span></th><th align="center"><span class="strongTable">Prenom</span></th><th align="center"><span class="strongTable">'+lblSmryDna+'</span></th><th align="center"><span class="strongTable">Type</span></th><th align="center"><span class="strongTable">Inscre</span></th><th align="center"><span class="strongTable">Titulaire</span></th></tr>';
						var store = grid.getStore();
						store.each(function(store) {
							resultInfo += '<tr>';
							if (typeof(store.data.persacharg_dna) == "object") {
								store.data.persacharg_dna = store.data.persacharg_dna
										.format("d/m/Y");
							}
							resultInfo += '<td align="center">' + store.data.persacharg_nom
									+ '</td>';
							resultInfo += '<td align="center">' + store.data.persacharg_prenom
									+ '</td>';
							resultInfo += '<td align="center">' + store.data.persacharg_dna
									+ '</td>';
							resultInfo += '<td align="center">' + store.data.persacharg_type
									+ '</td>';
							resultInfo += '<td align="center">' + store.data.persacharg_inscr
									+ '</td>';
							resultInfo += '<td align="center">' + store.data.persacharg_tit
									+ '</td>';
							resultInfo += '</tr>';
						});
						resultInfo += '</table>';
					}
					resultInfo += '<h1><br />Vos données personnelles:</h1>';
					resultInfo += "<p>" + lblSmryNom + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_nom")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryPrenom + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_prenom")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmrySexe + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_sexe")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryDna + lblSmryDnaFormat+ " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_DNA")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryNat + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_nat")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryNrn + " : ";
					resultInfo += MyForm1.getForm()
							.findField("frmCont_numRegNat").getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryRue + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_rue")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryNum + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_num")
							.getRawValue()
							+ "</p>";
					//resultInfo += "<p>" + lblSmryBp + " : ";
					//resultInfo += MyForm1.getForm().findField("frmCont_bp")
					//		.getRawValue()
					//		+ "</p>";
					resultInfo += "<p>" + lblSmryCp + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_cp")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryVille + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_ville")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryPays + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_pays")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryTel + " : ";
					resultInfo += MyForm1.getForm()
							.findField("frmCont_prefixe").getRawValue();
					resultInfo += " / ";
					resultInfo += MyForm1.getForm().findField("frmCont_tel")
							.getRawValue()
							+ "</p>";
					resultInfo += "<p>" + lblSmryEmail + " : ";
					resultInfo += MyForm1.getForm().findField("frmCont_email")
							.getRawValue()
							+ "</p>";
					Ext.get("id_sumary").insertHtml("beforeEnd", resultInfo);
					Ext.get("id_sumary_miss_field").insertHtml("beforeEnd","<h1><br />Champs non saisis :</h1>");
					Ext.get("id_sumary_miss_field").insertHtml("beforeEnd","<p>Attention, vous n’avez pas encore complété les données suivantes :</p>");
					Ext.get("id_sumary_miss_field").insertHtml("beforeEnd","<p>L'absence de ces données peut entraîner un retard dans le traitement de votre demande.</p>");
					Ext.get("id_sumary_miss_field").insertHtml("beforeEnd",buildMissField());
				}
			});
		} else {
			Ext.get('id_frm_error').update(msgErrorForm);
		}
	}

	function showHideFrmCour(item, checked) {
		idToInsert = Ext.getCmp("formContact").items.indexOfKey("id_cb_cour");
		// MyForm1.findById("panel2").remove(MyForm1.findById("panel1").items.itemAt(i));
		if (checked == true) {
			Ext.getCmp("formContact").insert(idToInsert + 1, getFrmCont());
			Ext.getCmp("formContact").form = MyForm1.getForm();
			MyForm1.initFields.call(Ext.getCmp("formContact"));
			
		} else {
			Ext.getCmp("formContact").findById("id_frm_cour").items.each(function () {this.disable();})
			Ext.getCmp("formContact").remove("id_frm_cour");
			// Ext.getCmp("id_frm_cour").hide();
		}
		MyForm1.doLayout();
		Ext.getCmp("panel2").doLayout()
	}

	function showCbmMut(item, checked) {
		Ext.getCmp("id_cmb_union").show();
	}
	function selectUnion(ev, target) {
		store_mut.load({
					params : {
						'id' : idDB,
						'cmb_union' : target.get("idunion")
					}
				});
		if (target.get("idunion") == 0) {
			form_bloc3 = buildStep3();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_fieldSet2_2");
			addFieldSet(form_bloc3, idToInsert, true);
			MyForm1.doLayout();
		} else {
			Ext.getCmp("id_cmb_mut").show();
			Ext.getCmp("id_cmb_mut").clearValue();
		}
	}
	function selectMut(ev, target) {
		MyForm1.getForm().submit({
					url : 'servlet/ProcessQ2',
					params : {
						id : idDB
					},
					success : function(form, action) {
						// console.log("submit Q2");
					}
				});
		form_bloc3 = buildStep3();
		idToInsert = MyForm1.findById("panel1").items
				.indexOfKey("id_fieldSet2_2");
		addFieldSet(form_bloc3, idToInsert, true);
		MyForm1.doLayout();
	}
	// Start Function choose steps
	function StepChoose(item, checked) {
		if (item.name == "repQ1" && checked == true) {
			MyForm1.getForm().submit({
						url : 'servlet/ProcessQ1',
						params : {
							id : idDB
						},
						success : function(form, action) {
							// console.log("submit Q1");
						}
					});
		}
		if (item.name == "repQ1" && item.inputValue == '1' && checked == true) {
			rb_titut_1 = new Ext.form.Radio({
						boxLabel : Q2questions[0],
						name : "repQ2",
						inputValue : "1",
						hideLabel : true,
						id : "repQ2Test",
						handler : StepChoose
					});
			ligne1 = new Ext.Panel({
				layout : 'column',
				bodyBorder : false,
				border : false,
				hideBorders : true,
				items : [{
							columnWidth : .40,
							items : [rb_titut_1]
						}, {
							columnWidth : .60,
							html : '<img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="tt1">'
						}]
			});
			rb_persacharg_1 = new Ext.form.Radio({
						boxLabel : Q2questions[1],
						name : "repQ2",
						inputValue : "0",
						hideLabel : true,
						handler : StepChoose
					});
			ligne2 = new Ext.Panel({
				layout : 'column',
				bodyBorder : false,
				border : false,
				hideBorders : true,
				items : [{
							columnWidth : .40,
							items : [rb_persacharg_1]
						}, {
							columnWidth : .60,
							html : '<img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="tt2">'
						}]
			});
			/*
			 * Ext.getCmp("id_fieldset2").add(getLabel_bloc2_1());
			 * Ext.getCmp("id_fieldset2").add(ligne1);
			 * Ext.getCmp("id_fieldset2").add(ligne2);
			 */
			form_bloc2_1 = new Ext.form.FieldSet({
						name : "fieldSet2_1",
						id : "id_fieldSet2_1",
						autoHeight : true,
						items : [getLabel_bloc2_1(), ligne1, ligne2]
					});
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_form_bloc1");
			addFieldSet(form_bloc2_1, idToInsert, true);
			MyForm1.doLayout();
			buildToolTip();
		} else if (item.name == "repQ1" && item.inputValue == '2'
				&& checked == true) {
			rb_titut_2 = new Ext.form.Radio({
						boxLabel : Q2questions[0],
						name : "repQ2",
						inputValue : "1",
						hideLabel : true,
						handler : showCbmMut
					});
			ligne3 = new Ext.Panel({
				layout : 'column',
				bodyBorder : false,
				border : false,
				hideBorders : true,
				items : [{
							columnWidth : .40,
							items : [rb_titut_2]
						}, {
							columnWidth : .60,
							html : '<img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="tt3">'
						}]
			});

			rb_persacharg_2 = new Ext.form.Radio({
						boxLabel : Q2questions[1],
						name : "repQ2",
						inputValue : "0",
						hideLabel : true,
						handler : showCbmMut
					});
			ligne4 = new Ext.Panel({
				layout : 'column',
				bodyBorder : false,
				border : false,
				hideBorders : true,
				items : [{
							columnWidth : .40,
							items : [rb_persacharg_2]
						}, {
							columnWidth : .60,
							html : '<img src="scripts/ext/resources/images/default/window/icon-info.gif" height="15" id="tt4">'
						}]
			});
			lbl_sel_union = new Ext.form.Label({
				name : "lbl_sel_union",
				html : "Sélectionnez l'union dont fait partie votre mutualité :",
				hidden : true
			});
			cmb_union = new Ext.form.ComboBox({
				name : "cmb_union",
				id : "id_cmb_union",
				store : store_union,
				displayField : 'union',
				mode : 'local',
				triggerAction : 'all',
				editable : false,
				hideLabel : true,
				width : 350,
				listWidth : 350,
				listeners : {
					'select' : selectUnion,
					scope : this
				},
				hiddenName : 'cmb_union',
				valueField : 'idunion',
				emptyText : 'Sélectionnez l\'union dont fait partie votre mutualité',
				hidden : true
			});
			lbl_cmb_mut = new Ext.form.Label({
						name : "label_bloc2_2",
						html : "Sélectionnez votre mutualité :",
						hidden : true
					});

			cmb_mut = new Ext.form.ComboBox({
						name : "cmb_mut",
						id : "id_cmb_mut",
						store : store_mut,
						displayField : 'name',
						mode : 'local',
						triggerAction : 'all',
						lastQuery : '',
						editable : false,
						hideLabel : true,
						width : 350,
						listWidth : 350,
						listeners : {
							'select' : selectMut,
							scope : this
						},
						hiddenName : 'cmb_mut',
						valueField : 'id',
						emptyText : 'Sélectionnez votre mutualité',
						hidden : true
					});

			form_bloc2_2 = new Ext.form.FieldSet({
						name : "fieldSet2_2",
						id : "id_fieldSet2_2",
						autoHeight : true,
						items : [getLabel_bloc2_2(), ligne3, ligne4,
								lbl_sel_union, cmb_union, lbl_cmb_mut, cmb_mut]
					});

			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_form_bloc1");
			addFieldSet(form_bloc2_2, idToInsert, true);
			MyForm1.doLayout();
			buildToolTip();
		} else if ((item.name == "repQ1" && item.inputValue == '3' && checked == true)
				|| (item.name == "repQ1" && item.inputValue == '4' && checked == true)
				|| (item.name == "repQ1" && item.inputValue == '5' && checked == true)) {
			form_bloc3 = buildStep3();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_form_bloc1");
			addFieldSet(form_bloc3, idToInsert, true);
			MyForm1.doLayout();
		} else if (item.name == 'repQ2' && checked == true) {
			var stepToInsert;
			if (item.inputValue == "1" && Ext.getCmp("id_rb_insc").checked) {
				stepToInsert = getQuestionAssurance();
				stepToInsert.add({
							xtype : "button",
							text : "Etape suivante",
							handler : checkAssCompl
						});
			} else {
				stepToInsert = buildStep3();
			}
			MyForm1.getForm().submit({
						url : 'servlet/ProcessQ2',
						params : {
							id : idDB
						},
						success : function(form, action) {
							// console.log("submit Q2");
						}
					});
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_fieldSet2_1");
			addFieldSet(stepToInsert, idToInsert, true);
			MyForm1.doLayout();
			if (item.inputValue == "1" && Ext.getCmp("id_rb_insc").checked)
				buildToolTip();
		} else if (item.name == 'repQ3' && checked == true) {
			MyForm1.getForm().submit({
						url : 'servlet/ProcessQ3',
						params : {
							id : idDB
						},
						success : function(form, action) {
							// console.log("submit Q3");
						}
					});

			form_bloc4 = buildStep4();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_fieldSet3");
			addFieldSet(form_bloc4, idToInsert, true);
			MyForm1.doLayout();
		} else if (item.name == 'repQ4' && checked == true) {
			MyForm1.getForm().submit({
						url : 'servlet/ProcessQ4',
						params : {
							id : idDB
						},
						success : function(form, action) {
							// console.log("submit Q4");
						}
					});
			var questionSitFam;
			// reset the familly data store ds
			ds.removeAll();
			if (item.inputValue == '2' || item.inputValue == '6') {
				addPersonConjoint(item.inputValue);
			}
			form_bloc5 = buildGridForm();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_fieldSet4");
			addFieldSet(form_bloc5, idToInsert, true);
			MyForm1.doLayout();
			toolTipPersonnesACharge();

		} else if (item.name == 'cbSituationFam' && checked == true) {
			MyForm1.getForm().submit({
						url : 'servlet/ProcessQ4',
						params : {
							id : idDB
						},
						success : function(form, action) {
							// console.log("submit Q4");
						}
					});
			form_bloc5 = buildChoixInscFam();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_fieldSet4");
			addFieldSet(form_bloc5, idToInsert, true);
			MyForm1.doLayout();

		} else if (item.name == 'radioChoixInscFam' && checked == true) {
			MyForm1.getForm().submit({
						url : 'servlet/ProcessQ5',
						params : {
							id : idDB
						},
						success : function(form, action) {
							// console.log("submit Q5");
						}
					});
			if (item.inputValue == '1') {
				addPerson(false);
			}
			gridForm = buildGridForm();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("id_fieldSet5");
			addFieldSet(gridForm, idToInsert, true);
			MyForm1.doLayout();
			toolTipPersonnesACharge();

		} else if (item.name == 'repQ7' && checked == true) {
			gridForm = buildGridForm();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("idQuestionAssurance");
			addFieldSet(gridForm, idToInsert, true);
			MyForm1.doLayout();
			toolTipPersonnesACharge();
		} else if (item.name == 'repQ8' && checked == true) {
			questionSub = getQuestionSubscription();
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("idQuestionAssurance");
			addFieldSet(questionSub, idToInsert, true);
			MyForm1.doLayout();

		} else if ((item.name == 'repQ7' || item.name == 'repQ8')
				&& checked == false) {
			idToInsert = MyForm1.findById("panel1").items
					.indexOfKey("idQuestionAssurance");
			addFieldSet(questionSub, idToInsert, false);
			MyForm1.doLayout();

		}
	}
	// End Function choose steps

	function showContactForm() {
		var json;
		json = '[';
		var grid = Ext.getCmp('company-grid');
		if (grid != null) {
			var store = grid.getStore();
			try {
				store.each(function(store) {
							if (typeof(store.data.persacharg_dna) == "object") {
								store.data.persacharg_dna = store.data.persacharg_dna
										.format("d/m/Y");
							}
							json += Ext.util.JSON.encode(store.data) + ',';
						});
			} catch (err) {
				Ext.MessageBox.alert('ERROR', 'Could not encode');
			}
			if (json.length > 1) {
				json = json.substring(0, json.length - 1);
			}
		}
		json += ']';
		Ext.Ajax.request({
			   url: 'servlet/SaveFam',
			   params: { jsonFam: json,
			             id : idDB}
		});
		
		if (!Ext.get("panel2")){
			if (MyForm1.findById("panel2").items != null) {
				for (var i = 0; i < MyForm1.findById("panel2").items.keys.length; i++) {
					MyForm1.findById("panel2")
							.remove(MyForm1.findById("panel2").items.itemAt(i));
				}
			}
			// submitGrid();
			//philippe
			if ((Ext.getCmp("id_rb_insc").checked) && (Ext.getCmp("repQ2Test").checked)){
				formContact = buildFormContact(true);
			}
			else {
				formContact = buildFormContact();
			}
		
			MyForm1.findById("panel2").add(formContact);
			buildToolTip();
			formContact.form = MyForm1.getForm();
			MyForm1.initFields.call(formContact);
		}	
		else {
			/*if(Ext.getCmp("id_rb_insc").checked) {
			  if (Ext.get("idQuestionAssurance"))
			  	MyForm1.findById("formContact").remove(MyForm1.findById("idQuestionAssurance"));
			} 
			else {*/
			  if (!Ext.get("idQuestionAssurance")) {
			    var questionnaireAssurance = getQuestionAssurance();
			    MyForm1.findById("formContact").insert(MyForm1.findById("formContact").items.indexOfKey("continuerFormContact")  ,questionnaireAssurance );
			    questionnaireAssurance.form = MyForm1.getForm();
			    MyForm1.initFields.call(questionnaireAssurance);
			  }
			//}
		}
		Ext.getCmp("panel2").enable();
		Ext.getCmp("idTabPanel").activate(1);
		MyForm1.doLayout();
		buildToolTip();
		// show_contact
		googleFct('/donnees_pers');
		_gaq.push(['_trackPageview', '/analytics/affiliationExpress/donneesPersonnelles']);
	 	window.location.hash = "#show_contact";
	
	}

	objInstantStep.nom = cook.get('nom');
	objInstantStep.prenom = cook.get('prenom'); 
	objInstantStep.mail = cook.get('mail');
	idDB = Ext.urlDecode(location.search.substring(1)).id;
	function saveField(ev, target) {
		// console.log('name='+this.name+' | valeur='+target)
		cook.set(this.name, target);
	}
	if (idDB!=null) {
		content_center_html = '<div id="CT_Step1" class="PartenaDivs"></div>';
		if (MyForm1.isVisible() == false) {
			Ext.get('content_center').insertHtml("beforeEnd",content_center_html);
			MyForm1.render(Ext.get('CT_Step1'));
		}
	} else {
		var cp = new Ext.state.CookieProvider();
		Ext.state.Manager.setProvider(cp);
		var cook = Ext.state.Manager.getProvider();
		// Add the additional 'advanced' VTypes
		Ext.apply(Ext.form.VTypes, {
			email : function(val, field) {
				this.emailText = "e-mail non valide";
				if (val
						.match(/^([a-zA-Z0-9_-])+([.]?[a-zA-Z0-9_-]{1,})*@([a-zA-Z0-9-_]{2,}[.])+[a-zA-Z]{2,3}$/)) {
					if (field.initialPassField) {
						var pwd = Ext.getCmp(field.initialPassField);
						this.emailText = "Les e-mails doivent être identiques";
						return (val == pwd.getValue());
					} else
						return true;
				} else
					return false;
			},
			emailText : 'Les e-mails doivent être identiques'
		});

		var txt_pre = new Ext.form.TextField({
					fieldLabel : "Prénom",
					name : "prenom",
					labelStyle : " padding-left:10px; font-weight:bold;",
					validateOnBlur : false
				});
		txt_pre.on('change', saveField);
		var txt_nom = new Ext.form.TextField({
					fieldLabel : "Nom",
					name : "nom",
					labelStyle : " padding-left:10px; font-weight:bold;",
					validateOnBlur : false
				});
		txt_nom.on('change', saveField);
		var txt_mail = new Ext.form.TextField({
					fieldLabel : "E-mail",
					name : "mail",
					vtype : 'email',
					labelStyle : " padding-left:10px; font-weight:bold;",
					id : 'pass',
					validateOnBlur : false
				});
		txt_mail.on('change', saveField);
		var txt_confemail = new Ext.form.TextField({
					fieldLabel : "Confirmation E-mail",
					name : "confemail",
					vtype : 'email',
					labelStyle : " padding-left:10px; line-height:11px; font-weight:bold;",
					initialPassField : 'pass',
					validateOnBlur : false
				});		
		txt_confemail.on('change', saveField);
		var bt_sub = new Ext.Button({
			text:"continuer"
		});
		var form_inscr = new Ext.FormPanel({
					url : 'servlet/ProcessInstantStep',
					itemCls : 'coucou',
					baseParams: {lang: "fr"},
					defaults : {
						allowBlank : false,
						validationEvent : false
					},
					items : [txt_pre, txt_nom, txt_mail, txt_confemail, bt_sub]
				});
		form_inscr.render(Ext.get('content_center'));
		if (cook.get('prenom') != null) {
			txt_pre.setRawValue(cook.get('prenom'));
		}
		if (cook.get('nom') != null) {
			txt_nom.setRawValue(cook.get('nom'));
		}
		if (cook.get('mail') != null) {
			txt_mail.setRawValue(cook.get('mail'));
		}
		if (cook.get('confemail') != null) {
			txt_confemail.setRawValue(cook.get('confemail'));
		}


		bt_sub.on('click', function() {
			form_inscr.getForm().submit({
				success : function(form, action) {					
					idDB = action.result.id;
					document.location = "affiliationExpress.jsp?id="+idDB;
					_gaq.push(['_trackPageview', '/analytics/affiliationExpress/votreSituation']);
				},
				failure : function(form, action) {
					switch (action.failureType) {
						case Ext.form.Action.CLIENT_INVALID :
							// Ext.Msg.alert("Failure",
							// "Form fields may not be submitted with invalid
							// values");
							break;
						case Ext.form.Action.CONNECT_FAILURE :
							Ext.Msg.alert("Failure", "Ajax communication failed");
							break;
						case Ext.form.Action.SERVER_INVALID :
							Ext.Msg.alert("Failure", action.result.msg);
					}
				}
			});
		});
	}
});
