<?php
//debug($_SESSION['s_Title']);
		$commun = $_SESSION['t_commun'];
		$sId_Event_Type_Marb    = $_SESSION['event_type']['Marb'];
		$sId_Event_Type_Marc    = $_SESSION['event_type']['Marc'];
		$sId_Event_Type_Mar     = $_SESSION['event_type']['Mar'];
		$sId_Event_Type_Div     = $_SESSION['event_type']['Div'];		
		$sId_Event_Type_Union   = $_SESSION['event_type']['Union'];		
		$sId_Event_Type_Date    = $_SESSION['event_type']['Date'];		
		$sId_Event_Type_Birth   = $_SESSION['event_type']['Birth'];
		$sId_Event_Type_Baptism = $_SESSION['event_type']['Bapm'];		
		$sId_Event_Type_Death   = $_SESSION['event_type']['Deat'];		
		$sId_Event_Type_Burial  = $_SESSION['event_type']['Buri'];				
		
		$_SESSION['event_type'] = array('Marb'=>$sId_Event_Type_Marb, 'Marc'=>$sId_Event_Type_Marc,'Mar'=>$sId_Event_Type_Mar, 'Div'=>$sId_Event_Type_Div,
									'Union'=>$sId_Event_Type_Union, 'Date'=>$sId_Event_Type_Date, 'Birth'=>$sId_Event_Type_Birth, 
									'Bapm'=>$sId_Event_Type_Baptism, 'Deat'=>$sId_Event_Type_Death, 'Buri'=>$sId_Event_Type_Burial);
	//	echo "<div id='corps'>";
		if ($_SESSION['infos_confidentielles'] == false)  {	
							
		echo "<center><h1>".$_SESSION['s_Title']."</h1></center>";
		//Affichage du sexe
		$flag="";
		if ($commun['sex']==1) { $flag=IMAGES.'female.png'; }
		if ($commun['sex']==0) { $flag=IMAGES.'male.png'; }

		echo "<div id=button>";
		if($flag!="") {
			echo "  <img src=".$flag." width=14 height=14> ";
		}
		
		echo " ";
		echo $commun['lien-arbres']."&nbsp;";
		//Affichage du lien vers la liste de descendance
		echo "<a href='".Router::url('individus/asc_individu/'.$commun['individu'])."'><img src=".IMAGES.'list1.png'." alt='".decode_lng_text('DETAIL_IND_ASC')."'></a>";
		echo " ";
		if ($commun['descendance'] == 1)
		{
			//Affichage du lien vers la liste de descendance
			echo "<a href='".Router::url('individus/desc_individu/'.$commun['individu'])."'><img src=".IMAGES.'list2.png' ." alt='".decode_lng_text('DETAIL_IND_DESC')."'></a>";
		}
		echo "</div>";
		echo "<br>";
		
		
		
		echo "<br><center><table>";
		//variables de styles pour les tableaux
		$style_1 = "<td style='width: 20%; background-color: rgb(250, 210, 120);'>"; 
		$style_2 = "<td style='width: 25%; background-color: rgb(255, 255, 255);'>";
		$style_3 = "<td style='width: 55%; background-color: rgb(255, 255, 255);'>";
		$style_4 = "<td style='width: 80%; background-color: rgb(255, 255, 255);' colspan='2' rowspan='1'>";
			
		//Recherche de l'individu et affichage du tableau principal

		echo "<table style='text-align: left; width: 100%;' border='0'";
		echo "cellpadding='2' cellspacing='1' bgcolor='black'>";
		echo "<tbody>";
		echo "<tr bgcolor='white'>";
		//Affichage du prénom
		echo $style_1.decode_lng_text('SEARCH_FISRT_NAME')."</td>";
		echo $style_4.$commun['first_name']."</td>";
		echo "</tr>";
		//Affichage du nom
		echo "<tr>";
		echo $style_1.decode_lng_text('SEARCH_LAST_NAME')."</td>";
		echo $style_4.$commun['libelle']."</td>";
		echo "</tr>";
		// Display Nickname
		
		if($commun['nickname']!="") {
			echo "<tr>";
			echo $style_1.decode_lng_text('GEDTAG_NICK')."</td>";
			echo $style_4.$commun['nickname']."</td>";
			echo "</tr>";
		}
		//Affichage du titre
		
		if ($commun['titre']) {
			echo "<tr>";
			echo $style_1.decode_lng_text('GEDTAG_TITL')."</td>";
			echo $style_4.$commun['titre']."</td>";
			echo "</tr>";
		}
		//Affichage de la profession
		
		if ($commun['prof']) {
			echo "<tr>";
			echo $style_1.decode_lng_text('GEDTAG_OCCU')."</td>";
			echo $style_4.$commun['prof']."</td>";
			echo "</tr>";
		}
		
		$event = $_SESSION['t_common_events'];
	//var_dump($event);
		// Display birth
		if (isset($event[$sId_Event_Type_Birth]['id_event'])==true)
		{
			$note = $event[$sId_Event_Type_Birth]['note'];
			$plus = balloon('$sId_Event_Type_Birth', $note);
			$country = $event[$sId_Event_Type_Birth]['id_country'];
			$zone = $event[$sId_Event_Type_Birth]['id_zone'];
			$city = $event[$sId_Event_Type_Birth]['id_city'];
			if(isset($event[$sId_Event_Type_Birth]['place']))
			{
				$lieu_event = $event[$sId_Event_Type_Birth]['place'];
			}

			echo "<tr>";
			echo $style_1.decode_lng_text('GEDTAG_BIRT').$plus."</td>";
			//echo "<td style='width: 25%; background-color: rgb(204, 255, 255);'>".decode_date($event[$sId_Event_Type_Birth]['date'])."</td>";
			echo $style_2.decode_date_evnt($event[$sId_Event_Type_Birth])."</td>";
			echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
			echo "</tr>";
		}
		// Display Baptism
		if (isset($event[$sId_Event_Type_Baptism]['id_event']))
		{
			$note = $event[$sId_Event_Type_Baptism]['note'];
			$plus = balloon('$sId_Event_Type_Baptism', $note);
			$country = $event[$sId_Event_Type_Baptism]['id_country'];
			$zone = $event[$sId_Event_Type_Baptism]['id_zone'];
			$city = $event[$sId_Event_Type_Baptism]['id_city'];
			if(isset($event[$sId_Event_Type_Baptism]['place']))
			{
				$lieu_event = $event[$sId_Event_Type_Baptism]['place'];
			}

			echo "<tr>";
			echo $style_1.decode_lng_text('GEDTAG_BAPM').$plus."</td>";
			echo $style_2.decode_date_evnt($event[$sId_Event_Type_Baptism])."</td>";
			echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
			echo "</tr>";
		}
		// Display death
		if (isset($event[$sId_Event_Type_Death]['id_event']))
		{
			$note=$event[$sId_Event_Type_Death]['note'];
			$plus = balloon($sId_Event_Type_Death, $note);
			$country = $event[$sId_Event_Type_Death]['id_country'];
			$zone = $event[$sId_Event_Type_Death]['id_zone'];
			$city = $event[$sId_Event_Type_Death]['id_city'];
			if(isset($event[$sId_Event_Type_Death]['place']))
			{
				$lieu_event = $event[$sId_Event_Type_Death]['place'];
			}

			echo "<tr>";
			echo $style_1.decode_lng_text('GEDTAG_DEAT').$plus."</td>";
			//echo "<td style='width: 25%; background-color: rgb(204, 255, 255);'>".decode_date($event[$sId_Event_Type_Death]['date']).load_age ($year1, $year2)."</td>";
			echo $style_2.decode_date_evnt($event[$sId_Event_Type_Death]).$event[$sId_Event_Type_Death]['age']."</td>";
			echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
			echo "</tr>";
		}
		// Display Burial
		if (isset($event[$sId_Event_Type_Burial]['id_event']))
		{
			$note =$event[$sId_Event_Type_Burial]['note'];
			$plus = balloon('$sId_Event_Type_Burial', $note);
			$country = $event[$sId_Event_Type_Burial]['id_country'];
			$zone = $event[$sId_Event_Type_Burial]['id_zone'];
			$city = $event[$sId_Event_Type_Burial]['id_city'];
			if(isset($event[$sId_Event_Type_Burial]['place']))
			{
				$lieu_event = $event[$sId_Event_Type_Burial]['place'];
			}

			echo "<tr>";
			echo $style_1.decode_lng_text('GEDTAG_BURI').$plus."</td>";
			echo $style_2.decode_date_evnt($event[$sId_Event_Type_Burial])."</td>";
			echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
			echo "</tr>";
		}
		// End of table
		echo "</tbody>";
		echo "</table>";
		echo "<br>";
		
		// Display parent table
		echo "<table style='text-align: left; width: 100%;' border='0'";
		echo "cellpadding='2' cellspacing='1' BGCOLOR='black'>";
		echo "<tbody>";
		echo "<tr>";
		echo $style_1.decode_lng_text('DETAIL_IND_FATHER')."</td>";
		echo $style_4.$commun['father']."</td>";
		echo "</tr>";
		echo "<tr>";
		echo $style_1.decode_lng_text('DETAIL_IND_MOTHER')."</td>";
		echo $style_4.$commun['mother']."</td>";
		echo "</tr>";
		echo "</tbody>";
		echo "</table>";
		echo "<br>";
		
		/*
		* Display union table	
		*/
		/*
		* affichage des informations relatives à chaque union 
		*/
		
		$array_conjoints_mar=$_SESSION['t_conjoints_mar'];

		foreach($array_conjoints_mar as $event_union) {
			$event2=$event_union['event2'];
			$enfants_union=$event_union['enfants'];
	// var_dump($array_conjoints_mar);
	// var_dump($enfants_union);
		$sLibelleType=decode_lng_text("GEDTAG_UNION");
		echo "<table style='text-align: left; width: 100%;' border='0'";
		echo "cellpadding='2' cellspacing='1' bgcolor='black'>";;
		echo "<tbody>";
		echo "<tr>";
		echo $style_1.$sLibelleType."</td>";
		
		echo $style_4.$event_union['compagne']."</td>";
		echo "</tr>";
		if( $event_union['id_conjoint'] !=-1)
		{
			//Affichage publication des bans
			if (isset($event2[$sId_Event_Type_Marb]['id_event'])==true)
				
			{
				$note=$event[$sId_Event_Type_Marb]['note'];
				$plus = balloon('$sId_Event_Type_Marb', $note);
				$country = $event2[$sId_Event_Type_Marb]['id_country'];
				$zone = $event2[$sId_Event_Type_Marb]['id_zone'];
				$city = $event2[$sId_Event_Type_Marb]['id_city'];
				if(isset($event2[$sId_Event_Type_Marb]['place']))
				{
					$lieu_event = $event2[$sId_Event_Type_Marb]['place'];
				}
		
				$sLibelleType=decode_lng_text("GEDTAG_".$event2[$sId_Event_Type_Marb]['code']);
				echo "<tr>";
				echo $style_1.decode_lng_text('GEDTAG_MARB').$plus."</td>";
				echo $style_2.$event2[$sId_Event_Type_Marb]['date']."</td>";
				echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
				echo "</tr>";
			}
			//Affichage du contrat de mariage
			if (isset($event2[$sId_Event_Type_Marc]['id_event'])==true)
				
			{
				$note=$event[$sId_Event_Type_Marc]['note'];
				$plus = balloon('$sId_Event_Type_Marc', $note);
				$country = $event2[$sId_Event_Type_Marc]['id_country'];
				$zone = $event2[$sId_Event_Type_Marc]['id_zone'];
				$city = $event2[$sId_Event_Type_Marc]['id_city'];

				if(isset($event2[$sId_Event_Type_Marc]['place']))
				{
					$lieu_event = $event2[$sId_Event_Type_Marc]['place'];
				}
				$sLibelleType=decode_lng_text("GEDTAG_".$event2[$sId_Event_Type_Marc]['code']);
				echo "<tr>";
				echo $style_1.decode_lng_text('GEDTAG_MARC').$plus."</td>";
				echo $style_2.$event2[$sId_Event_Type_Marc]['date']."</td>";
				echo $style_3."<a href='".Router::url('/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
				echo "</tr>";
			}
			//Affichage mariage
			if (isset($event2[$sId_Event_Type_Mar]['id_event'])==true)
			{
				$note=$event[$sId_Event_Type_Mar]['note'];
				$plus = balloon('$sId_Event_Type_Mar', $note);
				$country = $event2[$sId_Event_Type_Mar]['id_country'];
				$zone = $event2[$sId_Event_Type_Mar]['id_zone'];
				$city = $event2[$sId_Event_Type_Mar]['id_city'];
				if(isset($event2[$sId_Event_Type_Mar]['place']))
				{
					$lieu_event = $event2[$sId_Event_Type_Mar]['place'];
				}
				$sLibelleType=decode_lng_text("GEDTAG_".$event2[$sId_Event_Type_Mar]['code']);
				echo "<tr>";
				echo $style_1.decode_lng_text('GEDTAG_MARR').$plus."</td>";
				echo $style_2.$event2[$sId_Event_Type_Mar]['date'].$event2[$sId_Event_Type_Mar]['age']."</td>";
				echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
				echo "</tr>";
			}
			//Affichage divorce
			if (isset($event2[$sId_Event_Type_Div]['id_event'])==true)
			{
				$note=$event[$sId_Event_Type_Div]['note'];
				$plus = balloon('$sId_Event_Type_Div', $note);
				$country = $event2[$sId_Event_Type_Div]['id_country'];
				$zone = $event2[$sId_Event_Type_Div]['id_zone'];
				$city = $event2[$sId_Event_Type_Div]['id_city'];
				if(isset($event2[$sId_Event_Type_Div]['place']))
				{
					$lieu_event = $event2[$sId_Event_Type_Div]['place'];
				}
				$sLibelleType=decode_lng_text("GEDTAG_".$event2[$sId_Event_Type_Div]['code']);
				echo "<tr>";
				echo $style_1.decode_lng_text('GEDTAG_DIV').$plus."</td>";
				echo $style_2.$event2[$sId_Event_Type_Div]['date'].$event2[$sId_Event_Type_Div]['age']."</td>";
				echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
				echo "</tr>";
			}
		
			} //fin du détail des unions	
		//Affichage du ou des enfants de cette union

			echo $style_1.decode_lng_text('DETAIL_IND_CHILD')."</td>";
			echo $style_4;
			if ($enfants_union) {
				foreach($enfants_union as $detail_enfant) {
					$flag="";
					if ($detail_enfant['sex']==1) { $flag=IMAGES.'female.png'; }
					if ($detail_enfant['sex']==0) { $flag=IMAGES.'male.png'; }

					if($flag!="") {
						echo "  <img src=".$flag." width=12 height=12> ";
					}
					
					echo $detail_enfant['nom_enfant']."<br>";
				}
			}

		echo "</td>";
		echo "</tr>";
		echo "</tbody>";
		echo "</table>";
		echo "<br>";
		}

			// Affichage des autres évènements de la personne
			
		$event_divers=$_SESSION['t_event_divers'];

		echo "<table style='text-align: left; width: 100%;' border='0'";
		echo "cellpadding='2' cellspacing='1' bgcolor='black'>";
		echo "<tbody>";
		foreach($event_divers as $row_evt) {

			$plus = balloon($row_evt['id_event'], $row_evt['note']);


			if($row_evt['code'] !="") {

				$sLibelleType=decode_lng_text("GEDTAG_".$row_evt['code']);
			}
			else {

				$sLibelleType=$row_evt['libelle'];
			}
			echo "<tr>";
			echo $style_1.$sLibelleType.$plus."</td>";
			$country = $row_evt['country'];
			$zone = $row_evt['zone'];
			$city = $row_evt['city'];
			$date = $row_evt['date'];

			if($country=="-1" && $zone=="-1" && $city=="-1" && $date==":")
			{
				if($row_evt['code']=="TYPE")
				{
					echo decode_lng_text("GEDTAG_".$row_evt['libelle']);
				}
				else {
					echo $style_4.$row_evt['libelle'];
				}	
			

				echo "</td>";
			}
			else
			{
				echo $style_2.$row_evt['date'].$row_evt['age']."</td>";
				$lieu_event='';
				$country = $row_evt['country'];
				$zone = $row_evt['zone'];
				$city = $row_evt['city'];
				$date = $row_evt['date'];
				if(isset($row_evt['place'])) {
					$lieu_event = $row_evt['place'];
				}
				echo $style_3."<a href='".Router::url('lieux/detail_ind_zone/'.$country."/".$zone."/".$city)."'>".$lieu_event."</a></td>";
		
			}
			
			echo "</tr>";
		}
		
		// echo "</tr>";
		// echo "</tbody>";
		// echo "</table>";
		// echo "<br>";
		
		if ($_SESSION['notes']) {
			echo "<table style='text-align: left; width: 100%;' border='0'";
			echo "cellpadding='2' cellspacing='1' bgcolor='black'>";
			echo "<tbody>";
			echo "<tr>";
			echo $style_1."Notes"."</td>";
			echo $style_4.$_SESSION['notes']."</td>";
			echo "</tr>";
			echo "</tbody>";
			echo "</table>";
			echo "<BR>";
		}
			
		echo "</td>";
		echo "</tr>";
		echo "</tbody>";
		echo "</table></center>";
		echo "<br/> <br/>";

		// echo "</table></center>";
		// echo "<br /> <br />";	
	// echo "</div>";
}
else
{
//echo "Vous n'avez pas accès à ces informations.";
echo "<br>";
echo display_lng_text("PRIVATE_ERROR");
echo "<br>";
}


function balloon($code, $text)
{
	if ($text)
	{
		echo "<div id='balloon".$code."' class='balloonstyle' style='width: 550px; background-color: lightyellow'>";
		echo $text;
		echo "</div>";
		$plus = " <a rel='balloon".$code."'>(".decode_lng_text('EVNT_MORE')."...)</a>";
	}
	else
	{
		$plus = "";	
	}
	return $plus;
}


// <link rel="stylesheet" type="text/css" href="balloontip.css" />
// <script type="text/javascript" src="balloontip.js">
// /***********************************************
// * Rich HTML Balloon Tooltip- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
// * This notice MUST stay intact for legal use
// * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
// ***********************************************/
// </script>
?>