Location: PHPKode > projects > HuMo-gen > report_descendant.php
 <?php
// *********************************************************************************************
// ------------------------------------------------------------------------------------------------
// |   STARFIELDCHART.PHP                                                        |
// |   for use with the $genarray generated in Humogen               |
// |   Original starfield plotting code by Yossi Beck - Feb-March 2010     |
// |   Copyright GPL_GNU licence                                                |
// ------------------------------------------------------------------------------------------------
// meaning of $genarray members:
// "par" = array nr of parent
// "nrc" = nr of children (children with multiple marriages are counted as additional children for plotting's sake
// "gen" = nr of the generation
// "x"   = the x position of top left corner of a person's square
// "y"   = the y position of top left corner of a person's square
// "fst" = the x position of first (lefmost) child
// "lst" = the x position of last (rightmost) child, unless this is a second marriage of this child,
//         in which case the first marriage of the last child is entered into "lst"
// "chn" = the number of the child in the family (additional marriages have subsequent numbers)
// "2nd" = indicates this person is in fact a second or following instance of the previous person with additional marriage
// "htx" = wedding text ("married on 13 mar 1930 to:")
// "huw" = mentioning of additional marriage ("2nd marriage")
// "sex" = sex of the person
// "nam" = name of the person
// "sps" = name of spouse
// "fams"  = humogen family number (F345)
// "gednr" = humogen gedcom number (I143)
// "non" = person with no own family (i.e. only child status)
// *********************************************************************************************


//**********************************************************************************************
//********** 1st Part:  CODE TO GENERATE THE STARFIELD CHART FROM $GENARRAY *******
//**********************************************************************************************
function generate() {
global $genarray, $direction;
$_SESSION['genarray']=$genarray;

global $hsize;  // horizontal length of box
global $vsize;  // vertical height of box
global $chosengen; // number of generations to display (default set in gezin.php)
global $size; // default size (default set in gezin.php)

if($direction==0) { // if vertical

global $vbasesize; // vertical distance in between X value of parent and X value of child
global $vdist; // vertical distance in between boxes of two generations

if($size==50){   // full size box with name and details
	$hsize=150;
	$vsize=75;
	$vdist=80;
}
elseif($size==45) { // smaller box with name + popup
	$hsize=100;
	$vsize=45;
	$vdist=60;
}
else {             // re-sizable box with no name, only popup
	$hsize=$size; 
	$vsize=$size;
	$vdist=$size*2;
}

$vbasesize=$vsize+$vdist;
$inbetween=10;   // horizontal distance between two persons in a family. Between fams is double $inbetween  

$movepar=0;  // flags the need to move parent box. 1 means: call move() function

for($i=0; $i < count($genarray);$i++) {
	if(!isset($genarray[$i])) { break; }

	$distance=0;

	$genarray[$i]["y"]=($genarray[$i]["gen"]*($vbasesize))+40;
	$par=$genarray[$i]["par"];
	if($genarray[$i]["chd"]==1) {
		if($genarray[$i]["gen"]==0) {
			$genarray[$i]["x"]=0;
		}
		else {
			$exponent=$genarray[$par]["nrc"]-1;

			$genarray[$i]["x"] = $genarray[$par]["x"] -  (($exponent*($hsize+$inbetween))/2)      ;

			if($genarray[$i]["gen"]==$genarray[$i-1]["gen"]) {

				if($genarray[$i]["x"] < $genarray[$i-1]["x"]+($hsize+$inbetween*2)) {
					$genarray[$i]["x"]=$genarray[$i-1]["x"]+($hsize+$inbetween*2);
					$movepar=1;
				}
			}
			else {
				if($genarray[$i]["x"]<0) {
					$genarray[$i]["x"]=0;
					$movepar=1;
				}
			}
			$genarray[$par]["fst"]=$genarray[$i]["x"];       // x of first child in fam
		}

	}
	else {
		$genarray[$i]["x"] = $genarray[$i-1]["x"] + ($hsize+$inbetween);
	}

	$z=$i;
	if($genarray[$z]["gen"]!=0 AND $genarray[$z]["chd"]==$genarray[$par]["nrc"]) {

		while($genarray[$z]["2nd"]==1)  {
			$z--;
		}

		$genarray[$par]["lst"]=$genarray[$z]["x"];
		if($movepar==1) {
			$movepar=0;
			move($par);
		}
	}

}	// end for loop

} // end if vertical

else {  // horizontal
global $hbasesize; // horizontal distance in between X value of parent and X value of child
global $hdist; // horizontal distance in between boxes of two generations

if($size==50){   // full size box with name and details
	$hsize=150;
	$vsize=75;
	$hdist=60;
}
elseif($size==45) { // smaller box with name + popup
	$hsize=100;
	$vsize=45;
	$hdist=60;
}
else {             // re-sizable box with no name, only popup
	$hsize=$size; 
	$vsize=$size;
	$hdist=$size*2;
}

$hbasesize=$hsize+$hdist;
$vinbetween=10;   // vertical distance between two persons in a family. Between fams is double $inbetween 

$movepar=0;  // flags the need to move parent box. 1 means: call move() function

for($i=0; $i < count($genarray);$i++) {
	if(!isset($genarray[$i])) { break; }

	$distance=0;
	
	$genarray[$i]["x"]=($genarray[$i]["gen"]*$hbasesize)+1;
	$par=$genarray[$i]["par"];
	if($genarray[$i]["chd"]==1) {
		if($genarray[$i]["gen"]==0) {
			$genarray[$i]["y"]=40;
		}
		else {
			$exponent=$genarray[$par]["nrc"]-1;

			$genarray[$i]["y"] = $genarray[$par]["y"] -  (($exponent*($vsize+$vinbetween))/2)      ;

			if($genarray[$i]["gen"]==$genarray[$i-1]["gen"]) {

				if($genarray[$i]["y"] < $genarray[$i-1]["y"]+($vsize+$vinbetween*2)) {
					$genarray[$i]["y"]=$genarray[$i-1]["y"]+($vsize+$vinbetween*2);
					$movepar=1;
				}
			}
			else {
				if($genarray[$i]["y"]<40) {
					$genarray[$i]["y"]=40;
					$movepar=1;
				}
			}
			$genarray[$par]["fst"]=$genarray[$i]["y"];       // y of first child in fam
		}

	}
	else {
		$genarray[$i]["y"] = $genarray[$i-1]["y"] + ($vsize+$vinbetween);
	}

	$z=$i;
	if($genarray[$z]["gen"]!=0 AND $genarray[$z]["chd"]==$genarray[$par]["nrc"]) {

		while($genarray[$z]["2nd"]==1)  {
			$z--;
		}

		$genarray[$par]["lst"]=$genarray[$z]["y"];
		if($movepar==1) {
			$movepar=0;
			move($par);
		}
	}

}	// end for loop


}  // end if horizontal

}  // end function generate()

// *********************************************************************************************
// **** 2nd Part: RECURSIVE FUNCTION TO MOVE PART OF THE CHART WHEN NEW ITEMS ARE ADDED ********
// *********************************************************************************************
function move($i) {
	global $genarray, $size, $direction;

if($direction==0) { // if vertical
	$par=$genarray[$i]["par"];
	$tempx= $genarray[$i]["x"];
	$genarray[$i]["x"] = ($genarray[$i]["fst"] + $genarray[$i]["lst"])/2;

	if($genarray[$i]["gen"]!=0) {
		$q=$i;
		if($genarray[$q]["chd"] == 1) {
			$genarray[$par]["fst"]=$genarray[$q]["x"];
		}
		if($genarray[$q]["chd"]==$genarray[$par]["nrc"]) {
			while($genarray[$q]["2nd"]==1) {
				$q--;
			}
		$genarray[$par]["lst"]=$genarray[$q]["x"];
		}
	}
	$distance = $genarray[$i]["x"] - $tempx;

	$n=$i+1;
	while($genarray[$n]["gen"] == $genarray[$n-1]["gen"]) {
		if(isset($genarray[$n]["fst"]) AND isset($genarray[$n]["lst"])) {
			$tempx= $genarray[$n]["x"];
			$genarray[$n]["x"] = ($genarray[$n]["fst"] + $genarray[$n]["lst"])/2;
			$distance = $genarray[$n]["x"] - $tempx;
		}
		else {
			$genarray[$n]["x"] += $distance;
		}
		if($genarray[$n]["gen"]!=0) {
			$c=$n;
			$par=$genarray[$c]["par"];
			if($genarray[$c]["chd"] == 1) {
				$genarray[$par]["fst"]=$genarray[$c]["x"];
			}
			if($genarray[$c]["chd"]==$genarray[$par]["nrc"]) {

				while($genarray[$c]["2nd"]==1) {
					// $c++;
					$c--;
				}

				$genarray[$par]["lst"]=$genarray[$c]["x"];
			}
		}
		$n++;
	}
	if($genarray[$i]["gen"]>0) {
		$par=$genarray[$i]["par"];
		move($par);
	}
} // end if vertical

else { // if horizontal
	$par=$genarray[$i]["par"];
	$tempx= $genarray[$i]["y"];
	$genarray[$i]["y"] = ($genarray[$i]["fst"] + $genarray[$i]["lst"])/2;

	if($genarray[$i]["gen"]!=0) {
		$q=$i;
		if($genarray[$q]["chd"] == 1) {
			$genarray[$par]["fst"]=$genarray[$q]["y"];
		}
		if($genarray[$q]["chd"]==$genarray[$par]["nrc"]) {
			while($genarray[$q]["2nd"]==1) {
				$q--;
			}
		$genarray[$par]["lst"]=$genarray[$q]["y"];
		}
	}
	$distance = $genarray[$i]["y"] - $tempx;

	$n=$i+1;
	while($genarray[$n]["gen"] == $genarray[$n-1]["gen"]) {
		if(isset($genarray[$n]["fst"]) AND isset($genarray[$n]["lst"])) {
			$tempx= $genarray[$n]["y"];
			$genarray[$n]["y"] = ($genarray[$n]["fst"] + $genarray[$n]["lst"])/2;
			$distance = $genarray[$n]["y"] - $tempx;
		}
		else {
			$genarray[$n]["y"] += $distance;
		}
		if($genarray[$n]["gen"]!=0) {
			$c=$n;
			$par=$genarray[$c]["par"];
			if($genarray[$c]["chd"] == 1) {
				$genarray[$par]["fst"]=$genarray[$c]["y"];
			}
			if($genarray[$c]["chd"]==$genarray[$par]["nrc"]) {

				while($genarray[$c]["2nd"]==1) {
					$c--;
				}

				$genarray[$par]["lst"]=$genarray[$c]["y"];
			}
		}
		$n++;
	}
	if($genarray[$i]["gen"]>0) {
		$par=$genarray[$i]["par"];
		move($par);
	}

}  // end if horizontal
}

//****************************************************************************
//********** 3rd Part:  CODE TO PRINT THE STARFIELD CHART         *****
//****************************************************************************
function printchart() {
global $genarray, $size, $db, $language, $chosengen, $keepgezin_id, $keephoofdpersoon, $uri_pad, $database;
global $vbasesize, $hsize, $vsize, $vdist, $hdist, $user, $direction;
global $dirmark1, $dirmark2, $rtlmarker, $alignmarker;

// YB: -- check browser type & version. we need this further on to detect IE7 with it's widely reported z-index bug
$browser_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';

//following only on screen (after menu box) 
//print '<span class="weergave" style="font-size:large; color:darkgreen; position:absolute; left:600px; top:3px; height:25px">';

echo '<div class="parenteel fonts" style="align:center; text-align: center;"><b>'.$language["main_descendant_report"].$language["main_of"].$genarray[0]["nam"].'</b></div>';

/*
print '<span class="weergave" style="font-size:large; color:darkgreen;">';
print '&nbsp;&nbsp;'.$language["main_descendant_report"].$language["main_of"].$genarray[0]["nam"]."&nbsp;&nbsp;&nbsp;";
print '</span>';
//following only for print (no menu box, name to the left)
//print '<span class="onlyprint" style="font-size:large; color:darkgreen; position:absolute; left:20px; top:3px; height:25px">';
print '<span class="onlyprint" style="font-size:large; color:darkgreen;">';
print '&nbsp;&nbsp;Descendant Chart of '.$genarray[0]["nam"]."&nbsp;&nbsp;&nbsp;"; 
print '</span>';
*/

print '<div class="wrapper" style="position:relative; direction:'.$rtlmarker.';">';

// generation and size choice box:
//print '<div class="weergave" style="direction:ltr; z-index:80; position:absolute; padding:2px; background-color:white; width:570px; height:25px; left:10px; top:1px; border:1px black solid">';
echo '<div class="weergave search_bar" style="direction:ltr; z-index:80; width:600px; text-align:left;">';

	print '<div style="display:inline;">';
	print '<form method="POST" action="'.'gezin.php?chosensize='.$size.'&amp;screen_mode=STARSIZE" style="display : inline;">';
	print '<input type="hidden" name="id" value="'.$keepgezin_id.'">';
	print '<input type="hidden" name="chosengen" value="'.$chosengen.'">';
	print '<input type="hidden" name="hoofdpersoon" value="'.$keephoofdpersoon.'">';
	print '<input type="hidden" name="database" value="'.$database.'">';

	if ($direction=="1"){ // horizontal
		print '<input type="hidden" name="direction" value="0">';
		print '<input type="Submit" name="submit" value="'.$language["graph_desc_vertical"].'">';
	}
	else{
		print '<input type="hidden" name="direction" value="1">';
		print '<input type="Submit" name="submit" value="'.$language["graph_desc_horizontal"].'">';
	}
	print '</form>';
	print '</div>'; 

print '&nbsp;'.$language["graph_desc_generations"].': ';
print '<select name="chosengen" onChange="window.location=this.value">';

for ($i=2; $i<=15; $i++) {
	print '<option value="'.$uri_pad.'gezin.php?id='.$keepgezin_id.'&amp;hoofdpersoon='.
	$keephoofdpersoon.'&amp;direction='.$direction.'&amp;database='.$database.'&amp;chosensize='.
	$size.'&amp;chosengen='.$i.'&amp;screen_mode=STAR" ';
	if ($i == $chosengen) print "selected=\"selected\" ";
	print ">".$i."</option>";
}

print '</select>';

print '&nbsp;&nbsp;';

print $language["graph_desc_zoom"].': ';

print '<input style="display:none;" name="chosensize" id="chosensize" type="Text" value="'.$size.'" size="3">'; 

echo '<script type="text/javascript">';

	print 'var database="'.$database.'";'; 
	print 'var hoofdpersoon="'.$keephoofdpersoon.'";';
	print 'var id="'.$keepgezin_id.'";';
	print 'var chosengen="'.$chosengen.'";';
	print 'var direction="'.$direction.'";';
?>

	var A_TPL = {
		'b_vertical' : false,
		'b_watch': true,
		'n_controlWidth': 150,
		'n_controlHeight': 17,
		'n_sliderWidth': 17,
		'n_sliderHeight': 16,
		'n_pathLeft' : 1,
		'n_pathTop' : 1,
		'n_pathLength' : 135,
		's_imgControl': 'sliderbar/img/sldr150h_bg.gif',
		's_imgSlider': 'sliderbar/img/sldr3h_sl.gif',
		'n_zIndex': 1
	}
	var A_INIT = {
		's_name': 'chosensize',
		'n_minValue' : 10,
		'n_maxValue' : 50,
		'n_step' : 5
	}

	new slider(A_INIT, A_TPL,database,hoofdpersoon,id,chosengen,direction);

</script>
<?php

//======== HELP POPUP ========================
echo '<div class="'.$rtlmarker.'sddm" style="position:absolute;left:500px;top:3px;display:inline;">';
	echo '<a href="#"';
	echo ' style="display:inline" ';
	//echo 'onmouseover="mopen(event,\'hulpmenu\')"';
	echo 'onmouseover="mopen(event,\'hulpmenu\',0,0)"';
	echo 'onmouseout="mclosetime()">';
	echo '-- '.$language["main_help"].' --';
	echo '</a>&nbsp;';

	//echo '<div style="z-index:40; padding:4px; direction:'.$rtlmarker.'" id="hulpmenu" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">';
	echo '<div class="sddm_fixed" style="z-index:40; padding:4px; text-align:'.$alignmarker.';  direction:'.$rtlmarker.';" id="hulpmenu" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">';

		echo $language["graph_desc_help1"];

		echo '<p><span style="background-color:cyan; border:1px brown solid;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;'.$language["graph_desc_man"].'<br>';
		echo '<span style="background-color:pink; border:1px brown solid;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;'.$language["graph_desc_woman"].'<br>';

		echo '<span style="color:blue">=====</span>&nbsp;'.$language["graph_desc_help2"].'<br><br>';

		echo $language["graph_desc_help3"];

	echo '</div>';
echo '</div>';

//=================================

echo '</div>';

for($w=0; $w < count($genarray); $w++) {
	$xvalue=$genarray[$w]["x"];
		$yvalue=$genarray[$w]["y"];

	if($genarray[$w]["sex"]=="v") {
		//$bkcolor="pink";
		$bkcolor="#FFCCFF";
	}
	else {
		//$bkcolor="lightblue";
		$bkcolor="#99FFFF";
	}

	// *** Start person class and calculate privacy ***
	if ($genarray[$w]["gednr"]){
		$man_qry = "SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person WHERE pers_gedcomnumber = '".veilig($genarray[$w]["gednr"])."'";
		$man_result = mysql_query($man_qry,$db);
		@$man = mysql_fetch_object($man_result);

		$man_cls= New persoon_cls;
		$man_cls->construct($man);
		$man_levend=$man_cls->privacy;
	}

	if(strpos($browser_user_agent,"msie 7.0")!==false) {  // IE7 needs special treatment for z-index bug...

		print '<div style="font-size:x-small; position:absolute; background-color:'.$bkcolor.';height:'.$vsize.'px; width:'.$hsize.'px; border:1px brown solid;left:'.$xvalue.'px;top:'.$yvalue.'px">';
		print '<a class="nam" href="gezin.php?id='.$genarray[$w]["fams"].'&amp;hoofdpersoon='.$genarray[$w]["gednr"].'&amp;direction='.$direction.'&amp;screen_mode=STAR"  style="z-index:10; text-align:center; display:block; width:100%; height:100%">';
		if($size==50) {
			echo '<strong><span style="position:relative;">'.$genarray[$w]["nam"].'</span></strong>';

			if ($man_levend){
				echo '<br>'.$language["privacy"].'<br>';  //Tekst privacy weergeven
			}
			else{
			if ($man->pers_birth_date OR $man->pers_birth_place){
				echo '<br>'.$language["lng_birth_short"].$dirmark1.' '.
				datumplaats($man->pers_birth_date,$man->pers_birth_place); 
			}

			if ($man->pers_death_date OR $man->pers_death_place){
				echo '<br>'.$language["lng_death_short"].$dirmark1.' '.
				datumplaats($man->pers_death_date,$man->pers_death_place); 
			}
			}
		}
		elseif($size==45) { echo '<span style="position:relative;">'.$genarray[$w]["nam"].'</span>'; }
		elseif($size>=25) {echo '<span style="position:relative;">'.$genarray[$w]["init"].'</span>'; }
		print '</a>';
		print '</div>';
		print '<div style="z-index:60; position:absolute; background-color:none; height:'.$vsize.'px; width:'.$hsize.'px; border:none; left:'.$xvalue.'px; top:'.$yvalue.'px">';
	}
	else {  // all other browser incl. IE8
		print '<div style="position:absolute; background-color:'.$bkcolor.';height:'.$vsize.'px; width:'.$hsize.'px; border:1px brown solid; left:'.$xvalue.'px; top:'.$yvalue.'px">';
	}

	echo '<div class="'.$rtlmarker.'sddm" style="display:inline;">';

	if($size>=25) {
		echo '<a class="nam" href="gezin.php?id='.$genarray[$w]["fams"].'&amp;hoofdpersoon='.$genarray[$w]["gednr"].'&amp;chosensize='.$size.'&amp;direction='.$direction.'&amp;screen_mode=STAR"';
		echo ' style="font-size:9px; text-align:center; display:block; width:100%; height:100%" ';
		//echo 'onmouseover="mopen(event,\'m1'.$w.'\')"';
		echo 'onmouseover="mopen(event,\'m1'.$w.'\',0,0)"';
		echo 'onmouseout="mclosetime()">';
		if(strpos($browser_user_agent,"msie 7.0")===false) {
			if($size==50) {
				echo '<strong>'.$genarray[$w]["nam"].'</strong>'; 
				if ($man_levend){
					echo '<br>'.$language["privacy"].'<br>';  //Tekst privacy weergeven
				}
				else{
					if ($man->pers_birth_date OR $man->pers_birth_place){
						echo '<br>'.$language["lng_birth_short"].$dirmark1.' '.
						datumplaats($man->pers_birth_date,$man->pers_birth_place); 
					}
					if ($man->pers_death_date OR $man->pers_death_place){
						echo '<br>'.$language["lng_death_short"].$dirmark1.' '.
						datumplaats($man->pers_death_date,$man->pers_death_place); 
					}
				}
			}
			elseif($size==45) {echo $genarray[$w]["nam"]; }
			elseif($size>=25 AND $size<45) {echo $genarray[$w]["init"]; }
		}
	}
	else {
		if(isset($genarray[$w]["fams"]) AND isset($genarray[$w]["gednr"])) {
			echo '<a href="gezin.php?id='.$genarray[$w]["fams"].'&amp;hoofdpersoon='.$genarray[$w]["gednr"].'&amp;chosensize='.$size.'&amp;direction='.$direction.'&amp;screen_mode=STAR"';
			echo ' style="display:block; width:100%; height:100%" ';
			//echo 'onmouseover="mopen(event,\'m1'.$w.'\')"';
			echo ' onmouseover="mopen(event,\'m1'.$w.'\',0,0)"';
			echo 'onmouseout="mclosetime()">';
			if(strpos($browser_user_agent,"chrome")!==false OR strpos($browser_user_agent,"safari")!==false  ) { echo "&nbsp;"; }
			//  (Chrome and Safari need some character here - even &nbsp - or else popup won't work..!
		}
	}
	print '</a>';


	// *** POP-UP box ***
	echo '<div class="sddm_fixed" style="z-index:40;" id="m1'.$w.'" onmouseover="mcancelclosetime()" onmouseout="mclosetime()">';

	if($genarray[$w]["2nd"]==1) { echo $genarray[$w]["huw"]."<br>"; }

	// *** Show pictures ***
	if (!$man_levend AND $user["afbeeldingen"]=='j'){  
		$picture='';
		global $dataDb;
		$PAD=$dataDb->tree_pict_path;
		$afbqry=mysql_query("SELECT * FROM ".veilig($_SESSION['tree_prefix'])."events
			WHERE event_person_id='".$genarray[$w]["gednr"]."' AND event_kind='afbeelding'
			ORDER BY event_order",$db);
		$afb_nr=mysql_num_rows($afbqry);
		if ($afb_nr > 0){
			$afbDb=mysql_fetch_object($afbqry);
			if(file_exists($PAD.'thumb_'.$afbDb->event_event)) {
				$picture='<img src="'.$PAD.'thumb_'.$afbDb->event_event.'" style="margin-left: 50px; margin-top: 5px;" alt="'.$afbDb->event_text.'">';
			}
		}
		if($picture) { echo $picture; }
	}

	echo '<a href="gezin.php?id='.$genarray[$w]["fams"].'&amp;hoofdpersoon='.$genarray[$w]["gednr"].'">'.'<strong>'.$man_cls->naam($man).'</strong></a>';

	if ($man_levend){
		echo $language["privacy"].'<br>';  //Tekst privacy weergeven
	}
	else{
		if ($man->pers_birth_date OR $man->pers_birth_place){
			echo $language["pers_born"].$dirmark1.' '.
			datumplaats($man->pers_birth_date,$man->pers_birth_place).'<br>'; }

		if ($man->pers_death_date OR $man->pers_death_place){
			echo $language["pers_died"].$dirmark1.' '.
			datumplaats($man->pers_death_date,$man->pers_death_place).'<br>'; }
	}

	if($genarray[$w]["non"]!=1) {
		// *** Start person class and calculate privacy ***
		if (isset($genarray[$w]["spgednr"]) AND $genarray[$w]["spgednr"]){
			$woman_qry = "SELECT * FROM ".veilig($_SESSION['tree_prefix'])."person
				WHERE pers_gedcomnumber = '".veilig($genarray[$w]["spgednr"])."'";
			$woman_result = mysql_query($woman_qry,$db);
			@$woman = mysql_fetch_object($woman_result);

			$woman_cls= New persoon_cls;
			$woman_cls->construct($woman);
			$woman_levend=$woman_cls->privacy;
		}

		// *** Marriage data ***
		echo $genarray[$w]["htx"]."<br>";

		if(isset($genarray[$w]["spfams"]) AND isset($genarray[$w]["spgednr"])
			AND isset($genarray[$w]["sps"])) {
			echo '<a href="gezin.php?id='.$genarray[$w]["spfams"].'&amp;hoofdpersoon='.$genarray[$w]["spgednr"].'">'.'<strong>'.$woman_cls->naam($woman).'</strong></a>';
		}
		else {
			echo $woman_cls->naam($woman);
		}

		if ($woman_levend){
			echo $language["privacy"].'<br>';  //Tekst privacy weergeven
		}
		else{
			if ($woman->pers_birth_date OR $woman->pers_birth_place){
				echo $language["pers_born"].$dirmark1.' '.
				datumplaats($woman->pers_birth_date,$woman->pers_birth_place).'<br>'; }

			if ($woman->pers_death_date OR $woman->pers_death_place){
				echo $language["pers_died"].$dirmark1.' '.
				datumplaats($woman->pers_death_date,$woman->pers_death_place).'<br>'; }
			}
	}
	echo '</div>';
	// *** END OF POP-UP BOX ***


	echo '</div>';  // div of class sddm
	print '</div>';  // div of square

if($direction==0) { // if vertical

// draw dotted line from first marriage to following marriages
if(isset($genarray[$w]["2nd"]) AND $genarray[$w]["2nd"]==1) {
	$startx=$genarray[$w-1]["x"]+$hsize+2;	 
		$starty=$genarray[$w-1]["y"]+($vsize/2);
	$width=($genarray[$w]["x"]) - ($genarray[$w-1]["x"]+$hsize)-2;
	print  '<div style="position:absolute;border:1px blue dashed;height:2px;width:'.$width.'px;left:'.$startx.'px;top:'.$starty.'px"></div>';
}

// draw line to children
if($genarray[$w]["nrc"]!=0) {
	$startx=$genarray[$w]["x"]+($hsize/2);	
		$starty=$genarray[$w]["y"]+$vsize+2;
	print  '<div class="chart_line" style="position:absolute; height:'.(($vdist/2)-2).'px; width:1px; left:'.$startx.'px; top:'.$starty.'px"></div>';
}

// draw line to parent
	if($genarray[$w]["gen"]!=0 AND $genarray[$w]["2nd"]!=1) {
		$startx=$genarray[$w]["x"]+($hsize/2);		
					$starty=$genarray[$w]["y"]-($vdist/2);
		print '<div class="chart_line" style="position:absolute; height:'.($vdist/2).'px;width:1px;left:'.$startx.'px;top:'.$starty.'px"></div>';
	}

// draw horizontal line from 1st child in fam to last child in fam
	if($genarray[$w]["gen"] != 0) {
		$parent=$genarray[$w]["par"];
		if($genarray[$w]["chd"] == $genarray[$parent]["nrc"]) { // last child in fam
			$z=$w;
			while($genarray[$z]["2nd"]==1) { //if last is 2nd (3rd etc) marriage, the line has to stop at first marriage
			$z--;
			}
			$startx=$genarray[$parent]["fst"]+($hsize/2);
			$starty=$genarray[$z]["y"]-($vdist/2);
			$width=$genarray[$z]["x"] - $genarray[$parent]["fst"];
			print '<div class="chart_line" style="position:absolute; height:1px; width:'.$width.'px; left:'.$startx.'px; top:'.$starty.'px"></div>';
		}
	}
} // end if vertical

else { // if horizontal
// draw dotted line from first marriage to following marriages
if(isset($genarray[$w]["2nd"]) AND $genarray[$w]["2nd"]==1) {
	$starty=$genarray[$w-1]["y"]+$vsize+2;
	$startx=$genarray[$w-1]["x"]+($hsize/2);
	$height=($genarray[$w]["y"]) - ($genarray[$w-1]["y"]+$vsize)-2;
	print  '<div style="position:absolute;border:1px blue dashed;height:'.$height.'px; width:3px; left:'.$startx.'px;top:'.$starty.'px"></div>';
}

// draw line to children
if($genarray[$w]["nrc"]!=0) {
	$starty=$genarray[$w]["y"]+($vsize/2);
	$startx=$genarray[$w]["x"]+$hsize+2;
	print '<div class="chart_line" style="position:absolute; height:1px; width:'.(($hdist/2)-2).'px; left:'.$startx.'px; top:'.$starty.'px"></div>';
}

// draw line to parent
	if($genarray[$w]["gen"]!=0 AND $genarray[$w]["2nd"]!=1) {
		$starty=$genarray[$w]["y"]+($vsize/2);
		$startx=$genarray[$w]["x"]-($hdist/2);
		print '<div class="chart_line" style="position:absolute; width:'.($hdist/2).'px; height:1px; left:'.$startx.'px; top:'.$starty.'px"></div>';
	}

// draw vertical line from 1st child in fam to last child in fam
	if($genarray[$w]["gen"] != 0) {
		$parent=$genarray[$w]["par"];
		if($genarray[$w]["chd"] == $genarray[$parent]["nrc"]) { // last child in fam
			$z=$w;
			while($genarray[$z]["2nd"]==1) { //if last is 2nd (3rd etc) marriage, the line has to stop at first marriage
			$z--;
			}
			$starty=$genarray[$parent]["fst"]+($vsize/2);
			$startx=$genarray[$z]["x"]-($hdist/2);
			$height=$genarray[$z]["y"] - $genarray[$parent]["fst"];
			print '<div class="chart_line" style="position:absolute; width:1px; height:'.$height.'px; left:'.$startx.'px; top:'.$starty.'px"></div>';
		}
	}

} // end if horizontal
}
print "<br><br></div>";
// here place div at bottom so there is some space under last boxes
$last=count($genarray)-1;
$putit=$genarray[$last]["y"]+130;
print '<div style="position:absolute;left:1px;top:'.$putit.'px;">&nbsp; </div>';

}
?>
Return current item: HuMo-gen