var modif  ;
var nb_mar ;
var relation = 0 ;
var navigateur ;
var $lg_lieu ;

if (navigator.appName == "Netscape")
	{
	navigateur = "FF" ;
	
	$lg_lieu = 169 ;
	}
else
	{
	var exp = new RegExp ("MSIE 8.0", "g") ;
			
	if (exp.test(navigator.appVersion))
		navigateur = "IE8" ;
	else	navigateur = "IE" ;
	
	$lg_lieu = 159 ;
	}
	
function getHTTPObject()
	{
	var xhr = false ; 
         
	if (window.XMLHttpRequest)										// Firefox et autres
		xhr = new XMLHttpRequest() ; 
	else if (window.ActiveXObject)
		{														// Internet Explorer 
		try
			{
			xhr = new ActiveXObject ("Msxml2.XMLHTTP") ;
			}
                 
		catch (e)
			{
			xhr = new ActiveXObject ("Microsoft.XMLHTTP") ;
			}
		}
	else															// XMLHttpRequest non supporté par le navigateur
		{
		alert ("Votre navigateur ne supporte pas les objets XMLHTTPRequest !") ; 
           
		xhr = false ; 
		}
        
	return xhr ;
	}


function ferme()
	{
	opener = self ;
	self.close() ;
	}
	

function js_AffAsc(base, n, maxi)
	{
	var xhr = getHTTPObject () ;

//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
		if ((xhr.readyState == 1) || (xhr.readyState == 2) || (xhr.readyState == 3))
			{
//			document.getElementsByTagName('body')[0].style.cursor = "wait" ;
//			document.getElementById('patienter').style.display   = "block" ;
			}
                 
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;

			var ch = resultat.split("!") ;
			
			if (ch[0] == "Identification")
				{
				document.getElementById('Message').style.display = "block" ;
				document.getElementById('Message').innerHTML = "IDENTIFIEZ-VOUS !" ;
				
				if (base == "Capet")
					{
					window.open('http://www.capet.org/promo1.htm','wclose', 'width=550, height=700, toolbar=no, scrollbars=yes, status=no, left=240, top=170') ;
					}
				}
			else if (ch[0] == "Promo2")
				{
				if (base == "Capet")
					{
					window.open('http://www.capet.org/promo2.htm','wclose', 'width=550, height=700, toolbar=no, scrollbars=yes, status=no, left=240, top=170') ;
					}
				}
			else if (ch[0] == "Promo3")
				{
				if (base == "Capet")
					{
					window.open('http://www.capet.org/promo3.htm','wclose', 'width=550, height=700, toolbar=no, scrollbars=yes, status=no, left=240, top=170') ;
					}
				}
			else if (ch[0] == "Terminer")
				{
				document.getElementById('Message').style.display = "block" ;
				document.getElementById('Message').innerHTML = "DECONNECTEZ-VOUS !" ;
				}
			else
				{
				document.getElementById('Message').style.display = "none" ;

				var sosa  = ch[0].split(";") ;
				var label = ch[1].split("@") ;
				var liste = ch[2].split("@") ;

//				On se sert de innerHTML pour afficher dans les champs

				var i ;
				var info ;
				var sosa1 ;
				var blason  = new Array() ;
				var mariage = new Array() ;
				var frere ;
				var soeur ;
				var liste_enfants ;
				var liste_conjoints ;
			
				for (i=1 ; i<maxi ; i++)
					{
					if (sosa[i-1] == "")
						{
						document.getElementById('sosa'+i).innerHTML = "0" ;

						$("#F"+i).css("display","none") ;
						$("#N"+i).css("display","none") ;
						$("#Q"+i).css("display","none") ;
						$("#D"+i).css("display","none") ;
						$("#B"+i).css("display","none") ;

						blason[i-1]  = "" ;
						mariage[i-1] = "" ;
						}
					else
						{
						$("#F"+i).css("display","block") ;
						$("#N"+i).css("display","block") ;
						$("#Q"+i).css("display","block") ;
						$("#D"+i).css("display","block") ;

						$("#Q"+i).css("visibility","visible") ;
						$("#D"+i).css("visibility","visible") ;

						info = sosa[i-1].split("@") ;							// Toutes les infos concernant le personnage
						
						document.getElementById('sosa'+i).innerHTML = info[0] ;	// Numéro
						document.getElementById('F'+i).innerHTML = info[1] ;		// Nom, prénom, dates de naissance et de décès
						document.getElementById('F'+i).style.background = info[2] ;	// Groupe d'appartenance
						document.getElementById('F'+i).style.cursor = "pointer" ;
//						$("#sosa"+i).val(info[0]) ;							// Numéro
//						$("#F"+i).val(info[1]) ;								// Nom, prénom, dates de naissance et de décès
//						$("#F"+i).css("background", info[2]) ;					// Groupe d'appartenance
//						$("#F"+i).css("cursor","pointer") ;

						blason[i-1]  = info[3] ;								// Blason
						mariage[i-1] = info[4] ;								// Date et lieu de mariage
					
						if (i == 1)
							{
							sosa1 = info[0] ;								// Numéro du personnage de base

							if (info[5] == 1)								// Il existe descendance
								$("#Fleche").css("visibility", "visible") ;
							else	$("#Fleche").css("visibility", "hidden") ;
							}

						if (info[6] == 1)									// Il existe une notice
							{
							var notice ;
						
							notice  = "<a href='#' onclick='window.open(\"G_Notice.php?base=" + base + "&n=" + i +"\")'>" ;
							notice += "<img src='images/note_ok.png' border='0'></a>" ;

							$("#N"+i).css("visibility","visible") ;
							$("#N"+i).html(notice) ;

// 26.06.2009					if (i == 1) document.getElementById('Message2').innerHTML = notice ;
							}
						else
							{
							$("#N"+i).css("visibility","hidden") ;

							if (i == 1) document.getElementById('Message2').innerHTML = "" ;
							}

						if ((i == 1) && (ch[3] != ""))						// Il existe un message
							{
							alert (ch[3]) ;
							}
							
						if (blason[i-1] == "")
							{
							document.getElementById('B'+i).style.display = "none" ;				
							}
						else	
							{					
							blason[i-1] = blason[i-1].replace (/\'/g, '%27') ;
							blason[i-1] = blason[i-1].replace (/ /g, '%20') ;

							blason[i-1] = blason[i-1].replace (/à/g, '%E0') ;
							blason[i-1] = blason[i-1].replace (/ä/g, '%E4') ;
							blason[i-1] = blason[i-1].replace (/â/g, '%E2') ;
							blason[i-1] = blason[i-1].replace (/ç/g, '%E7') ;
							blason[i-1] = blason[i-1].replace (/é/g, '%E9') ;
							blason[i-1] = blason[i-1].replace (/è/g, '%E8') ;
							blason[i-1] = blason[i-1].replace (/ë/g, '%EB') ;
							blason[i-1] = blason[i-1].replace (/ê/g, '%EA') ;
							blason[i-1] = blason[i-1].replace (/î/g, '%EE') ;
							blason[i-1] = blason[i-1].replace (/ï/g, '%EF') ;
							blason[i-1] = blason[i-1].replace (/ô/g, '%F4') ;
							blason[i-1] = blason[i-1].replace (/ö/g, '%F6') ;
							blason[i-1] = blason[i-1].replace (/û/g, '%FB') ;
							blason[i-1] = blason[i-1].replace (/ü/g, '%FC') ;

							blason[i-1] = blason[i-1].replace (/À/g, '%C0') ;
							blason[i-1] = blason[i-1].replace (/Ä/g, '%C4') ;
							blason[i-1] = blason[i-1].replace (/Â/g, '%C2') ;
							blason[i-1] = blason[i-1].replace (/Ç/g, '%C7') ;
							blason[i-1] = blason[i-1].replace (/É/g, '%C9') ;
							blason[i-1] = blason[i-1].replace (/È/g, '%C8') ;
							blason[i-1] = blason[i-1].replace (/Ë/g, '%CB') ;
							blason[i-1] = blason[i-1].replace (/Ê/g, '%CA') ;
							blason[i-1] = blason[i-1].replace (/Î/g, '%CE') ;
							blason[i-1] = blason[i-1].replace (/Ï/g, '%CF') ;
							blason[i-1] = blason[i-1].replace (/Ô/g, '%D4') ;
							blason[i-1] = blason[i-1].replace (/Ö/g, '%D6') ;
							blason[i-1] = blason[i-1].replace (/Û/g, '%DB') ;
							blason[i-1] = blason[i-1].replace (/Ü/g, '%DC') ;

							document.getElementById('B'+i).style.display = "block" ;
							document.getElementById('B'+i).style.backgroundImage = "url(" + blason[i-1] + ")" ;
							}
						}
					}
				
				for (i=2 ; i<maxi ; i=i+2)
					{
					if (mariage[i] == "")
						{
						document.getElementById('MAR'+i).style.display = "none" ;
						}
					else
						{
						document.getElementById('MAR'+i).style.display = "block" ;					
						document.getElementById('MAR'+i).innerHTML = mariage[i] ;
						}
					}
			
				var libelle ;
			
				frere = label[0] ;
				soeur = label[1] ;
				
				var lib1 = "" ;
				if (frere == 1) lib1 = "un frère" ;
				if (frere >= 2) lib1 = frere + " frères" ;
			
				var lib2 = "" ;
				if (soeur == 1) lib2 = "une soeur" ;
				if (soeur >= 2) lib2 = soeur + " soeurs" ;
			
				if ((frere >0) && (soeur >0)) libelle = lib1 + " et " + lib2 ;
				if ((frere >0) && (soeur==0)) libelle = lib1 ;
				if ((frere==0) && (soeur >0)) libelle = lib2 ;
				if ((frere==0) && (soeur==0)) libelle = "" ;

				if (libelle == "")
					{
					if ((sosa[1] == "") || (sosa[2] == ""))
						{
						document.getElementById('SaisirEnfant').innerHTML = "" ;
						document.getElementById('AjoutEnfant').style.display = "none" ;
						}
					else
						{
						document.getElementById('SaisirEnfant').innerHTML = "Saisir un frère ou une soeur" ;
						document.getElementById('AjoutEnfant').style.display = "block" ;
						}
					}
				else
					{
					document.getElementById('SaisirEnfant').innerHTML = "" ;
					document.getElementById('AjoutEnfant').style.display = "block" ;
					}

				document.getElementById('Enfants').style.display = "block" ;
				document.getElementById('Enfants').innerHTML = libelle ;
				
				document.getElementById('Liste_enfants').style.display = "block" ;
				document.getElementById('Liste_enfants').innerHTML = liste[0] ;
				
				document.getElementById('Liste_conjoints').style.display = "block" ;
				document.getElementById('Liste_conjoints').innerHTML = liste[1] ;
				
				js_Fiche (base, sosa1) ;				
				}
			}
		}

	xhr.open ("POST", "ajaxTableau.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idBase=" + base + "&idSosa=" + n + "&idMaxi=" + maxi) ;
	}

function js_AffBlason(base, n)
	{
	var base = $("#f_base").val() ;
	var url  = "G_Blason.php?base=" + base + "&n=" + n ;

	window.open (url, "wclose", "width=360,height=555,toolbar=no,scrollbars=no,status=no,left=240,top=170") ;
	}

function js_deroule (id)
	{
	if  (document.getElementById(id).style.display == "none")
		document.getElementById(id).style.display  = "block" ;
	else document.getElementById(id).style.display  = "none" ;
	}	

function js_ChercheNomEnfant (n)
	{
	var xhr = getHTTPObject () ;

	var navigateur = navigator.appName ;
					
//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;
			
			var personne = resultat.split(";") ;			

			var libelle ;
			
			var i = 0 ;
						
			while (personne[i] != "")
				{
				if (i == 0)
					{
					var liste = document.getElementById("liste") ;

					texte = document.createElement("div") ;
					texte.innerHTML = "<font color='red'><b>Vous êtes en train de saisir un nouveau personnage</b></font><br>Peut-être figure-t-il déjà dans la base capétienne ?<br>Si oui, sélectionnez-le dans la liste suivante :<br>" ;	
					liste.appendChild(texte) ;

					ret = document.createElement("br") ;
					liste.appendChild(ret) ;
					
					if (navigateur == "Netscape")
						{
						perso = document.createElement("input") ;
						perso.name  = "perso" ;
						perso.type  = "radio" ;
						perso.id    = "perso0" ;
						perso.value = 0 ;
						perso.setAttribute('onClick', 'js_SelectPersonne('+ i + ',' + n + ')') ;
						}
					else
						{
						p = "<input type='radio' name='perso' id='perso0' value='0' onClick='js_SelectPersonne(0, " + n + ")'>" ;
						perso = document.createElement (p) ;
						}

					liste.appendChild(perso) ;
	
					texte = document.createElement("span") ;
					texte.innerHTML = "Création d'un nouveau personnage" ;	
					liste.appendChild(texte) ;

					ret = document.createElement("br") ;
					liste.appendChild(ret) ;
					}
					
				option = personne[i].split("@") ;

				var base = $("#f_base").val() ;
				
				var loupe = "<a href='G_Personnage.php?base=" + base + "&n=" + option[0] + "' target='wclose'" ;
				loupe += "onclick=\"window.open('G_Personnage.php?base=" + base + "&n=" + option[0] + "' ,'wclose', 'width=380, height=180, toolbar=no, scrollbars=yes, status=no, left=264, top=170')\">" ;
				loupe += "<img src='images/loupe.jpg' border='0'></a>" ;
	
				libelle = option[2] + " " + option[1] + " (" + option[5] + "-" + option[9] + ")" + loupe ;
				
				liste = document.getElementById("liste") ;
				liste.style.backgroundColor = "#FFC0C0" ;	

				if (navigateur == "Netscape")
					{
					perso = document.createElement("input") ;
					perso.name  = "perso" ;
					perso.type  = "radio" ;
					perso.id    = "perso" + (i+1) ;
					perso.value = (i+1) ;
					perso.setAttribute('onClick', 'js_SelectPersonne('+ option[0] + ',' + n + ')') ;
					}
				else
					{
					p = "<input type='radio' name='perso' id='perso" + (i+1) + "' value='" + (i+1) + "' onClick='js_SelectPersonne(" + option[0] + ", " + n + ")'>" ;
					perso = document.createElement (p) ;					
					}

				liste.appendChild(perso) ;

				texte = document.createElement("span") ;
				texte.innerHTML = libelle ;	
				liste.appendChild(texte) ;

				ret = document.createElement("br") ;
				liste.appendChild(ret) ;
				
				i++ ;
				}

// 28.05.2008	liste = document.getElementById("Fiche") ;					// Redimensionnement de la fiche
// 28.05.2008	liste.style.height = perso.offsetTop + 380 + "px" ;			
			}		
		}
		
	ch  = ($("#f_base").val() + "@") ;
	ch += ($("#enfant_nom"+n).val() + "@") ;
	ch += ($("#enfant_prenom"+n).val() + "@") ;
	ch += ($("#enfant_sexe"+n).val() + "@") ;

	xhr.open ("POST", "ajaxRecherche.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idChaine=" + ch) ;
	}


function js_ChercheNomConjoint ()
	{
	var xhr = getHTTPObject () ;

	var navigateur = navigator.appName ;
					
//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;
			
			var personne = resultat.split(";") ;			

			var libelle ;
			
			var i = 0 ;
						
			while (personne[i] != "")
				{
				if (i == 0)
					{
					var liste = document.getElementById("liste") ;

					texte = document.createElement("div") ;
					texte.innerHTML = "<font color='red'><b>Vous êtes en train de saisir un nouveau personnage</b></font><br>Peut-être figure-t-il déjà dans la base capétienne ?<br>Si oui, sélectionnez-le dans la liste suivante :<br>" ;	
					liste.appendChild(texte) ;

					ret = document.createElement("br") ;
					liste.appendChild(ret) ;
					
					if (navigateur == "Netscape")
						{
						perso = document.createElement("input") ;
						perso.name  = "perso" ;
						perso.type  = "radio" ;
						perso.id    = "perso0" ;
						perso.value = 0 ;
						perso.setAttribute('onClick', 'js_SelectPersonneConjoint('+ i + ',0)') ;
						}
					else
						{
						p = "<input type='radio' name='perso' id='perso0' value='0' onClick='js_SelectPersonneConjoint(0, 0)'>" ;
						perso = document.createElement (p) ;
						}

					liste.appendChild(perso) ;
	
					texte = document.createElement("span") ;
					texte.innerHTML = "Création d'un nouveau personnage" ;	
					liste.appendChild(texte) ;

					ret = document.createElement("br") ;
					liste.appendChild(ret) ;
					}
					
				option = personne[i].split("@") ;
				
				var loupe = "<a href='G_Personnage.php?n=" + option[0] + "' target='wclose'" ;
				loupe += "onclick=\"window.open('G_Personnage.php?n=" + option[0] + "' ,'wclose', 'width=380, height=180, toolbar=no, scrollbars=yes, status=no, left=264, top=170')\">" ;
				loupe += "<img src='images/loupe.jpg' border='0'></a>" ;
	
				libelle = option[2] + " " + option[1] + " (" + option[5] + "-" + option[9] + ")" + loupe ;
				
				liste = document.getElementById("liste") ;
				liste.style.backgroundColor = "#FFC0C0" ;	

				if (navigateur == "Netscape")
					{
					perso = document.createElement("input") ;
					perso.name  = "perso" ;
					perso.type  = "radio" ;
					perso.id    = "perso" + (i+1) ;
					perso.value = (i+1) ;
					perso.setAttribute('onClick', 'js_SelectPersonneConjoint('+ option[0] + ',0)') ;
					}
				else
					{
					p = "<input type='radio' name='perso' id='perso" + (i+1) + "' value='" + (i+1) + "' onClick='js_SelectPersonneConjoint(" + option[0] + ", 0)'>" ;
					perso = document.createElement (p) ;					
					}

				liste.appendChild(perso) ;

				texte = document.createElement("span") ;
				texte.innerHTML = libelle ;	
				liste.appendChild(texte) ;

				ret = document.createElement("br") ;
				liste.appendChild(ret) ;
				
				i++ ;
				}

// 28.05.2008	liste = document.getElementById("Fiche") ;					// Redimensionnement de la fiche
// 28.05.2008	liste.style.height = perso.offsetTop + 380 + "px" ;			
			}		
		}
		
	ch  = ($("#f_base").val() + "@") ;
	ch += ($("#conjoint_nom").val() + "@") ;
	ch += ($("#conjoint_prenom").val() + "@") ;
	ch += (($("#f_sexe").val() ^ 1) + "@") ;

	xhr.open ("POST", "ajaxRecherche.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idChaine=" + ch) ;
	}


function js_IndiquerSexe (n)
	{
	var sexe = $("#enfant_sexe"+n).val() ;

	if (sexe > 1) alert ("Veuillez sélectionner le sexe !") ;
	}


function js_SelectPersonne (numero, n)
	{
	var xhr = getHTTPObject () ;

//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;
			
			if (resultat != "Nouveau")
				{
				var ch = resultat.split("@") ;

//				On se sert de innerHTML pour afficher dans les champs

				$("#enfant_nom"+n).val(ch[1]) ;
				$("#enfant_prenom"+n).val(ch[2]) ;

				$("#enfant_n_jour"+n).val(ch[3]) ;
				$("#enfant_n_mois"+n).val(ch[4]) ;
				$("#enfant_n_annee"+n).val(ch[5]) ;
				$("#enfant_n_lieu"+n).val(ch[6]) ;
				$("#enfant_n_dpt"+n).val(ch[7]) ;

				$("#enfant_d_jour"+n).val(ch[8]) ;
				$("#enfant_d_mois"+n).val(ch[9]) ;
				$("#enfant_d_annee"+n).val(ch[10]) ;
				$("#enfant_d_lieu"+n).val(ch[11]) ;
				$("#enfant_d_dpt"+n).val(ch[12]) ;
				
				relation = numero ;				

				alert ("Relation établie : vous pouvez compléter puis valider !") ;
				}
				
			js_EffaceListe () ;
			}		
		}
		
	ch = $("#f_base").val() + "@" + numero ;

	xhr.open ("POST", "ajaxSelection.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idNumero=" + ch) ;
	}


function js_SelectPersonneConjoint (numero, n)
	{
	var xhr = getHTTPObject () ;

//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;
			
			if (resultat != "Nouveau")
				{
				var ch = resultat.split("@") ;

//				On se sert de innerHTML pour afficher dans les champs

				$("#conjoint_nom").val(ch[1]) ;
				$("#conjoint_prenom").val(ch[2]) ;

				$("#conjoint_n_jour").val(ch[3]) ;
				$("#conjoint_n_mois").val(ch[4]) ;
				$("#conjoint_n_annee").val(ch[5]) ;
				$("#conjoint_n_lieu").val(ch[6]) ;
				$("#conjoint_n_dpt").val(ch[7]) ;

				$("#conjoint_d_jour").val(ch[8]) ;
				$("#conjoint_d_mois").val(ch[9]) ;
				$("#conjoint_d_annee").val(ch[10]) ;
				$("#conjoint_d_lieu").val(ch[11]) ;
				$("#conjoint_d_dpt").val(ch[12]) ;				

				relation = numero ;				

				alert ("Relation établie : vous pouvez compléter puis valider !") ;
				}
				
			js_EffaceListe () ;
			}		
		}
		
	ch = $("#f_base").val() + "@" + numero ;

	xhr.open ("POST", "ajaxSelection.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idNumero=" + ch) ;
	}


function js_ChercheLieu (champ)
	{
	gecode = document.forms["Modifier"].elements[champ].value.split("(") ;

	lieu   = gecode[0] ;
//	code   = gecode[1].split(")") ;
//	dpt    = code[0] ;
	}
	

function js_Autotab (origine, destination)
	{
//	if (origine.getAttribute && (origine.value.length == origine.getAttribute("maxlength"))) destination.focus() ;
	if ($("#"+origine).val().length == $("#"+origine).attr("maxlength")) $("#"+destination).focus() ;
	}


function js_Fiche(base, numero)
	{
	var xhr = getHTTPObject () ;

	var notice ;

//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
		if ((xhr.readyState == 1) || (xhr.readyState == 2) || (xhr.readyState == 3))
			{
//			document.getElementsByTagName('body')[0].style.cursor = "wait" ;
//			document.getElementById('patienter').style.display   = "block" ;
			}
                 
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;
		
			var mariage = resultat.split(";") ;
			var ch = mariage[0].split("@") ;

			if (ch[0] == "Identification")
				{
				document.getElementById('Message').style.display = "block" ;
				document.getElementById('Message').innerHTML = "IDENTIFIEZ-VOUS !" ;
				}
			else
				{
				var langue = $("#f_langue").val() ;

//				On se sert de innerHTML pour afficher dans les champs

//				document.getElementById('Clic').style.display = "block" ;
//				document.getElementById('Clic').innerHTML = ch[1] ;
				
// 26.06.2009		document.getElementById('Message').style.display = "block" ;
				
				switch (langue)
					{
					case "us"	: fiche = "Note " + numero ;
							  break ;

					default	: fiche = "Fiche n°" + numero ;
							  break ;
					}

// 26.06.2009		document.getElementById('Message').innerHTML = fiche ;

//				document.getElementById(numero).style.background = "#FFFF99" ;

				$("#f_base").val(base) ;
				$("#f_numero").val(numero) ;
				
				$("#n_base").val(base) ;
				$("#n_numero").val(numero) ;

				$("#i_base").val(base) ;
				$("#i_numero").val(numero) ;

				$("#nom").val(ch[2]) ;
				$("#prenom").val(ch[3]) ;
				$("#f_sexe").val(ch[4]) ;
				
				$("#n_jour").val(ch[5]) ;
				$("#n_mois").val(ch[6]) ;
				$("#n_annee").val(ch[7]) ;
				$("#n_lieu").val(ch[8]) ;
				$("#n_dpt").val(ch[9]) ;
				
				$("#d_jour").val(ch[10]) ;
				$("#d_mois").val(ch[11]) ;
				$("#d_annee").val(ch[12]) ;
				$("#d_lieu").val(ch[13]) ;
				$("#d_dpt").val(ch[14]) ;
				
				$("#titre").val("") ;
				$("#auteur").val("") ;
				$("#page").val("") ;
				$("#annee").val("") ;
				$("#note").val("") ;
				$("#fichier").val("") ;
				
				var exp = new RegExp ("geneal", "g")
// 26.06.2009
				ch[22] = 0 ;

				if (ch[22] == 1)									// Il existe une notice
					{
					switch (langue)
						{
						case "us"	: notice = "Complete notice <a href='G_Notice.php?base=" + base + "&p=xx&n=" + numero + "' " ;
								  break ;

						default	: notice = "Notice complète <a href='G_Notice.php?base=" + base + "&p=xx&n=" + numero + "' " ;
								  break ;
						}
											
//					notice += "onclick=\"window.location.replace('G_Notice.php?base=\" + base + \"&p=xx&n=\" + numero + \"','wclose', 'width=885, height=700, toolbar=no, scrollbars=yes, status=no')\">" ;
					notice += "onclick=\"window.open('G_Notice.php?base=" + base + "&p=xx&n=" + numero + "','wclose', 'width=885, height=700, toolbar=no, scrollbars=yes, status=no')\">" ;
					notice += "<img src='images/note_ok.png' border='0'></a>" ;
								 
					if (exp.test(window.location) == false)
						{
////						notice += "&nbsp;&nbsp;&nbsp;Arbre <a href='geneal.php?n=1'><img src='images/Geneal6a.ico' border='0'></a>" ;
						}

					document.getElementById('Message2').innerHTML = notice ;
					}
				else
					{
					if (exp.test(window.location) == false)
						{
////						notice = "&nbsp;&nbsp;&nbsp;Arbre <a href='geneal.php?n=1'><img src='images/Geneal6a.ico' border='0'></a>" ;
						notice = "" ;
						}
					else	notice = "" ;

					document.getElementById('Message2').innerHTML = notice ;
					}

				js_FicheSujet (0) ;

//				Suppression de tous les champs mariage

				var element ;
				
				element = document.getElementById("lib") ;

				while (element.firstChild)
					{
					element.removeChild(element.firstChild) ;
					}
				
				element = document.getElementById("mar") ;

				while (element.firstChild)
					{
					element.removeChild(element.firstChild) ;
					}
					
				if (ch[20] == "") mariage[0] = "" ;					// Pas de conjoint

				var i  = 0 ;
				nb_mar = 0 ;
				
				while (mariage[i] != "")
					{
					ch = mariage[i].split("@") ;

					i++ ;

//					Date, lieu de mariage, nom et n° du conjoint

					switch (langue)
						{
						case "us"	: label = "<br>Marriage " + i + " :<br>Spouse :<br><br>" ;
								  break ;
								  
						default	: label = "<br>Mariage " + i + " :<br>Conjoint :<br><br>" ;
								  break ;
						}

					$("#lib").append("<div id='lib"+i+"' style='float:left; width:100%; text-align:right; font-size:11px; line-height:18px;'>"+label+"</div>") ;					
					$("#mar").append("<div id='mar"+i+"' style='float:left; line-height:18px;'><br></div>") ;

					$("#mar"+i).append("<input type='hidden' id='conjoint"+i+"' value='"+ch[21]+"'>") ;

					$("#mar"+i).append("<input class='champ' type='text' maxlength='2' id='m_jour"+i+"' value='"+ch[15]+"' style='width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
					$("#m_jour"+i).keyup(function(){js_Autotab("m_jour"+i, "m_mois"+i);}) ;

					$("#mar"+i).append("<input class='champ' type='text' maxlength='2' id='m_mois"+i+"' value='"+ch[16]+"' style='width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
					$("#m_mois"+i).keyup(function(){js_Autotab("m_mois"+i, "m_annee"+i);}) ;

					$('#mar'+i).append('<input class="champ" type="text" maxlength="4" id="m_annee'+i+'" value="'+ch[17]+'" style="width:32px; text-align:center; margin-right:1px; margin-bottom:1px;">') ;
					$('#m_annee'+i).keyup(function(){js_Autotab('m_annee'+i, 'm_lieu'+i);}) ;
					
					$('#mar'+i).append('<input class="champ" type="text" size="25" maxlength="40" id="m_lieu'+i+'" value="'+ch[18]+'" style="width:'+$lg_lieu+'px; margin-right:1px; margin-bottom:1px;">') ;
					$('#m_lieu'+i).focus(function(){setAutoComplete('m_lieu'+i, 'results', 'ajaxFormulaire2.php?base='+base+'&champ=lieu&debut=');});

					$("#mar"+i).append("<input class='champ' type='text' maxlength='6' id='m_dpt"+i+"' value='"+ch[19]+"' style='width:63px; margin-bottom:1px;'>") ;
					$("#mar"+i).append("<br>") ;					
					$('#mar'+i).append('<input class="champ" type="text" size="50" id="nom_conjoint'+i+'" value="'+ch[20]+'" style="margin-bottom:1px;">') ;
					$('#mar'+i).append('<br>') ;
					
					switch (langue)								// Bouton Modifier
						{
						case "us"	: label = "Modify" ;
								  break ;

						default	: label = "Modifier" ;
								  break ;
						}
			
					$("#mar"+i).append ("<input class='bouton' type='button' id='btn_modifier_conjoint"+i+"' value='"+label+"' style='width:56px; margin-bottom:1px;'>") ;
					$("#btn_modifier_conjoint"+i).click(function()
						{
						var btn = $(this).attr("id").split("btn_modifier_conjoint") ;
						js_FicheConjoint (btn[1], 1) ;
						}) ;
					
					switch (langue)								// Bouton Ajout enfant
						{
						case "us"	: label = "Add a child" ;
								  break ;

						default	: label = "Ajout enfant" ;
								  break ;
						}

					$("#mar"+i).append ("<input class='bouton' type='button' id='btn_ajout_enfant"+i+"' value='"+label+"' style='width:86px; margin-bottom:1px;'>") ;
					$("#btn_ajout_enfant"+i).click(function()
						{
						var btn = $(this).attr("id").split("btn_ajout_enfant") ;
						js_AjoutEnfant (btn[1]) ;
						}) ;				
																// Combo sexe

					select  = "<select id='enfant_sexe"+i+"' style='width:56px; margin-left:4px;'>" ;
					select += "<option value='2'>Sexe</option>" ;
					select += "<option value='0' style='background-color:blue; color:#FFFFFF;'>Garçon</option>" ;
					select += "<option value='1' style='background-color:red; color:#FFFFFF;'>Fille</option>" ;
					select += "</select>" ;

					$("#mar"+i).append (select) ;

					switch (langue)								// Bouton Valider
						{
						case "us"	: label = "Valid" ;
								  break ;

						default	: label = "Valider" ;
								  break ;
						}
						
					$("#mar"+i).append ("<input class='bouton' type='button' id='btn_valider_conjoint"+i+"' value='"+label+"' style='width:54px; margin-bottom:1px; margin-left:2px;'>") ;
					$("#btn_valider_conjoint"+i).click(function()
						{
						var btn = $(this).attr("id").split("btn_valider_conjoint") ;
						js_ValiderConjoint (btn[1]) ;
						}) ;

					switch (langue)								// Bouton Annuler
						{
						case "us"	: blabel = "Cancel" ;
								  break ;

						default	: label = "Annuler" ;
								  break ;
						}
				
					$("#mar"+i).append ("<input class='bouton' type='button' id='btn_annuler_conjoint"+i+"' value='"+label+"' style='width:54px; margin-bottom:1px; margin-left:2px;'>") ;
					$("#btn_annuler_conjoint"+i).click(function()
						{
						var btn = $(this).attr("id").split("btn_annuler_conjoint") ;
						js_FicheConjoint(btn[1], 0) ;
						}) ;
						
					$("#mar"+i).append ("<br>") ;

					js_FicheConjoint (i, 0) ;
					}
				}
				
			nb_mar = i ;
					
			if (ch[0] == 0)										// Niveau = 0
				{
				$("#btn_modifier_sujet").attr("disabled", true) ;
				$("#btn_ajout_conjoint").attr("disabled", true) ;

				for (i=1 ; i<=nb_mar ; i++) $("#btn_modifier_conjoint"+i).attr("disabled", true) ;	
				for (i=1 ; i<=nb_mar ; i++) $("#btn_ajout_enfant"+i).attr("disabled", true) ;	
				}
			}
		}

	xhr.open ("POST", "ajaxFiche.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idBase=" + base + "&idNumero=" + numero) ;
	}


function js_FicheSujet (modif)
	{
	var active ;
	
	if (modif)
		active = false ;
	else	active = true ;

	$("#nom").attr("disabled", active) ;
	$("#prenom").attr("disabled", active) ;

	$("#n_jour").attr("disabled", active) ;	
	$("#n_mois").attr("disabled", active) ;	
	$("#n_annee").attr("disabled", active) ;	
	$("#n_lieu").attr("disabled", active) ;	
	$("#n_dpt").attr("disabled", active) ;	
	
	$("#d_jour").attr("disabled", active) ;	
	$("#d_mois").attr("disabled", active) ;	
	$("#d_annee").attr("disabled", active) ;	
	$("#d_lieu").attr("disabled", active) ;	
	$("#d_dpt").attr("disabled", active) ;	
	
	if (modif)
		{
		$("#btn_modifier_sujet").css("visibility","hidden") ;
		$("#btn_ajout_conjoint").css("visibility","hidden") ;
		$("#btn_valider_sujet").attr("disabled", false) ;	
		$("#btn_annuler_sujet").attr("disabled", false) ;	

		for (i=1 ; i<=nb_mar ; i++) $("#btn_modifier_conjoint"+i).attr("disabled", true) ;	
		for (i=1 ; i<=nb_mar ; i++) $("#btn_ajout_enfant"+i).attr("disabled", true) ;	
		}
	else
		{
		$("#btn_modifier_sujet").css("visibility","visible") ;
		$("#btn_ajout_conjoint").css("visibility","visible") ;
		$("#btn_valider_sujet").attr("disabled", true) ;	
		$("#btn_annuler_sujet").attr("disabled", true) ;	

		if (nb_mar >= 1)
			{
			for (i=1 ; i<=nb_mar ; i++) $("#btn_modifier_conjoint"+i).attr("disabled", false) ;	
			for (i=1 ; i<=nb_mar ; i++) $("#btn_ajout_enfant"+i).attr("disabled", false) ;	
			for (i=1 ; i<=nb_mar ; i++) $("#btn_valider_conjoint"+i).attr("disabled", true) ;	
			for (i=1 ; i<=nb_mar ; i++) $("#btn_annuler_conjoint"+i).attr("disabled", true) ;	
			}

		if ($("#ajout_lib").length > 0)
			{				
			document.getElementById("ajout_lib").parentNode.removeChild(document.getElementById("ajout_lib")) ;
			document.getElementById("ajout_mar").parentNode.removeChild(document.getElementById("ajout_mar")) ;
			}

		var exp = new RegExp ("Contribution|Index", "g")

		if (exp.test(window.location))
			{
			$("#btn_ajout_conjoint").css("visibility","hidden") ;			
			}
		}
				
	js_EffaceListe () ;
	}


function js_ValiderSujet()
	{
	var xhr = getHTTPObject () ;
	var url ;
	var base ;

//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;

			if (document.forms["Modifier"].elements["btn_ajout_conjoint"].style.visibility == "hidden")	// Rajout d'un conjoint
//			if ($("#btn_ajout_conjoint").height() < 2)											// C-à-d bouton non visible			
				{																		// Rajout d'un conjoint
				var message  = resultat.split("@") ;
				var conjoint = message[0] ;

/***				btn_C = document.getElementById("btn_ajout_conjoint") ;
				btn_C.style.visibility  = "visible" ;***/
				
				$("#btn_ajout_conjoint").css("visibility","visible") ;

				var exp = new RegExp ("geneal", "g")

				if (exp.test(window.location))
					{
					base = $("#f_base").val() ;

					url = window.location.toString().split('?') ;				
					url[0] += "?base=" + base + "&n=1" ;
			
					window.location.replace (url[0]) ;
					}
				else
					{
					var numero = $("#f_numero").val() ;
					var texte  = js_InfoConjoint (numero, ch) ;				
					var span   = document.getElementById('SP'+numero) ;
					var td     = document.getElementById('TD'+numero) ;

					var div2 = document.createElement("div") ;
					div2.id  = numero ;
					div2.style.marginLeft = "30px" ;
					div2.style.fontSize   = "12px" ;

					var parent  = document.getElementById(span.parentNode.id) ;
					var suivant = span.nextSibling ;
					parent.insertBefore(div2 ,suivant) ;
					
					texte = td.innerHTML + texte ;
					
					td.innerHTML = "<font color='red'>" + texte + "</font>" ;					

					js_Fiche (base, numero) ;
					}

				js_FicheSujet (0) ;
				}
			else													// Modification du sujet
				{
				var exp = new RegExp ("Modification non", "g") ;
			
				if (exp.test(resultat)) alert (resultat) ;				// Modification non autorisée
			
				base = $("#f_base").val() ;

				var url = window.location.toString().split('?') ;				
				url[0] += "?base=" + base + "&n=1" ;
			
				window.location.replace (url[0]) ;
				}
			}		
		}

	if ($("#ajout_mar").length == 0)									// Modification du sujet
		{
		ch  = ($("#f_base").val() + "@") ;
		ch += ($("#f_numero").val() + "@") ;

		ch += ($("#nom").val() + "@") ;
		ch += ($("#prenom").val() + "@") ;

		ch += ($("#n_jour").val() + "@") ;
		ch += ($("#n_mois").val() + "@") ;
		ch += ($("#n_annee").val() + "@") ;		

		var lieu = $("#n_lieu").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#n_lieu").val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#n_dpt").val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#n_lieu").val() + "@") ;
			ch += ($("#n_dpt").val() + "@") ;
			}

		ch += ($("#d_jour").val() + "@") ;
		ch += ($("#d_mois").val() + "@") ;
		ch += ($("#d_annee").val() + "@") ;

		var lieu = $("#d_lieu").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#d_lieu").val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#d_dpt").val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#d_lieu").val() + "@") ;
			ch += ($("#d_dpt").val() + "@") ;
			}

		js_FicheSujet (0) ;

		xhr.open ("POST", "ajaxValidationSujet.php", true) ;
		}
	else															// Ajout d'un conjoint
		{
		if ($("#conjoint_nom").val() == "")
			{
			$("#conjoint_nom").val("ZZ_" + $("#f_numero").val()) ;
			}

		if ($("#conjoint_prenom").val() == "")
			{
			if  ($("#f_sexe").val() == 1)
				$("#conjoint_prenom").val("N...") ;
			else	$("#conjoint_prenom").val("Ne...") ;
			}

		ch  = (relation + "@") ;
		ch += ($("#f_base").val() + "@") ;
		ch += ($("#f_numero").val() + "@") ;
		ch += ("0@") ;
		ch += ($("#conjoint_nom").val() + "@") ;
		ch += ($("#conjoint_prenom").val() + "@") ;
		ch += ($("#f_sexe").val() + "@") ;

		ch += ($("#conjoint_n_jour").val() + "@") ;
		ch += ($("#conjoint_n_mois").val() + "@") ;
		ch += ($("#conjoint_n_annee").val() + "@") ;
		
		var lieu = $("#conjoint_n_lieu").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#conjoint_n_lieu").val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#conjoint_n_dpt").val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#conjoint_n_lieu").val() + "@") ;
			ch += ($("#conjoint_n_dpt").val() + "@") ;
			}

		ch += ($("#conjoint_d_jour").val() + "@") ;
		ch += ($("#conjoint_d_mois").val() + "@") ;
		ch += ($("#conjoint_d_annee").val() + "@") ;

		var lieu = $("#conjoint_d_lieu").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#conjoint_d_lieu").val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#conjoint_d_dpt").val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#conjoint_d_lieu").val() + "@") ;
			ch += ($("#conjoint_d_dpt").val() + "@") ;
			}

		ch += ($("#conjoint_m_jour").val() + "@") ;
		ch += ($("#conjoint_m_mois").val() + "@") ;
		ch += ($("#conjoint_m_annee").val() + "@") ;

		var lieu = $("#conjoint_m_lieu").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#conjoint_m_lieu").val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#conjoint_m_dpt").val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#conjoint_m_lieu").val() + "@") ;
			ch += ($("#conjoint_m_dpt").val() + "@") ;
			}

		relation = 0 ;

		xhr.open ("POST", "ajaxAjoutConjoint.php", true) ;
		}
	
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idChaine=" + ch) ;
	}


function js_FicheConjoint (n, modif)
	{
	var	active ;

	if (modif)
		active = false ;
	else	active = true ;

	$("#m_jour"+n).attr("disabled", active) ;	
	$("#m_mois"+n).attr("disabled", active) ;	
	$("#m_annee"+n).attr("disabled", active) ;	
	$("#m_lieu"+n).attr("disabled", active) ;	
	$("#m_dpt"+n).attr("disabled", active) ;	
	$("#nom_conjoint"+n).attr("disabled", true) ;
	
	if (modif)
		{
		for (i=1 ; i<=nb_mar ; i++)
			{
			if (i == n)
				{
				$("#btn_modifier_conjoint"+n).css("visibility","hidden") ;
				$("#btn_ajout_enfant"+n).css("visibility","hidden") ;
				}
			else
				{
				$("#btn_modifier_conjoint"+i).attr("disabled", true) ;
				$("#btn_ajout_enfant"+i).attr("disabled", true) ;
				}
			}
			
		$("#btn_modifier_sujet").attr("disabled", true) ;
		$("#btn_ajout_conjoint").attr("disabled", true) ;
		}
	else
		{
		for (i=1 ; i<=nb_mar ; i++)
			{
			$("#btn_modifier_conjoint"+i).attr("disabled", false) ;
			$("#btn_ajout_enfant"+i).attr("disabled", false) ;

			if (i == n)
				{
				$("#btn_modifier_conjoint"+n).css("visibility","visible") ;
				$("#btn_ajout_enfant"+n).css("visibility","visible") ;

				if ($("#ajout_lib").length > 0)
					{				
					document.getElementById("ajout_lib").parentNode.removeChild(document.getElementById("ajout_lib")) ;
					document.getElementById("ajout_mar").parentNode.removeChild(document.getElementById("ajout_mar")) ;
					}
				}
			}
			
		$("#btn_modifier_sujet").attr("disabled", false) ;
		$("#btn_ajout_conjoint").attr("disabled", false) ;
		}

	$("#enfant_sexe"+n).css("visibility","hidden") ;
	$("#enfant_sexe"+n).attr("disabled", active) ;
	$("#btn_valider_conjoint"+n).attr("disabled", active) ;
	$("#btn_annuler_conjoint"+n).attr("disabled", active) ;
				
	js_EffaceListe () ;

	var exp = new RegExp ("Contribution|Index", "g")

	if (exp.test(window.location))
		{
		$("#btn_ajout_enfant"+n).css("visibility","hidden") ;
		}
	}


function js_ValiderConjoint(n)
	{
	var xhr = getHTTPObject () ;
	var url ;
	var base ;

//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;

			if ($("#ajout_mar").length == 0)							// Modification du conjoint
				{
				alert (resultat) ;

				base = $("#f_base").val() ;

				url = window.location.toString().split('?') ;				
				url[0] += "?base=" + base + "&n=1" ;
			
				window.location.replace (url[0]) ;
				}
			else													// Ajout d'un enfant
				{
				var message = resultat.split("@") ;
				var enfant = message[0] ;

				if (enfant == "X")
					{
					alert ("Veuillez sélectionner le sexe !") ;
					}
				else
					{
					if (message.length > 1) alert (message[1]) ;

					btn_E = document.getElementById("btn_ajout_enfant" + n) ;
					btn_E.style.visibility = "visible" ;

					var exp = new RegExp ("geneal", "g")

					if (exp.test(window.location))
						{
						base = $("#f_base").val() ;

						url = window.location.toString().split('?') ;				
						url[0] += "?base=" + base + "&n=1" ;
			
//						window.location.replace (url[0]) ;
						}
					else
						{
						var texte  = js_InfoEnfant (enfant, ch) ;

						var numero = $("#f_numero").val() ;
						var div    = document.getElementById(numero) ;

						var span   = document.createElement("span") ;
						span.id    = "SP" + enfant ;
						span.style.display = "block" ;
						span.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td valign='top'><img src='images/TVplus0.gif' border='0'></td><td bgcolor='#FFC0C0'>" + texte + "</td></tr></table>" ;

						div.appendChild(span) ;
						}

//					js_Fiche (base, enfant) ;				
					js_FicheConjoint (n, 0) ;
					}
				}
			}		
		}

	if ($("#ajout_mar").length == 0)									// Modification du conjoint
		{
		ch  = ($("#f_base").val() + "@") ;
		ch += ($("#f_numero").val() + "@") ;

		ch += ($("#conjoint"+n).val() + "@") ;

		ch += ($("#m_jour"+n).val() + "@") ;
		ch += ($("#m_mois"+n).val() + "@") ;
		ch += ($("#m_annee"+n).val() + "@") ;

		var lieu = $("#m_lieu"+n).val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#m_lieu"+n).val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#m_dpt"+n).val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#m_lieu"+n).val() + "@") ;
			ch += ($("#m_dpt"+n).val() + "@") ;
			}

		js_FicheConjoint (n, 0) ;

		xhr.open ("POST", "ajaxValidationConjoint.php", true) ;		
		}
	else															// Ajout d'un enfant
		{
		if ($("#enfant_prenom"+n).val() == "")
			{
			alert ("Veuillez saisir le prénom !\n\nSi prénom inconnu :\nSaisissez N... pour un garçon, Ne... pour une fille.") ;

			return;
			}

		ch  = (relation + "@") ;
		ch += ($("#f_base").val() + "@") ;
		ch += ($("#f_numero").val() + "@") ;

		ch += ($("#conjoint"+n).val() + "@") ;
		ch += ($("#enfant_nom"+n).val() + "@") ;
		ch += ($("#enfant_prenom"+n).val() + "@") ;
		ch += ($("#enfant_sexe"+n).val() + "@") ;

		ch += ($("#enfant_n_jour"+n).val() + "@") ;
		ch += ($("#enfant_n_mois"+n).val() + "@") ;
		ch += ($("#enfant_n_annee"+n).val() + "@") ;

		var lieu = $("#enfant_n_lieu"+n).val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#enfant_n_lieu"+n).val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#enfant_n_dpt"+n).val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#enfant_n_lieu"+n).val() + "@") ;
			ch += ($("#enfant_n_dpt"+n).val() + "@") ;
			}

		ch += ($("#enfant_d_jour"+n).val() + "@") ;
		ch += ($("#enfant_d_mois"+n).val() + "@") ;
		ch += ($("#enfant_d_annee"+n).val() + "@") ;

		var lieu = $("#enfant_d_lieu"+n).val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			for (var i=0; i<tableau.length ; i++)
				{
	 			switch (i)
	 				{
	 				case 0  :	$("#enfant_d_lieu"+n).val(tableau[0]) ;
	 						ch += (tableau[0] + "@") ;
	 						break ;
				
					case 1  :	$("#enfant_d_dpt"+n).val(tableau[1]) ;
		 					ch += (tableau[1] + "@") ;
							break ;
						
					default :	break ;
	 				}
				}
			}
		else
			{
			ch += ($("#enfant_d_lieu"+n).val() + "@") ;
			ch += ($("#enfant_d_dpt"+n).val() + "@") ;
			}

		relation = 0 ;

		xhr.open ("POST", "ajaxAjoutEnfant.php", true) ;
		}
			
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idChaine=" + ch) ;
	}


function js_AjoutConjoint()
	{
	var n = nb_mar ;
	var br ;
	var lib2 ;
	var mar2 ;
		
	var base = $("#f_base").val() ;

	$("#nom").attr("disabled", true) ;	
	$("#prenom").attr("disabled", true) ;	

	$("#n_jour").attr("disabled", true) ;	
	$("#n_mois").attr("disabled", true) ;	
	$("#n_annee").attr("disabled", true) ;	
	$("#n_lieu").attr("disabled", true) ;	
	$("#n_dpt").attr("disabled", true) ;	
	
	$("#d_jour").attr("disabled", true) ;	
	$("#d_mois").attr("disabled", true) ;	
	$("#d_annee").attr("disabled", true) ;	
	$("#d_lieu").attr("disabled", true) ;	
	$("#d_dpt").attr("disabled", true) ;	
	
	$("#btn_modifier_sujet").css("visibility","hidden") ;
	$("#btn_ajout_conjoint").css("visibility","hidden") ;
	$("#btn_valider_sujet").attr("disabled", false) ;
	$("#btn_annuler_sujet").attr("disabled", false) ;

	if (nb_mar)
		{
		for (i=1 ; i<=nb_mar ; i++) $("#btn_modifier_conjoint"+i).attr("disabled", true) ;
		for (i=1 ; i<=nb_mar ; i++) $("#btn_ajout_enfant"+i).attr("disabled", true) ;
		for (i=1 ; i<=nb_mar ; i++) $("#btn_valider_conjoint"+i).attr("disabled", true) ;
		for (i=1 ; i<=nb_mar ; i++) $("#btn_annuler_conjoint"+i).attr("disabled", true) ;
		}

	var aide = "<a href='G_Aide.php' target='wclose'" ;
	aide += "onclick=\"window.open('G_Aide.php','wclose', 'width=400, height=400, toolbar=no, scrollbars=no, status=no, left=240, top=170')\">" ;
	aide += "<img src='images/aide2.gif' border='0'></a>" ;

	if ((n == undefined) || (nb_mar == 0))
		{
		$("#lib").append("<div id='ajout_lib' style='float:left; width:100%; text-align:right; font-size:11px; line-height:18px;'>"+aide+ "<br>Mariage :<br>Nom :<br>Prénom :<br>Naissance :<br>Décès :</div>") ;
		$("#mar").append("<div id='ajout_mar'></div>") ;
		}
	else
		{
		$("#lib"+n).append("<div id='ajout_lib' style='float:left; width:100%; text-align:right; font-size:11px; line-height:18px;'>"+aide+ "<br>Mariage " + (n+1) + " :<br>Nom :<br>Prénom :<br>Naissance :<br>Décès :</div>") ;
		$("#mar"+n).append("<div id='ajout_mar'></div>") ;
		}
	
	$("#ajout_mar").append("<br>") ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='2' id='conjoint_m_jour' value='' style='background-color:#FFC0C0; width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_m_jour").keyup(function(){js_Autotab('conjoint_m_jour', 'conjoint_m_mois');}) ;
	
	$("#ajout_mar").append("<input class='champ' type='text' maxlength='2' id='conjoint_m_mois' value='' style='background-color:#FFC0C0; width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_m_mois").keyup(function(){js_Autotab('conjoint_m_mois', 'conjoint_m_annee');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='4' id='conjoint_m_annee' value='' style='background-color:#FFC0C0; width:32px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_m_annee").keyup(function(){js_Autotab('conjoint_m_annee', 'conjoint_m_lieu');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='40' id='conjoint_m_lieu' value='' style='background-color:#FFC0C0; width:"+$lg_lieu+"px; margin-right:1px; margin-bottom:1px;'>") ;
	$('#conjoint_m_lieu').focus(function(){setAutoComplete('conjoint_m_lieu', 'results', 'ajaxFormulaire2.php?base='+base+'&champ=lieu&debut=');});

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='6' id='conjoint_m_dpt' value='' style='background-color:#FFC0C0; width:63px; margin-bottom:1px;'>") ;

	$("#ajout_mar").append("<br>") ;

	$("#ajout_mar").append("<input class='champ' type='text' size='50' id='conjoint_nom' value='' style='background-color:#FFC0C0; margin-bottom:1px; margin-top:0px;'>") ;
	$('#conjoint_nom').focus(function(){setAutoComplete('conjoint_nom', 'results', 'ajaxFormulaire2.php?base='+base+'&champ=nom&debut=');});

	$("#ajout_mar").append("<br>") ;

	$("#ajout_mar").append("<input class='champ' type='text' size='50' id='conjoint_prenom' value='' style='background-color:#FFC0C0; margin-bottom:1px; margin-top:0px;'>") ;
	$("#conjoint_prenom").blur(function(){js_ChercheNomConjoint();}) ;

	$("#ajout_mar").append("<br>") ;
		
	$("#ajout_mar").append("<input class='champ' type='text' maxlength='2' id='conjoint_n_jour' value='' style='background-color:#FFC0C0; width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_n_jour").keyup(function(){js_Autotab('conjoint_n_jour', 'conjoint_n_mois');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='2' id='conjoint_n_mois' value='' style='background-color:#FFC0C0; width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_n_mois").keyup(function(){js_Autotab('conjoint_n_mois', 'conjoint_n_annee');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='4' id='conjoint_n_annee' value='' style='background-color:#FFC0C0; width:32px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_n_annee").keyup(function(){js_Autotab('conjoint_n_annee', 'conjoint_n_lieu');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='40' id='conjoint_n_lieu' value='' style='background-color:#FFC0C0; width:"+$lg_lieu+"px; margin-right:1px; margin-bottom:1px;'>") ;
	$('#conjoint_n_lieu').focus(function(){setAutoComplete('conjoint_n_lieu', 'results', 'ajaxFormulaire2.php?base='+base+'&champ=lieu&debut=');});

	$("#ajout_mar").append("<input class='champ' type='text' size='5' maxlength='6' id='conjoint_n_dpt' value='' style='background-color:#FFC0C0; width:63px; margin-bottom:1px;'>") ;
					
	$("#ajout_mar").append("<br>") ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='2' id='conjoint_d_jour' value='' style='background-color:#FFC0C0; width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_d_jour").keyup(function(){js_Autotab('conjoint_d_jour', 'conjoint_d_mois');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='2' id='conjoint_d_mois' value='' style='background-color:#FFC0C0; width:18px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_d_mois").keyup(function(){js_Autotab('conjoint_d_mois', 'conjoint_d_annee');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='4' id='conjoint_d_annee' value='' style='background-color:#FFC0C0; width:32px; text-align:center; margin-right:1px; margin-bottom:1px;'>") ;
	$("#conjoint_d_annee").keyup(function(){js_Autotab('conjoint_d_annee', 'conjoint_d_lieu');}) ;

	$("#ajout_mar").append("<input class='champ' type='text' maxlength='40' id='conjoint_d_lieu' value='' style='background-color:#FFC0C0; width:"+$lg_lieu+"px; margin-right:1px; margin-bottom:1px;'>") ;
	$('#conjoint_d_lieu').focus(function(){setAutoComplete('conjoint_d_lieu', 'results', 'ajaxFormulaire2.php?base='+base+'&champ=lieu&debut=');});

	$("#ajout_mar").append("<input class='champ' type='text' size='5' maxlength='6' id='conjoint_d_dpt' value='' style='background-color:#FFC0C0; width:63px; margin-bottom:1px;'>") ;

//	liste = document.getElementById("Fiche") ;					// Redimensionnement de la fiche
//	liste.style.height = mar.offsetTop + 600 + "px" ;			
	}


function js_AjoutEnfant(n)
	{
	var navigateur = navigator.appName ;

	var br ;
	var lib2 ;
	var mar2 ;
	
	var btn_E ;
	var btn_V ;
	var btn_A ;

	var base = $("#f_base").val() ;

	$("#m_jour"+n).attr("disabled", true) ;	
	$("#m_mois"+n).attr("disabled", true) ;	
	$("#m_annee"+n).attr("disabled", true) ;	
	$("#m_lieu"+n).attr("disabled", true) ;	
	$("#m_dpt"+n).attr("disabled", true) ;	
	
	$("#btn_modifier_sujet").attr("disabled", true) ;
	$("#btn_ajout_conjoint").attr("disabled", true) ;
	$("#btn_valider_sujet").attr("disabled", true) ;
	$("#btn_annuler_sujet").attr("disabled", true) ;

	for (i=1 ; i<=nb_mar ; i++) $("#btn_modifier_conjoint"+i).attr("disabled", true) ;
	for (i=1 ; i<=nb_mar ; i++) $("#btn_ajout_enfant"+i).attr("disabled", true) ;
	for (i=1 ; i<=nb_mar ; i++) $("#btn_valider_conjoint"+i).attr("disabled", true) ;
	for (i=1 ; i<=nb_mar ; i++) $("#btn_annuler_conjoint"+i).attr("disabled", true) ;

	$("#btn_modifier_conjoint"+n).css("visibility","hidden") ;
	$("#btn_ajout_enfant"+n).css("visibility","hidden") ;
	$("#btn_valider_conjoint"+n).attr("disabled", false) ;
	$("#btn_annuler_conjoint"+n).attr("disabled", false) ;

	$("#enfant_sexe"+n).attr("disabled", false) ;
	$("#enfant_sexe"+n).css("visibility","visible") ;

	var aide = "<a href='G_Aide2.php' target='wclose'" ;
	aide += "onclick=\"window.open('G_Aide2.php','wclose', 'width=400, height=400, toolbar=no, scrollbars=no, status=no, left=240, top=170')\">" ;
	aide += "<img src='images/aide2.gif' border='0'></a>&nbsp;&nbsp;" ;
	
	$("#lib"+n).append("<div id='ajout_lib' style='text-align:right; font-size:11px; line-height:18px;'>"+aide+ "Nom :<br>Prénom :<br>Naissance :<br>Décès :</div>") ;
	$("#mar"+n).append("<div id='ajout_mar'></div>") ;
	
	if ($("#f_sexe").val() == 0)
		{
		enfant_nom = $("#nom").val() ;
		}
	else
		{
		var enfant_nom = $("#nom_conjoint"+n).val() ;
		
		var i = 1 ;

		while (enfant_nom.substr(i,1))
			{
			if ((enfant_nom.substr(i,1) >= 'A') && (enfant_nom.substr(i,1) <= 'Z')) break ;
	
			i++ ;
			}

		enfant_nom = enfant_nom.substr(i) ;
		}

	$('#ajout_mar').append('<input class="champ" type="text" size="50" maxlength="45" id="enfant_nom'+n+'" value="'+enfant_nom+'" style="background-color:#FFC0C0; margin-bottom:1px;">') ;	
	$('#enfant_nom'+n).focus(function(){setAutoComplete('enfant_nom'+n, 'results', 'ajaxFormulaire2.php?base='+base+'&champ=nom&debut=');});

	$('#ajout_mar').append('<input class="champ" type="text" size="50" maxlength="90" id="enfant_prenom'+n+'" value="" style="background-color:#FFC0C0; margin-bottom:1px;">') ;	
	$('#enfant_prenom'+n).focus(function(){js_IndiquerSexe(n);}) ;
	$('#enfant_prenom'+n).blur(function(){js_ChercheNomEnfant(n);}) ;

	$("#ajout_mar").append("<br>") ;
		
	$("#ajout_mar").append("<input class='champ' type='text' size='2' maxlength='2' id='enfant_n_jour"+n+"' value='' style='background-color:#FFC0C0; text-align:center; margin-right:4px; margin-bottom:1px;'>") ;
	$("#enfant_n_jour"+n).keyup(function(){js_Autotab("enfant_n_jour"+n, "enfant_n_mois"+n);}) ;

	$("#ajout_mar").append("<input class='champ' type='text' size='2' maxlength='2' id='enfant_n_mois"+n+"' value='' style='background-color:#FFC0C0; text-align:center; margin-right:4px; margin-bottom:1px;'>") ;
	$("#enfant_n_mois"+n).keyup(function(){js_Autotab("enfant_n_mois"+n, "enfant_n_annee"+n);}) ;

	$("#ajout_mar").append("<input class='champ' type='text' size='4' maxlength='4' id='enfant_n_annee"+n+"' value='' style='background-color:#FFC0C0; text-align:center; margin-right:4px; margin-bottom:1px;'>") ;
	$("#enfant_n_annee"+n).keyup(function(){js_Autotab("enfant_n_annee"+n, "enfant_n_lieu"+n);}) ;

	$("#ajout_mar").append("<input class='champ' type='text' size='25' maxlength='40' id='enfant_n_lieu"+n+"' value='' style='background-color:#FFC0C0; margin-right:4px; margin-bottom:1px;'>") ;
	$('#enfant_n_lieu'+n).focus(function(){setAutoComplete('enfant_n_lieu'+n, 'results', 'ajaxFormulaire2.php?base='+base+'&champ=lieu&debut=');});

	$("#ajout_mar").append("<input class='champ' type='text' size='5' maxlength='6' id='enfant_n_dpt"+n+"' value='' style='background-color:#FFC0C0; margin-bottom:1px;'>") ;

	$("#ajout_mar").append("<br>") ;

	$("#ajout_mar").append("<input class='champ' type='text' size='2' maxlength='2' id='enfant_d_jour"+n+"' value='' style='background-color:#FFC0C0; text-align:center; margin-right:4px; margin-bottom:1px;'>") ;
	$("#enfant_d_jour"+n).keyup(function(){js_Autotab("enfant_d_jour"+n, "enfant_d_mois"+n);}) ;

	$("#ajout_mar").append("<input class='champ' type='text' size='2' maxlength='2' id='enfant_d_mois"+n+"' value='' style='background-color:#FFC0C0; text-align:center; margin-right:4px; margin-bottom:1px;'>") ;
	$("#enfant_d_mois"+n).keyup(function(){js_Autotab("enfant_d_mois"+n, "enfant_d_annee"+n);}) ;

	$("#ajout_mar").append("<input class='champ' type='text' size='4' maxlength='4' id='enfant_d_annee"+n+"' value='' style='background-color:#FFC0C0; text-align:center; margin-right:4px; margin-bottom:1px;'>") ;
	$("#enfant_d_annee"+n).keyup(function(){js_Autotab("enfant_d_annee"+n, "enfant_d_lieu"+n);}) ;

	$("#ajout_mar").append("<input class='champ' type='text' size='25' maxlength='40' id='enfant_d_lieu"+n+"' value='' style='background-color:#FFC0C0; margin-right:4px; margin-bottom:1px;'>") ;
	$('#enfant_d_lieu'+n).focus(function(){setAutoComplete('enfant_d_lieu'+n, 'results', 'ajaxFormulaire2.php?base='+base+'&champ=lieu&debut=');});

	$("#ajout_mar").append("<input class='champ' type='text' size='5' maxlength='6' id='enfant_d_dpt"+n+"' value='' style='background-color:#FFC0C0; margin-bottom:1px;'>") ;
	}


function js_EffaceListe ()
	{
//	Suppression de toutes les options de la liste

	var element ;
				
	element = document.getElementById("liste") ;

	while (element.firstChild)
		{
		element.removeChild(element.firstChild) ;
		}

	var ht ;
	var exp = new RegExp ("geneal16", "g") ;

	if (exp.test(window.location))
		ht = "730px" ;
	else ht = "601px" ;

//	var liste = document.getElementById("Fiche") ;						// Redimensionnement de la fiche
//	liste.style.height = ht ;
	}


function js_InfoConjoint (numero, ch)
	{
	var item ;
	var texte ;
	var evt_N = "" ;
	var evt_M = "" ;
	var evt_D = "" ;

	item = ch.split("@") ;
	
	if (item[8] != "")
		{
		if (item[5] == 1)
			{
			if  (item[6] == 0)
				evt_N = ", né en " ;
			else evt_N = ", né le " ;
			}
		else
			{
			if  (item[6] == 0)
				evt_N = ", née en " ;
			else evt_N = ", née le " ;
			}
		
		if (item[6] != "")
			evt_N += (item[6] + "." + item[7] + "." + item[8]) ;
		else if (item[7] != "")
			evt_N += (item[7] + "." + item[8]) ;
		else evt_N +=  item[8] ;
		}
		
	if (item[9] != "")
		{
		evt_N += (" à " + item[9]) ;
		}
		
	if (item[13] != "")
		{
		if (item[5] == 1)
			{
			if  (item[11] == 0)
				evt_D = ", décédé en " ;
			else evt_D = ", décédé le " ;
			}
		else
			{
			if  (item[11] == 0)
				evt_D = ", décédée en " ;
			else evt_D = ", décédée le " ;
			}
		
		if (item[11] != "")
			evt_D += (item[11] + "." + item[12] + "." + item[13]) ;
		else if (item[12] != "")
			evt_D += (item[12] + "." + item[13]) ;
		else evt_D +=  item[13] ;
		}
		
	if (item[14] != "")
		{
		evt_D += (" à " + item[14]) ;
		}
		
	if (item[18] != "")
		{
		if (item[5] == 0)
			{
			if  (item[16] == 0)
				evt_M = "marié en " ;
			else evt_M = "marié le " ;
			}
		else
			{
			if  (item[16] == 0)
				evt_M = "mariée en " ;
			else evt_M = "mariée le " ;
			}
		
		if (item[16] != "")
			evt_M += (item[16] + "." + item[17] + "." + item[18]) ;
		else if (item[12] != "")
			evt_M += (item[17] + "." + item[18]) ;
		else evt_M +=  item[18] ;
		}
	else
		{
		if (item[5] == 0)
			evt_M = "marié " ;
		else	evt_M = "mariée " ;
		}
			
	if (item[19] != "")
		{
		evt_M += (" à " + item[19]) ;
		}
		
	texte = evt_M + " avec " + item[4] + " " + item[3] + evt_N + evt_D ;

	return texte ;	
	}


function js_InfoEnfant (enfant, ch)
	{
	var item ;
	var texte ;
	var evt_N = "" ;
	var evt_D = "" ;
	
	item = ch.split("@") ;

	var fiche = "js_Fiche(" + base + ", " + enfant + ")" ;

	texte = "<a href='#' onClick='" + fiche + "'>" + item[4] + " " + item[3] + "</a>" ;

	if (item[8] != "")
		{
		if (item[5] == 0)
			{
			if  (item[6] == 0)
				evt_N = "né en " ;
			else evt_N = "né le " ;
			}
		else
			{
			if  (item[6] == 0)
				evt_N = "née en " ;
			else evt_N = "née le " ;
			}
		
		if (item[6] != "")
			evt_N += (item[6] + "." + item[7] + "." + item[8]) ;
		else if (item[7] != "")
			evt_N += (item[7] + "." + item[8]) ;
		else evt_N +=  item[8] ;
		}
		
	if (item[9] != "")
		{
		evt_N += (" à " + item[9]) ;
		}
		
	if (evt_N != "") texte += (", " + evt_N) ;
	
	if (item[13] != "")
		{
		if (item[5] == 0)
			{
			if  (item[11] == 0)
				evt_D = "décédé en " ;
			else evt_D = "décédé le " ;
			}
		else
			{
			if  (item[11] == 0)
				evt_D = "décédée en " ;
			else evt_D = "décédée le " ;
			}
		
		if (item[11] != "")
			evt_D += (item[11] + "." + item[12] + "." + item[13]) ;
		else if (item[12] != "")
			evt_D += (item[12] + "." + item[13]) ;
		else evt_D +=  item[13] ;
		}
		
	if (item[14] != "")
		{
		evt_D += (" à " + item[14]) ;
		}
		
	if (evt_D != "") texte += (", " + evt_D) ;
	
	return texte ;	
	}


function js_Notice(base, numero)
	{
	var fiche ;
	
//	On se sert de innerHTML pour afficher dans les champs

	var langue = $("#n_langue").val() ;
	
	switch (langue)
		{
		case "us"	: fiche = "Note " + numero ;
				  break ;

		default	: fiche = "Fiche n°" + numero ;
				  break ;
		}

//	document.getElementById('Clic').style.display = "block" ;
//	document.getElementById('Clic').innerHTML = ch[1] ;

	document.getElementById('Message').style.display = "block" ;
	document.getElementById('Message').innerHTML = fiche ;

//	document.getElementById(numero).style.background = "#FFFF99" ;

	$("#n_base").val(base) ;
	$("#n_numero").val(numero) ;				
	}


function js_Reference()
	{
	var xhr = getHTTPObject () ;
	var ch  ;

//	On définit ce qu'on va faire quand on aura la réponse

	xhr.onreadystatechange = function ()
		{
//		On ne fait quelque chose que si on a tout reçu et que le serveur est ok

		if (xhr.readyState == 4 && xhr.status == 200)
			{
			resultat = xhr.responseText ;
			
			$("#notice_titre").val("") ;
			$("#notice_auteur").val("") ;
			$("#notice_page").val("") ;
			$("#notice_annee").val("") ;
			$("#note").val("") ;
			
			alert (resultat) ;
			}		
		}
		
	if (($("#notice_titre").val() == "") && ($("#notice_auteur").val() == "") && ($("#note").val() == "")) return ;

	if  (document.forms["Notice"].elements["public"].checked == true)
		public = "1"
	else	public = "0" ;

	for (i=0 ; i<3 ; i++)
		{
		if (document.forms["Notice"].elements["type"][i].checked == true)
			{
			type = i ;
			break ;
			}
		}
		
	ch  = ($("#n_base").val() + "#") ;
	ch += ($("#n_numero").val() + "#") ;

	ch += ($("#notice_titre").val() + "#") ;
	ch += ($("#notice_auteur").val() + "#") ;
	ch += ($("#notice_page").val() + "#") ;
	ch += ($("#notice_annee").val() + "#") ;
	ch += ($("#note").val() + "#") ;
	ch += ($("#email").val() + "#") ;
	ch += (public + "#" + type) ;

	xhr.open ("POST", "ajaxValidationNotice.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idChaine=" + ch) ;
	}

function js_Maison ()
	{
	var base   = $("#f_base").val() ;
	var numero = $("#maison").val() ;
	
	var url = "geneal.php?base=" + base + "&p=xx&n=" + numero ;
	
	window.location.replace (url) ;
	}

function js_Maison2 ()
	{
	if (navigateur == "FF") return ;
	
	var numero = $("#maison").val() ;
	
	if (numero == 0)
		{
		$("#maison").css("width", "120px") ;
		document.forms["Maisons"].elements["maison"].size = 25 ;
		}
	}
