//  This function returns the last update of the file, based on
//  the lastModified property of the document.

//  The format of lastModified is dependent on the browser type:
//  Firefox, Mozilla == "Wed 18 Jan 2006 16:14:03 GMT"
//  IE 6+ == "01/18/2006 11:14:03"

function lastUpdate(extra)
{
        var x = new Date (document.lastModified);
        Modif = new Date(x.toGMTString());
        Year = takeYear(Modif);
        Month = Modif.getMonth();
        Day = Modif.getDate();
        Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
        x = new Date();
        today = new Date(x.toGMTString());
        Year2 = takeYear(today);
        Month2 = today.getMonth();
        Day2 = today.getDate();
        now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
        daysago = now - Mod;
        if (daysago < 0) return '';
        unit = 'days';
        if (daysago > 730)
        {
                daysago = Math.round(daysago/365);
                unit = 'years';
        }
        else if (daysago > 60)
        {
                daysago = Math.round(daysago/30);
                unit = 'months';
        }
        else if (daysago > 14)
        {
                daysago = Math.round(daysago/7);
                unit = 'weeks'
        }
        towrite = '<i>Updated: ';
        Month += 1;

        var mmm =
          ( 1==Month)?'Jan':( 2==Month)?'Feb':(3==Month)?'Mar':
          ( 4==Month)?'Apr':( 5==Month)?'May':(6==Month)?'Jun':
          ( 7==Month)?'Jul':( 8==Month)?'Aug':(9==Month)?'Sep':
          (10==Month)?'Oct':(11==Month)?'Nov':'Dec';

        towrite += (Day<10?"0"+Day:Day) + " " + mmm + " " + Year + "</i>";

        if (extra == "nice") {
          if (daysago == 0)
          {
            towrite += '(today)';
          }
          else if (daysago == 1)
          {
            towrite += '(yesterday)';
          }
          else
          {
            towrite += '(' + daysago + ' ' + unit + ' ago)';
          }
        }
        return towrite;
}


function takeYear(theDate)
{
        x = theDate.getYear();
        var y = x % 100;
        y += (y < 38) ? 2000 : 1900;
        return y;
}

document.write(lastUpdate());
