var relation = 0 ;
var n ;
var base ;
var num_sosa ;
var enfant_numero ;

$Fx = new Array () ;
$Fy = new Array () ;

$Fx[1] = 354 ;
$Fy[1] = 436 ;
$Fx[2] = 175 ;
$Fy[2] = 275 ;
$Fx[3] = 533 ;
$Fy[3] = 275 ;
$Fx[4] = 95 ;
$Fy[4] = 96 ;
$Fx[5] = 267 ;
$Fy[5] = 96 ;
$Fx[6] = 441 ;
$Fy[6] = 96 ;
$Fx[7] = 613 ;
$Fy[7] = 96 ;

for (i=1 ; i<8 ; i++)
	{
	$Fx[i] += 21 ;
	$Fy[i] += 160 ;
	}

$lg = 166 ;
$ht = 69  ;
$lg_code = $lg - 74 ;

if (navigator.appName == "Netscape")
	$br = "<br>" ;
else	$br = "<BR>" ;

function js_OuvreSosa(a)
	{
	js_FermeSosa (n) ;

	base = $("#f_base").val() ;

	if (a == 0)													// Ajout premier personnage
		{
		n = 1 ;

		var num   = 1 ;
		var c_num = 0 ;

		info = new Array () ;

		info[0] = "" ;
		info[1] = "" ;
		info[2] = "__.__.____" ;
		info[3] = "__.__.____" ;
		}
	else if (a == 1)												// Ajout enfant
		{
		n = 1 ;

		var num   = $("#sosa2").html() ;
		var c_num = $("#sosa3").html() ;

		info = new Array () ;

		var enfant_nom = $("#F1").html().split($br) ;

		info[0] = enfant_nom[0] ;
		info[1] = "" ;
		info[2] = "__.__.____" ;
		info[3] = "__.__.____" ;
		}
	else if ((a == 2) || (num_sosa == 0))								// Ajout nouveau personnage
		{
		if (document.forms["Modifier"].elements["btn_modifier_sujet"].disabled == true)
			{
			alert ("Saisie non autorisée !") ;
			return ;
			}

		if ($("#f_base").val() == "Capet")
			{
			alert ("Saisie en ascendance non autorisée !") ;
			return ;
			}

		info = new Array () ;
		
		if (n > 1)
			{
			i = n / 2 ;
			i = parseInt (i) ;

			enfant_numero = $("#sosa"+i).html() ;
			}
		else	enfant_numero = 0 ;

		info[0] = "" ;
		info[1] = "" ;
		info[2] = "__.__.____" ;
		info[3] = "__.__.____" ;
		}
	else
		{
		if (document.forms["Modifier"].elements["btn_modifier_sujet"].disabled == true)
			{
			alert ("Données non modifiables !") ;
			return ;
			}

		var info = $("#F"+n).html().split($br) ;		
		var num  = $("#sosa"+n).html() ;

		if (num == 0)
			{
			alert ("Saisie ascendante non autorisée !") ;
			return ;
			}
		}

	switch (a)
		{
		case 0  : $("#Case1").append("<form id='Sosa' style='position:absolute; top:0px; z-index:2'></form>") ;
				a = 1 ;
				break ;
		
		case 1  : $("#Case1").append("<form id='Sosa' style='position:absolute; top:"+$ht+"px;'></form>") ;
				break ;
		
		default : $("#Case"+n).append("<form id='Sosa' style='position:absolute; top:0px; height:200px;'></form>") ;
				break ;
		}

	$("#Sosa").append("<input type='hidden' id='numero' value='"+num+"'>") ;
	$("#Sosa").append("<input type='hidden' id='conjoint' value='"+c_num+"'>") ;
	
//	info[0] = info[0].replace(/\'/g, '\u0027') ;

	$('#Sosa').append('<input class="sosa" type="text" id="sosa_nom" maxlength="45" value="'+info[0]+'" style="width:'+$lg+'px;">') ;
	$('#sosa_nom').focus(function(){setAutoComplete('sosa_nom', 'results', 'ajaxFormulaire2.php?base='+base+'&champ=nom&debut=');});

	$('#Sosa').append('<input class="sosa" type="text" id="sosa_prenom" maxlength="90" value="'+info[1]+'" style="width:'+$lg+'px;">') ;
	$('#sosa_prenom').focus(function(){js_IndiquerSexeSosa();}) ;
	if (a > 0) $('#sosa_prenom').blur(function(){js_ChercheNomSosa();}) ;
	
	date = info[2].split(".") ;
	if (date[0].substring(0,2) == "__")   date[0] = "" ;
	if (date[1].substring(0,2) == "__")   date[1] = "" ;
	if (date[2].substring(0,4) == "____") date[2] = "" ;
	date[2] = date[2].substring(0,4) ;

	$("#Sosa").append("<input class='sosa' type='text' id='n_sosa_jour' maxlength='2' value='"+date[0]+"' style='width:19px;'>") ;
	$("#n_sosa_jour").keyup(function(){js_Autotab('n_sosa_jour', 'n_sosa_mois');}) ;

	$("#Sosa").append("<input class='sosa' type='text' id='n_sosa_mois' maxlength='2' value='"+date[1]+"' style='width:19px;'>") ;
	$("#n_sosa_mois").keyup(function(){js_Autotab('n_sosa_mois', 'n_sosa_annee');}) ;

	$("#Sosa").append("<input class='sosa' type='text' id='n_sosa_annee' maxlength='4' value='"+date[2]+"' style='width:33px;'>") ;
	$("#n_sosa_annee").keyup(function(){js_Autotab('n_sosa_annee', 'n_sosa_code');}) ;

	var reg  = new RegExp ("[,()]+", "g") ;
	var tableau = info[2].split(reg) ;

	if (tableau.length <2) tableau[1] = "" ;

	$("#Sosa").append("<input class='sosa' type='text' id='n_sosa_code' maxlength='30' value='"+tableau[1]+"' style='width:"+$lg_code+"px;'>") ;
	$("#n_sosa_code").focus(function(){setAutoComplete("n_sosa_code", "results", "ajaxFormulaire2.php?base="+base+"&champ=lieu&debut=");});
	
	date = info[3].split(".") ;
	if (date[0].substring(0,2) == "__")   date[0] = "" ;
	if (date[1].substring(0,2) == "__")   date[1] = "" ;
	if (date[2].substring(0,4) == "____") date[2] = "" ;
	date[2] = date[2].substring(0,4) ;

	$("#Sosa").append("<input class='sosa' type='text' id='d_sosa_jour' maxlength='2' value='"+date[0]+"' style='width:19px;'>") ;
	$("#d_sosa_jour").keyup(function(){js_Autotab('d_sosa_jour', 'd_sosa_mois');}) ;

	$("#Sosa").append("<input class='sosa' type='text' id='d_sosa_mois' maxlength='2' value='"+date[1]+"' style='width:19px;'>") ;
	$("#d_sosa_mois").keyup(function(){js_Autotab('d_sosa_mois', 'd_sosa_annee');}) ;

	$("#Sosa").append("<input class='sosa' type='text' id='d_sosa_annee' maxlength='4' value='"+date[2]+"' style='width:33px;'>") ;
	$("#d_sosa_annee").keyup(function(){js_Autotab('d_sosa_annee', 'd_sosa_code');}) ;

	var reg  = new RegExp ("[,()]+", "g") ;
	var tableau = info[3].split(reg) ;

	if (tableau.length <2) tableau[1] = "" ;

	$("#Sosa").append("<input class='sosa' type='text' id='d_sosa_code' maxlength='30' value='"+tableau[1]+"' style='width:"+$lg_code+"px;'>") ;
	$("#d_sosa_code").focus(function(){setAutoComplete("d_sosa_code", "results", "ajaxFormulaire2.php?base="+base+"&champ=lieu&debut=");});
		
	$("#Sosa").append("<input class='bouton' type='button' id='btn_valider' value='Valider' style='width:54px;'>") ;
	$("#btn_valider").click(function(){js_ValideSosa (a) ;}) ;

	$("#Sosa").append("<input class='bouton' type='button' id='btn_annuler' value='Annuler' style='width:54px;'>") ;
	$("#btn_annuler").click(function(){js_FermeSosa(n) ;}) ;

	if ((a > 0) && (a < 80) && (n == 1))								// Combo sexe
		{
		select  = "<select id='sexe_enfant' style='width:56px; margin-left:2px;'>" ;
		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>" ;

		$("#Sosa").append(select) ;
		}
	}
	
function js_FermeSosa(n)
	{
	var	i ;
	var	mar ;

	if  (n % 2)
		mar = n - 1 ;
	else	mar = n
	
	if  (document.getElementById("Sosa") != null)
		{
		document.getElementById("Sosa").parentNode.removeChild(document.getElementById("Sosa")) ;

		if (n > 1) $("#MAR"+mar).show() ;
		$("#Fleche").show() ;
		}
	else
		{
		if (n > 1) $("#MAR"+mar).hide() ;
		$("#Fleche").hide() ;
		
//		for (i=1 ; i<=7 ; i++) $("#Case"+i).append("<div id='Masque'"+i+"' style='position:absolute; top:0px; width:100%; height:100%;'></div>") ;
		}


	js_EffaceListe () ;
	}
	
	
function js_ValideSosa(a)
	{
	var xhr = getHTTPObject () ;
	var url ;
	
	var base = $("#f_base").val() ;

//	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)
			{
			js_FermeSosa (n) ;

			resultat = xhr.responseText ;

			var message = resultat.split("@") ;

			var enfant = message[0] ;

			var exp = new RegExp ("Modification non", "g") ;
			
			if (exp.test(enfant)) alert (enfant) ;						// Modification non autorisée

			url = window.location.toString().split('?') ;				
			url[0] += "?base=" + base + "&n=1" ;
			
			window.location.replace (url[0]) ;
			}		
		}

	if (a == 1)													// Ajout enfant
		{
		if ($("#sosa_prenom").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 += (base + "@") ;
		ch += ($("#numero").val() + "@") ;
		ch += ($("#conjoint").val() + "@") ;
		ch += ($("#sosa_nom").val() + "@") ;
		ch += ($("#sosa_prenom").val() + "@") ;
		ch += ($("#sexe_enfant").val() + "@") ;

		ch += ($("#n_sosa_jour").val() + "@") ;
		ch += ($("#n_sosa_mois").val() + "@") ;
		ch += ($("#n_sosa_annee").val() + "@") ;

		var lieu = $("#n_sosa_code").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			$("#n_sosa_code").val(tableau[1]) ;
			ch += (tableau[0] + "@") ;
			ch += (tableau[1] + "@") ;
			}
		else
			{
			ch += ("@") ;
			ch += ($("#n_sosa_code").val() + "@") ;
			}

		ch += ($("#Sosa").val() + "@") ;
		ch += ($("#d_sosa_mois").val() + "@") ;
		ch += ($("#d_sosa_annee").val() + "@") ;

		var lieu = $("#d_sosa_code").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			$("#d_sosa_code").val(tableau[1]) ;
			ch += (tableau[0] + "@") ;
			ch += (tableau[1] + "@") ;
			}
		else
			{
			ch += ("@") ;
			ch += ($("#d_sosa_code").val() + "@") ;
			}

		document.getElementById("Sosa").parentNode.removeChild(document.getElementById("Sosa")) ;

		xhr.open ("POST", "ajaxAjoutEnfant.php", true) ;
		}
	else if (a == 2)												// Ajout nouveau personnage
		{
		if ($("#sosa_prenom").val() == "")
			{
			alert ("Veuillez saisir le prénom !\n\nSi prénom inconnu :\nSaisissez N... pour un homme, Ne... pour une femme.") ;

			return;
			}
			
		if (n > 1)
			sexe = n%2 ;
		else sexe = $("#sexe_enfant").val() ;

		ch  = (relation + "@") ;
		ch += (base + "@") ;
		ch += (enfant_numero + "@") ;
		ch += ($("#sosa_nom").val() + "@") ;
		ch += ($("#sosa_prenom").val() + "@") ;
		ch += (sexe + "@") ;

		ch += ($("#n_sosa_jour").val() + "@") ;
		ch += ($("#n_sosa_mois").val() + "@") ;
		ch += ($("#n_sosa_annee").val() + "@") ;

		var lieu = $("#n_sosa_code").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			$("#n_sosa_code").val(tableau[1]) ;
			ch += (tableau[0] + "@") ;
			ch += (tableau[1] + "@") ;
			}
		else
			{
			ch += ("@") ;
			ch += ($("#n_sosa_code").val() + "@") ;
			}

		ch += ($("#d_sosa_jour").val() + "@") ;
		ch += ($("#d_sosa_mois").val() + "@") ;
		ch += ($("#d_sosa_annee").val() + "@") ;

		var lieu = $("#d_sosa_code").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			$("#d_sosa_code").val(tableau[1]) ;
			ch += (tableau[0] + "@") ;
			ch += (tableau[1] + "@") ;
			}
		else
			{
			ch += ("@") ;
			ch += ($("#d_sosa_code").val() + "@") ;
			}

		document.getElementById("Sosa").parentNode.removeChild(document.getElementById("Sosa")) ;

		xhr.open ("POST", "ajaxAjoutNouveau.php", true) ;
		}
	else															// Modification personnage
		{
		ch  = (base + "@") ;
		ch += ($("#numero").val() + "@") ;
		ch += ($("#sosa_nom").val() + "@") ;
		ch += ($("#sosa_prenom").val() + "@") ;

		ch += ($("#n_sosa_jour").val() + "@") ;
		ch += ($("#n_sosa_mois").val() + "@") ;
		ch += ($("#n_sosa_annee").val() + "@") ;		

		var lieu = $("#n_sosa_code").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			$("#n_sosa_code").val(tableau[1]) ;
			ch += (tableau[0] + "@") ;
			ch += (tableau[1] + "@") ;
			}
		else
			{
			ch += ("@") ;
			ch += ($("#n_sosa_code").val() + "@") ;
			}

		ch += ($("#d_sosa_jour").val() + "@") ;
		ch += ($("#d_sosa_mois").val() + "@") ;
		ch += ($("#d_sosa_annee").val() + "@") ;

		var lieu = $("#d_sosa_code").val() ;
		var reg  = new RegExp ("[,()]+", "g") ;
		var tableau = lieu.split(reg) ;

		if (tableau.length > 1)
			{
			$("#d_sosa_code").val(tableau[1]) ;
			ch += (tableau[0] + "@") ;
			ch += (tableau[1] + "@") ;
			}
		else
			{
			ch += ("@") ;
			ch += ($("#d_sosa_code").val() + "@") ;
			}

		document.getElementById("Sosa").parentNode.removeChild(document.getElementById("Sosa")) ;

		xhr.open ("POST", "ajaxValidationSujet.php", true) ;
		}

	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idChaine=" + ch) ;
	}

function js_IndiquerSexeSosa ()
	{
	if (n > 1) return ;
	
	var sexe = $("#sexe_enfant").val() ;

	if (sexe > 1) alert ("Veuillez sélectionner le sexe !") ;
	}

function js_ChercheNomSosa ()
	{
	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)
					{
					document.getElementById("smiley").style.display = "block" ;

					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_SelectPersonne1('+ i + ',0)') ;
						}
					else
						{
						p = "<input type='radio' name='perso' id='perso0' value='0' onClick='js_SelectPersonne1(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 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_SelectPersonne1('+ option[0] + ',0)') ;
					}
				else
					{
					p = "<input type='radio' name='perso' id='perso" + (i+1) + "' value='" + (i+1) + "' onClick='js_SelectPersonne1(" + 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++ ;
				}

/////		liste = document.getElementById("Fiche") ;					// Redimensionnement de la fiche
/////		liste.style.height = perso.offsetTop + 380 + "px" ;			
			}		
		}
		
	if (n > 1)
		sexe = n%2 ;
	else	sexe = $("#sexe_enfant").val() ;

	ch  = ($("#f_base").val() + "@") ;
	ch += ($("#sosa_nom").val() + "@") ;
	ch += ($("#sosa_prenom").val() + "@") ;
	ch += (sexe + "@") ;

	xhr.open ("POST", "ajaxRecherche.php", true) ;
	xhr.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded') ;
	xhr.send ("idChaine=" + ch) ;
	}

function js_SelectPersonne1 (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 ;

			document.getElementById("smiley").style.display = "none" ;

			if (resultat != "Nouveau")
				{
				var ch = resultat.split("@") ;

//				On se sert de innerHTML pour afficher dans les champs

				$("#sosa_nom").val(ch[1]) ;
				$("#sosa_prenom").val(ch[2]) ;

				$("#n_sosa_jour").val(ch[3]) ;
				$("#n_sosa_mois").val(ch[4]) ;
				$("#n_sosa_annee").val(ch[5]) ;
//				$("#n_sosa_lieu").val(ch[6]) ;
//				$("#n_sosa_dpt").val(ch[7]) ;
				$("#n_sosa_code").val(ch[7]) ;

				$("#d_sosa_jour").val(ch[8]) ;
				$("#d_sosa_mois").val(ch[9]) ;
				$("#d_sosa_annee").val(ch[10]) ;
//				$("#d_sosa_lieu").val(ch[11]) ;
//				$("#d_sosa_dpt").val(ch[12]) ;				
				$("#d_sosa_code").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_Arbre()
	{
	var base = $("#f_base").val() ;
	var url  = window.location.toString().split('?') ;				
	url[0] += "?base=" + base + "&n=1" ;
			
	window.location.replace (url[0]) ;
	}
	
function js_Supprimer(a)
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		var base = $("#f_base").val() ;		
		var url  = "G_Suppression.php?base=" + base + "&type=" + a + "&n=" + n ;

		window.open (url, "wclose", "width=380,height=300,toolbar=no,scrollbars=no,status=no,left=240,top=170") ;
		}
	}

function js_Ancetres()
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		var base = $("#f_base").val() ;
		var url  = "G_Asc.php?base=" + base + "&n=" + n ;

		window.open (url) ;
		}
	}

function js_Descendants()
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		var base = $("#f_base").val() ;
		var url  = "G_Desc.php?base=" + base + "&n=" + n ;

		window.open (url) ;
		}
	}

function js_Parente()
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		var base = $("#f_base").val() ;
		var url  = "G_Liste.php?base=" + base ;

		window.open (url, "wclose", "width=740,height=400,toolbar=no,scrollbars=no,status=no,left=240,top=170") ;
		}
	}

function js_Infos()
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		var base = $("#f_base").val() ;
		var url  = "G_Infos.php?base=" + base + "&n=" + n ;

		window.open (url, "wclose", "width=380,height=400,toolbar=no,scrollbars=no,status=no,left=240,top=170") ;
		}
	}

function js_Histo()
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		var base = $("#f_base").val() ;
		var url  = "G_Histo.php?base=" + base + "&n=" + n ;

		window.open (url, "wclose", "width=480,height=400,toolbar=no,scrollbars=yes,status=no,left=240,top=170") ;
		}
	}

function js_Message()
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		var base = $("#f_base").val() ;
		var url  = "G_Infos3.php?base=" + base + "&n=" + n ;

		window.open (url, "wclose", "width=480,height=400,toolbar=no,scrollbars=yes,status=no,left=240,top=170") ;
		}
	}

function js_Habilitation()
	{
	if (num_sosa == 0)
		{
		alert ("Choix invalide !") ;
		return ;
		}

	if (document.forms["Modifier"].elements["btn_modifier_sujet"].disabled == true)
		{
		alert ("Vous ne vous êtes pas identifié !") ;
		return ;
		}
	
	var base = $("#f_base").val() ;
	var url  = "G_Habilitation.php?base=" + base + "&n=" + n ;

	window.open (url, "wclose", "width=380,height=400,toolbar=no,scrollbars=no,status=no,left=240,top=170") ;
	}

function js_Nouveau()
	{
	if ((n > 1) && (num_sosa != 0))
		{
		alert ("Choix invalide !") ;
		}
	else
		{
		js_OuvreSosa(2) ;
		}
	}

menu_elemt = new Array ;
menu_elemt[0]  = "Informations supplémentaires|js_Infos()" ;
menu_elemt[1]  = "Historique des modifications|js_Histo()" ;
menu_elemt[2]  = "Ecrire aux auteurs|js_Message()" ;
menu_elemt[3]  = "" ;
menu_elemt[4]  = "Liste des ancêtres|js_Ancetres()" ;
menu_elemt[5]  = "Liste des descendants|js_Descendants()" ;
menu_elemt[6]  = "Parenté avec...|js_Parente()" ;
menu_elemt[7]  = "" ;
menu_elemt[8]  = "Saisie d'un nouveau personnage|js_Nouveau()" ;
menu_elemt[9]  = "" ;
menu_elemt[10] = "Modification|js_OuvreSosa(80)" ;
menu_elemt[11] = "Suppression totale|js_Supprimer('t')" ;
menu_elemt[12] = "Suppression lien père|js_Supprimer('p')" ;
menu_elemt[13] = "Suppression lien mère|js_Supprimer('m')" ;
menu_elemt[14] = "Suppression lien conjoint|js_Supprimer('c')" ;
menu_elemt[15] = "" ;
menu_elemt[16] = "Demande d'habilitation|js_Habilitation()" ;
	
function menu_position(e)
	{
//	menu_x = (navigator.appName == "Netscape") ? e.pageX : event.x+document.body.scrollLeft ;
//	menu_y = (navigator.appName == "Netscape") ? e.pageY : event.y+document.body.scrollTop ;
	menu_x = (navigator.appName == "Netscape") ? e.pageX : event.x+document.documentElement.scrollLeft ;
	menu_y = (navigator.appName == "Netscape") ? e.pageY : event.y+document.documentElement.scrollTop ;
	}

function menu_open()
	{
	var marge = parseInt (document.getElementById("Marge").innerHTML) ;

	n = 0 ;

	if      (menu_x>$Fx[1]+marge && menu_x<$Fx[1]+$lg+marge && menu_y>$Fy[1] && menu_y<$Fy[1]+$ht) n = 1 ;
	else if (menu_x>$Fx[2]+marge && menu_x<$Fx[2]+$lg+marge && menu_y>$Fy[2] && menu_y<$Fy[2]+$ht) n = 2 ;
	else if (menu_x>$Fx[3]+marge && menu_x<$Fx[3]+$lg+marge && menu_y>$Fy[3] && menu_y<$Fy[3]+$ht) n = 3 ;
	else if (menu_x>$Fx[4]+marge && menu_x<$Fx[4]+$lg+marge && menu_y>$Fy[4] && menu_y<$Fy[4]+$ht) n = 4 ;
	else if (menu_x>$Fx[5]+marge && menu_x<$Fx[5]+$lg+marge && menu_y>$Fy[5] && menu_y<$Fy[5]+$ht) n = 5 ;
	else if (menu_x>$Fx[6]+marge && menu_x<$Fx[6]+$lg+marge && menu_y>$Fy[6] && menu_y<$Fy[6]+$ht) n = 6 ;
	else if (menu_x>$Fx[7]+marge && menu_x<$Fx[7]+$lg+marge && menu_y>$Fy[7] && menu_y<$Fy[7]+$ht) n = 7 ;

	if (n)
		{
/***		num_sosa = document.getElementById("sosa"+n).innerHTML ; ***/
		num_sosa = $("#sosa"+n).html() ;

		document.getElementById("menu_box").style.top = menu_y + "px" ;
		document.getElementById("menu_box").style.left = menu_x + "px" ;
		document.getElementById("menu_ombre").style.top = menu_y+2 + "px" ;
		document.getElementById("menu_ombre").style.left = menu_x+2 + "px" ;
	
		if (num_sosa == 0)
			{
//			document.getElementById("menu_box").style.visibility = "hidden" ;
//			document.getElementById("menu_ombre").style.visibility = "hidden" ;
			document.getElementById("menu_box").style.visibility = "visible" ;
			document.getElementById("menu_ombre").style.visibility = "visible" ;
			}
		else
			{
			document.getElementById("menu_box").style.visibility = "visible" ;
			document.getElementById("menu_ombre").style.visibility = "visible" ;
			}

		return (false) ;
		}
	else	return (true) ;
	}

function menu_close()
	{
	if (document.getElementById)
		{
		document.getElementById("menu_box").style.top = 0 ;
		document.getElementById("menu_box").style.left = 0 ;
		document.getElementById("menu_ombre").style.top = 0 ;
		document.getElementById("menu_ombre").style.left = 0 ;
		document.getElementById("menu_box").style.visibility = "hidden" ;
		document.getElementById("menu_ombre").style.visibility = "hidden" ;
		}
	}

function menu_hl(mode, element)
	{
	if(mode == 1)
		{
		element.style.background = '#93A070' ;
		element.style.color = '#FFFFFF' ;
		}
	else
		{
		element.style.background ='#EED7A3' ;
		element.style.color = '#000000' ;
		}
	}

if(navigator.appName == "Netscape")
	document.captureEvents(Event.MOUSEMOVE) ;
