function paste_branch(myid, pix)
{
  if(myid == '') return '';
   
  if(typeof(db_person[myid]) == "undefined") return '';
  
  var i;
  var j;
  var html = '';
  
  var person = db_person[myid];
  
  var dad_id = person[0][3];
  var mum_id = person[0][4];
  
  var dad_ok = (dad_id != '') && (typeof(db_person[dad_id]) != "undefined");
  var mum_ok = (mum_id != '') && (typeof(db_person[mum_id]) != "undefined");
  
  var dad_db; if(dad_ok) dad_db = db_person[dad_id];
  var mum_db; if(mum_ok) mum_db = db_person[mum_id];
  
  var dad_click = ''; if(dad_ok) dad_click = 'onclick=\'paste_update("' + dad_id + '");\'';
  var mum_click = ''; if(mum_ok) mum_click = 'onclick=\'paste_update("' + mum_id + '");\'';

  var child_tot = (person[3]).length;
  
  var dad_fn = ''; if(dad_ok) dad_fn = dad_db[0][1];
  var dad_sn = ''; if(dad_ok) dad_sn = dad_db[0][2];
  var mum_fn = ''; if(mum_ok) mum_fn = mum_db[0][1];
  var mum_sn = ''; if(mum_ok) mum_sn = mum_db[0][2];
  
  html += '<table border="0" cellspacing="0" cellpadding="0" width="368"><tr><td align="center" width="368">';
  html += '<table border="0" cellspacing="0" cellpadding="0"><tr><td valign="top" align="center">';

  html += '<table border="0" cellspacing="0" cellpadding="0" class="dadnab" width="123">';  
  html += '<tr><td width="123" align="center" class="nowrap">';
  html += '<b>DAD</b><br>';
  if(dad_ok) html += '<a href="#" ' + dad_click + '>';
  html += '<img align="absmiddle" width="40" alt="" height="5"  class="noborder" src="../images/clear.gif">';
  html += '<img align="absmiddle" width="40" alt="" height="52" border="1" class="stborder" src="'+get_mug(dad_id)+'">';
  html += '<img align="absmiddle" width="40" alt="" height="5"  class="noborder" src="../images/horM.png"><br>';
  html += nice_date(dad_id)+'<br>'+dad_fn+'<br><b>'+dad_sn+'</b><br><span class="idlab">'+dad_id;
  if(dad_ok) html += '</a>';
  html += '</td></tr>';
  html += '</table>';
  
  html += '</td><td valign="top" align="center">';
  
  html += '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="102">';
  if(person[4][1]>0) html += '<a href="#" onClick="popimage('+person[4][1]+', \'data/'+myid+'\', \''+person[0][1]+' '+person[0][2]+'\', 500, 700);return false">';
  html += '<img class="border1" border="0" width="100" height="130" alt="" src="'+get_mug(myid)+'">'
  if(person[4][1]>0) html += '</a>';
  html += '</td></tr>';
  if(child_tot==1) html += '<tr height="10"><td align="center"><img width="5" height="10" src="../images/vert.png"/></td></tr>';
  if(child_tot>1 && child_tot<=6) html += '<tr height="5"><td align="center"><img width="5" height="5" src="../images/vert.png"/></td></tr>';
  html += '</table>';
  
  html += '</td><td valign="top" align="center">';

  html += '<table border="0" cellspacing="0" cellpadding="0" class="mumnab" width="123">';  
  html += '<tr><td width="123" align="center" class="nowrap">';
  html += '<b>MUM</b><br>';
  if(mum_ok) html += '<a href="#" ' + mum_click + '>';
  html += '<img align="absmiddle" width="40" alt="" height="5"  class="noborder" src="../images/horM.png">';
  html += '<img align="absmiddle" width="40" alt="" height="52" border="1" class="stborder" src="'+get_mug(mum_id)+'">';
  html += '<img align="absmiddle" width="40" alt="" height="5"  class="noborder" src="../images/clear.gif"><br>';
  html += nice_date(mum_id)+'<br>'+mum_fn+'<br><b>'+mum_sn+'</b><br><span class="idlab">'+mum_id;
  if(mum_ok) html += '</a>';
  html += '</td></tr>';
  html += '</table>';

  html += '</td></tr></table>';  
  html += '</td></tr><tr><td align="center" width="368">';

  var pole =0;
  var first=0;
  var last =child_tot-1;
  var boxw =368/(last+1);
  if(child_tot>6                  ) {last=5; pole=3; boxw=(368-5)/(last+1);}
  if(child_tot>=7 && child_tot<=10) {last=3; pole=2; boxw=(368-5)/(last+1);}
  
  html += '<table border="0" cellspacing="0" cellpadding="0"><tr>';
  
  for(i=first;i<=last;i++)
  {
    if(i==pole && i>0) 
    {
      html += '<td valign="top" height="100%" width="9" align=center>';
      html += '<img width="9" height="10" src="../images/boltC.png"/><br>';
      html += '<img width="5" height="100%" src="../images/vert.png"/></td>';
    }
    
    html += '<td valign="top" width='+boxw+'><table border="0" cellspacing="0" cellpadding="0" width="100%">';
    
    if(child_tot>1)
    {
      if(pole) html += '<tr height="10">';
      else     html += '<tr height="5">';
      
      if(i==first)           
      {
        html += '<td width="50%" valign="bottom" align="center"><img width="100%" height="5" src="../images/clear.gif"/></td>';
        html += '<td width=5     valign="bottom" align="center"><img width="5"    height="5" src="../images/boltL.png"/></td>';
        html += '<td width="50%" valign="bottom" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
      }  
      else if(i==last)
      {
        html += '<td width="50%" valign="bottom" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
        html += '<td width=5     valign="bottom" align="center"><img width="5"    height="5" src="../images/boltR.png"/></td>';
        html += '<td width="50%" valign="bottom" align="center"><img width="100%" height="5" src="../images/clear.gif"/></td>';
      }
      else
      {
        html += '<td width="50%" valign="bottom" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
        html += '<td width=5     valign="bottom" align="center"><img width="5"    height="5" src="../images/boltM.png"/></td>';
        html += '<td width="50%" valign="bottom" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
      }
      
      html += '</tr><tr height="5">';
      html += '<td width="50%" align="left"  ><img width="100%" height="5" src="../images/clear.gif"/></td>';
      html += '<td width=5     align="center"><img width="5"    height="5" src="../images/vert.png"/></td>';
      html += '<td width="50%" align="left"  ><img width="100%" height="5" src="../images/clear.gif"/></td>';
      html += '</tr>';
    }
    
    var cha_id = person[3][i];
    var cha_ok = (cha_id != '') && (typeof(db_person[cha_id]) != "undefined");
    var cha_db; if(cha_ok) cha_db = db_person[cha_id];
    var cha_click = ''; if(cha_ok) cha_click = 'onclick=\'paste_update("' + cha_id + '");\'';
    html += '<tr><td width="100%" align="center" class="chanab" colspan="3">';
    if(cha_ok) html += '<a href="#" ' + cha_click + '>';
    html += '<img width="40" height="52" alt="" border="1" class="stborder" src="'+get_mug(cha_id)+'"><br>';
    html += nice_date(cha_id)+'<br>'+cha_db[0][1]+'<br>'; // <b>'+cha_db[0][2]+'</b><br><span class="idlab">'+cha_id;
    if(cha_ok) html += '</a>';
    html += '</td></tr></table></td>';
  }
  
  if(pole>0)
  {
    html += '</tr><tr>';
    for(i=first;i<=last;i++)
    {
      if(i==pole && i>0) 
      html += '<td valign="top" height="5" width="9" align="center"><img width="5" height="5" src="../images/vert.png"/></td>';
      html += '<td></td>';
    }
  }
  html += '</tr></table>';  
  
  html += '</td></tr><tr><td align="center" width="368">';
  
  first=i;
  last =child_tot-1;
  boxw =368/(last-first+1);
  html += '<table border="0" cellspacing="0" cellpadding="0"><tr>';
  for(i=first;i<child_tot;i++)
  {
    html += '<td valign="top" width='+boxw+'><table border="0" cellspacing="0" cellpadding="0" width="100%">';
    html += '<tr height="5">';
    if(i==first)           
    {
      html += '<td height="5" width="50%" align="center"><img width="100%" height="5" src="../images/clear.gif"/></td>';
      html += '<td height="5" width=5     align="center"><img width="5"    height="5" src="../images/boltL.png"/></td>';
      html += '<td height="5" width="50%" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
    }  
    else if(i==last)
    {
      html += '<td height="5" width="50%" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
      html += '<td height="5" width=5     align="center"><img width="5"    height="5" src="../images/boltR.png"/></td>';
      html += '<td height="5" width="50%" align="center"><img width="100%" height="5" src="../images/clear.gif"/></td>';
    }
    else
    {
      html += '<td width="50%" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
      html += '<td width=5     align="center"><img width="5"    height="5" src="../images/boltM.png"/></td>';
      html += '<td width="50%" align="center"><img width="100%" height="5" src="../images/horM.png"/></td>';
    }
    html += '</tr><tr height="5">';
    html += '<td width="50%" align="left"  ><img width="100%" height="5" src="../images/clear.gif"/></td>';
    html += '<td width=5     align="center"><img width="5"    height="5" src="../images/vert.png"/></td>';
    html += '<td width="50%" align="left"  ><img width="100%" height="5" src="../images/clear.gif"/></td>';
    html += '</tr>';
    
    var cha_id = person[3][i];
    var cha_ok = (cha_id != '') && (typeof(db_person[cha_id]) != "undefined");
    var cha_db; if(cha_ok) cha_db = db_person[cha_id];
    var cha_click = ''; if(cha_ok) cha_click = 'onclick=\'paste_update("' + cha_id + '");\'';
    html += '<tr><td width="100%" align="center" class="chanab" colspan="3">';
    if(cha_ok) html += '<a href="#" ' + cha_click + '>';
    html += '<img width="40" height="52" alt="" border="1" class="stborder" src="'+get_mug(cha_id)+'"><br>';
    html += nice_date(cha_id)+'<br>'+cha_db[0][1]+'<br>'; // <b>'+cha_db[0][2]+'</b><br><span class="idlab">'+cha_id;
    if(cha_ok) html += '</a>';
    html += '</td></tr></table></td>';
  }
  html += '</tr></table>';  
  
  
  html += '</td></tr></table>';
  
  return html;
}

