// Write last modification date of html file
// By Peter Andersen <pa@mjolner.com> inspired
// from various scripts at www.javagoodies.com

var month_names = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var day_names   = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var sup_date;
var lastmodnumber = Date.parse(document.lastModified);
var lastmod = new Date(document.lastModified);
var year = lastmod.getYear();
var century;
var hours;
var minutes;
var sup = new Array();

sup[1]        = "1<SUP>st</SUP>";
sup[2]        = "2<SUP>nd</SUP>";
sup[3]        = "3<SUP>rd</SUP>";
sup[21]       = "21<SUP>st</SUP>";
sup[22]       = "22<SUP>nd</SUP>";
sup[23]       = "23<SUP>rd</SUP>";
sup[31]       = "31<SUP>st</SUP>";

//document.write("This page updated on " + lastmod);

if (lastmodnumber == 0) {
    // Cannot parse date header correctly
} else {
  if (isNaN(lastmodnumber)){
    document.writeln("<FONT size=\"-1\">"
		     + "[Modified: " + document.lastModified + "]"
		     + "</FONT>"
		     );
  } else {
    if (lastmod.getMinutes()<10) 
	 minutes = "0" + lastmod.getMinutes();
    else
	 minutes = lastmod.getMinutes();
    
    if (lastmod.getHours()<10) 
	 hours = "0" + lastmod.getHours();
    else
	 hours = lastmod.getHours();
    
    
    if ((lastmod.getDate()==1)  || (lastmod.getDate()==2)  || (lastmod.getDate()==3) ||
	  (lastmod.getDate()==21) || (lastmod.getDate()==22) || (lastmod.getDate()==23) ||
	  (lastmod.getDate()==31)) {
		 sup_date = sup[lastmod.getDate()];
    } else {
		 sup_date = lastmod.getDate()+"<SUP>th</SUP>";
    }
	
    // Y2K hack
    // For dates in 2000:
    //   NetScape reports year=100;
    //   Internet explorer reports year=2000;
    // For dates in 19xx
    //   Both browsers report year=xx
    // There is another function called getFullYear, which works,
    // *except* that Netscape 4.5 for windows reports year=1900 (:-(
    // The following works for all variants of the two browser, I have
    // tried :
    year %= 100;
    if (year >= 98 )
      century = "19";
    else
      century = "20";
    if (year<10){
      year = "0" + year;
    }
 	      
    document.writeln("<DIV STYLE=\"font:smaller\">"
		     + "[Modified: " 
		     + day_names[lastmod.getDay()] 
		     + " " 
		     + month_names[lastmod.getMonth()] 
		     + " " 
		     + sup_date
		     + " " 
		     + century + year 
		     + " at " 
		     + hours + ":" + minutes
		     + "]"
		     + "</DIV>"
		     );
  }
}
