/*
File Name:
   scripts/last_modified.js
File Author:
   Joe Morrow <j-morrow@northwestern.edu>
Last Updated:
   1:15 PM 4/22/2005 JOE
*/


/*
Function Name:
   getLastModified
Function Arguments:
   dateFormat
   head_date
Function Returns:
   modDate
Function Description:
   - returns a date string of the input format
   - 1. "%F %j, %Y" ("September 29, 2003")
   - 2. "%m/%d/%Y" ("09/29/2003")
   - head_date is a variable passed from PHP of the form yyyy/mm/dd, document.lastModified will be used if NULL
Last Updated:
   1:15 PM 4/22/2005 JOE
*/
function getLastModified(dateFormat, head_date) {
   var modDate = 0;
   var monthIncrement = 0;

   if (arguments.length == 2) {
//      alert("head_date = " + head_date);
      var head_dateString = new String(head_date);
      var LastModDate = new Date(head_date.substr(0,4), head_date.substr(5,2), head_date.substr(8,2));
   } else if (document.lastModified != 0) {
//      alert("document.lastModified = " + document.lastModified);
      var LastModDate = new Date(document.lastModified);
      monthIncrement = 1;
   } else {
//      alert("0");
      var LastModDate = 0
   }

   if (LastModDate != 0) {

      var year = LastModDate.getYear();
      if (year < 1000)
         year += 1900;

      switch (dateFormat) {
         case 1:
            var months = new Array("January","February","March","April",
                                "May","June","July","August","September",
                                "October","November","December");
            modDate = months[(LastModDate.getMonth() + monthIncrement)] + " " + LastModDate.getDate() + ", " + year;
            break;
         case 2:
         default:
            modDate = (LastModDate.getMonth() + monthIncrement) + "/" + LastModDate.getDate() + "/" + year;
            break;
      }
   }

   return modDate;
}


/*
Function Name:
   getCopyrightYear
Function Arguments:
   none
Function Returns:
   copyYear
Function Description:
   - returns the current year in "YYYY" format
Last Updated:
   3:15 PM 1/5/2005 JOE
*/
function getCopyrightYear(Null) {
   var today = new Date();
   var year = today.getYear();
   if (year < 1000)
      year += 1900;

   return year;
}
