// ood.js: display how out of date the page is

var diffStr = '';

function pageAge()
{
  var now = new Date();
  var lastMod = document.lastModified;
  var diff = Date.parse(now) - Date.parse(lastMod);
  var mil = diff % 1000;
  diff = (diff - mil) / 1000;
  var secs = diff % 60;
  diff = (diff - secs) / 60;
  var mins = diff % 60;
  diff = (diff - mins) / 60;
  var hrs = diff % 24;
  diff = (diff - hrs) / 24;
  if (diff == 0) {
    document.writeln("This page has been updated within the past day.");
    return;
  }
  var days = diff % 30;	  // close enough for this purpose
  diff = (diff - days) / 30;
  var months = diff % 12;
  diff = (diff - months) / 12;
  var yrs = diff;
  if (yrs > 30) {   // lastModified not supported by server
    return;
  }
  appendUnit('year', yrs);
  appendUnit('month', months);
  appendUnit('day', days);
  document.writeln("Page last updated on " + lastMod);
  document.writeln("<BR>It's " + diffStr + " out of date.");
}

function appendUnit(uName, value)
{
  if (value == 0) {
    return;
  }
  if (diffStr != '') {
    diffStr += ', ';
  }
  diffStr += value + ' ' + uName;
  if (value > 1) {
    diffStr += 's';
  }
}

function footer()  // show archives and (if appropriate) the page age
{
  var thisPage = window.location.pathname;
  var start = thisPage.lastIndexOf('teddy_');
  if (start == -1)
     thisPage = 'index';
  else {
    var end = thisPage.lastIndexOf('.htm');
    thisPage = thisPage.substr(start, (end-start));
  }
  document.writeln('<hr>');
  document.writeln('<h3>Other pictures:<h3>');
  if (thisPage != 'teddy_040726')
    document.writeln('<a href="teddy_040726.html">Teddy at 3</a><br>');
  if (thisPage != 'teddy_040112')
    document.writeln('<a href="teddy_040112.html">Teddy at 2 1/2</a><br>');
  if (thisPage != 'teddy_030909')
    document.writeln('<a href="teddy_030909.html">Teddy at 2 1/3</a><br>');
  if (thisPage != 'teddy_030807')
    document.writeln('<a href="teddy_030807.html">Teddy at 2 1/4</a><br>');
  if (thisPage != 'teddy_030618')
    document.writeln('<a href="teddy_030618.html">Teddy at 2 1/6</a><br>');
  if (thisPage != 'teddy_030507')
    document.writeln('<a href="teddy_030507.html">Teddy at 2 candles old (23-24 months)</a><br>');
  if (thisPage != 'teddy_030306')
    document.writeln('<a href="teddy_030306.html">Teddy at 21 months</a><br>');
  if (thisPage != 'teddy_030114')
    document.writeln('<a href="teddy_030114.html">Teddy at 19-20 months</a><br>');
  if (thisPage != 'teddy_021116')
    document.writeln('<a href="teddy_021116.html">Teddy at 15-18 months</a><br>');
  if (thisPage != 'teddy_020704')
    document.writeln('<a href="teddy_020704.html">Teddy at 10-14 months</a><br>');
  if (thisPage != 'teddy_020220')
    document.writeln('<a href="teddy_020220.html">Teddy at 8-9 months</a><br>');
  if (thisPage != 'teddy_011219')
    document.writeln('<a href="teddy_011219.html">Teddy at 5-7 months</a><br>');
  if (thisPage != 'teddy_010901')
    document.writeln('<a href="teddy_010901.html">Teddy at 3-4 months</a><br>');
  if (thisPage != 'teddy_010801')
    document.writeln('<a href="teddy_010801.html">Teddy at 2-3 months</a><br>');
  if (thisPage != 'teddy_010622')
    document.writeln('<a href="teddy_010622.html">Teddy at 1-2 months</a><br>');
  if (thisPage != 'teddy_010522')
    document.writeln('<a href="teddy_010522.html">Teddy at 1 month</a><br>');
  if (thisPage != 'teddy_010515')
    document.writeln('<a href="teddy_010515.html">Teddy at 1-2 weeks</a><br>');
  if (thisPage != 'teddy_010425')
    document.writeln('<a href="teddy_010425.html">Teddy at 2-4 days</a><br>');
  if (thisPage != 'teddy_010423')
    document.writeln('<a href="teddy_010423.html">Teddy at 2 days</a><br>');
  if (thisPage != 'teddy_010421')
    document.writeln('<a href="teddy_010421.html">Teddy\'s 0th birthday</a><br>');

  if (thisPage != 'index')
    document.writeln('<a href="index.html"><b>Teddy\'s home page<b></a><br>');
  else {
    document.writeln('<hr><h5>');
    pageAge();
    document.writeln('</h5>');
  }
  document.writeln('<hr>Friends and Relations: Teddy\'s Bookmarks<BR>');
  document.writeln('<a href="http://imainelli.home.comcast.net">Mommy\'s page</a>');
  document.writeln('&nbsp;&nbsp;&nbsp;<a href="http://danseidman.home.comcast.net">Daddy\'s page</a>');
  document.writeln('&nbsp;&nbsp;&nbsp;<a href="http://world.std.com/~benleo/">Cousins Ben and Leo\'s page</a>');
  document.writeln('&nbsp;&nbsp;&nbsp;<a href="http://www.imaginillus.com/aaron">Saba\'s page</a>');
  document.writeln('&nbsp;&nbsp;&nbsp;<a href="http://rkseidman.home.comcast.net">Grandma\'s page</a>');
  document.writeln('&nbsp;&nbsp;&nbsp;<a href="http://home.comcast.net/~connorsgram/">Great Aunt Marsha\'s page</a>');
  document.writeln('&nbsp;&nbsp;&nbsp;<a href="http://www.tooke-morton.com/gallery/Daily-Life">Roane\'s page</a>');
  document.writeln('&nbsp;&nbsp;&nbsp;<a href="http://www.angel-adoptions.org/">Angel Adoptions\' page</a>');
}