// ----------------
// script source: http://www.jsr.communitech.net/saved.htm
// ----------------
function initArray() {
	this.length = initArray.arguments.length
	for (var i = 0; i < this.length; i++)
	this[i+1] = initArray.arguments[i]
}

function dateupdate(id) {
	var MonthOfYearArray = new initArray("January","February","March","April",
	                                     "May","June","July","August",
	                                     "September","October","November","December");

	var LastModifiedDate = new Date(document.lastModified);
	
	d = MonthOfYearArray[(LastModifiedDate.getMonth()+1)]+" ";
	d += LastModifiedDate.getDate()+" ";
	d += (LastModifiedDate.getYear()+1900);
	
	d = document.createTextNode(d);
	document.getElementById(id).appendChild(d);
}


// ----------------
// script source: http://www.quirksmode.org/js/lastmod.html
// ----------------
function lastMod()
{
	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 = 'Page last changed ';
	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;
}

