// Time-stamp: <timediff.js, 2007-05-10 10:21:15 MDT, rhayes>

// For this to work, a refdate must be set in the head of the document
// invoking this script

// First, set a variable with current time
var now = new Date();
// Find out how many milliseconds have elapsed since the refdate and
// the current time and divide by the number of milliseconds in an
// hour and round the number off to nearest integer.
var hourdiff = Math.round((now - refdate)/3600000) ;
// Divide the number of hours obtained in the above procedure by 24 to
// get number of days and round down to an integer.
var days = Math.floor(hourdiff/24);
// Find the number of hours remaining after dividing the total number
// of hours by 24; this shows how many hours have elapsed in addition
// to the number of days.
var hoursleft = (hourdiff % 24);
// Put the number of days into a string
var reportdays = days.toString();
// Put the number of hours into a string
var reporthours = hoursleft.toString();
// Set up a string with the two grammatical numbers for the word
// 'day'.
var days_grammar = "days,day";
// Set up an array by splitting up days_grammar at the comma
var days_array = days_grammar.split(",");
// Do the same with the hours
var hours_grammar = "hours,hour";
var hours_array = hours_grammar.split(",");
// The following function writes the number of days and hours into a
// sentence in which the words 'day' and 'hour' have the correct form
// for the number of days and hours reported.
function writedays() {
  if (days == 1) {document.write("<br />" + reportdays + "&#032;" + days_array[1]);}
  else {document.write("<br />" + reportdays + "&#32;" + days_array[0]);
  }
};
  function writehours() {
    if (hoursleft == 1) {document.write(" and " + reporthours + "&#032;" + hours_array[1]+ " since last modification.");}
    else {document.write(" and " + reporthours + "&#032;" + hours_array[0]+ " since last modification.");}
  };
  writedays(); 
  writehours(); 

