
function match_year(myid, year, tol1, tol2)
{

  if(myid == '') return 0;

  if(typeof(db_person[myid]) == "undefined") return 0;

  var person = db_person[myid];

  var birth = 1000;

       if(person[1][0][0].year > 0) birth = person[1][0][0].year;
  else if(person[1][1][0].year > 0) birth = person[1][1][0].year;

  birth -= tol1;

  if( year < birth ) return 0;

  var death = 3000;

       if(person[2][0][0].year > 0) death = person[2][0][0].year;
  else if(person[2][1][0].year > 0) death = person[2][1][0].year;

  death += tol2;

  if( year > death ) return 0;

  return 1;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function get_mug(myid)
{
  if(myid == '') return 'names/icon.png';

  if(typeof(db_person[myid]) == "undefined") return 'names/icon.png';

  var i = db_person[myid][4][0];

       if(i == 0) return('names/' + db_person[myid][0][2] + '.gif');
  else if(i == 1) return('data/' + myid + '/icon.png');
  else            return('names/icon.png');
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Display a date.

function nice_date(myid)
{
  if(myid == '') return '-';

  if(typeof(db_person[myid]) == "undefined") return '-';

  var person = db_person[myid];

  var birth = '';
  var death = '';

       if(person[1][0][0].year > 0) birth = person[1][0][0].year;
  else if(person[1][1][0].year > 0) birth = person[1][1][0].year;

       if(person[2][0][0].year > 0) death = person[2][0][0].year;
  else if(person[2][1][0].year > 0) death = person[2][1][0].year;

  return(birth + '-' + death);
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Returns a string 098765 to signify if in a census.

function in_cen(myid, start, end)
{
  var html = '';

  html += '<img class="noborder" width="6" height="7" src="../images/' + ((census_set_1841.has(myid)) ? '4' : 'void') + '.gif">';
  html += '<img class="noborder" width="6" height="7" src="../images/' + ((census_set_1851.has(myid)) ? '5' : 'void') + '.gif">';
  html += '<img class="noborder" width="6" height="7" src="../images/' + ((census_set_1861.has(myid)) ? '6' : 'void') + '.gif">';
  html += '<img class="noborder" width="6" height="7" src="../images/' + ((census_set_1871.has(myid)) ? '7' : 'void') + '.gif">';
  html += '<img class="noborder" width="6" height="7" src="../images/' + ((census_set_1881.has(myid)) ? '8' : 'void') + '.gif">';
  html += '<img class="noborder" width="6" height="7" src="../images/' + ((census_set_1891.has(myid)) ? '9' : 'void') + '.gif">';
  html += '<img class="noborder" width="6" height="7" src="../images/' + ((census_set_1901.has(myid)) ? '0' : 'void') + '.gif">';

  return html;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Returns a string BMD to signify if in a BMD cert. If not in a cert, then '-' is used.

function in_bmd(myid)
{
  return '';

/*
  var i; var j; var k; var r; var c; var x;
  r = "";
  for(c=i=0; i<   certbirth.length; i++) { if(myid ==    certbirth[i][0][0]                                 ) { c=1; break; } } if(c==1) r += 'b'; else r += 'x';
  for(c=i=0; i<certmarriage.length; i++) { if(myid == certmarriage[i][4][2] || myid == certmarriage[i][5][2]) { c=1; break; } } if(c==1) r += 'm'; else r += 'x';
  r += 'x' // alter when deth certs are done
  x = '<img class="noborder" src="../images/cert_' + r + '.gif">';
  return x;
*/
}

