///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Generate sequence of names from given persion upwards through the father until can go no further.

function paste_chain(myid)
{
  if(myid == '') return '';
  
  if(typeof(db_person[myid]) == "undefined") return '';

  var html = '';

  html += '<table border="0" cellspacing="1" cellpadding="0" width="748" class="bor1"><tr><td bgcolor="#FFFFFF">';
  html += '<table border="0" cellspacing="3" cellpadding="0"><tr valign="top">';
  html += paste_chain_rec(myid);
  html += '</tr></table>';
  html += '</td></tr></table>';
  
  return html;
}

function paste_chain_rec(myid)
{
  if(myid == '') return '';

  if(typeof(db_person[myid]) == "undefined") return '';
  
  var person = db_person[myid];
  
  var txt = '';

  txt += '<a href="#" onclick=\'paste_update("'+ myid +'");\' title="">';
  txt += '<img class="border1" border="0" width="40" height="52" alt="" src="' + get_mug(myid) + '"><br>';
  txt += person[0][1] + '<br><b>' + person[0][2] + '</b>';
  txt += '</a>'

  var m = '';
  
  // if dad is not defined, see if mum has the same surname.
  // this wont catch all strange behaviours, but should be all right.

  if(person[0][3] == '') // dad
  {
    if(person[0][4] != '') // mum
    {
      var mum = db_person[person[0][4]];
    
      if(person[0][2] == mum[0][2])
      {
        m = paste_chain_rec(person[0][4]);
      }
    }
  }
  else
  {
    m = paste_chain_rec(person[0][3]);
  }

  return(m + '<td width="42" class="censuschain" align="center">' + txt + '</td>');
}

