function writeLastModified()
//This writes the last modified date on the page
  {
    //Get the last modified date and convert it to the fancy string
    var lastModifiedDate = dateToString(document.lastModified);
    //Output it
    document.writeln(lastModifiedDate);
    document.close();
  }
function writeCurrent()
//This writes the last modified date on the page
  {
    //Get the current date and convert it to the fancy string
    var currentDate = dateToString(new Date());
    //Output it
    document.writeln(currentDate);
    document.close();
  }
function dateToString(dateToChange)
  {
    //Default return string
    var returnString = 'Unknown';

    //Get the date and extract the hours, mins, etc.
    dateToChange = new Date(dateToChange);
    if (dateToChange != 0 && dateToChange.getHours() != 1970)
      {
        var minutesValue = dateToChange.getMinutes();
        var secondsValue = dateToChange.getSeconds();
        var hoursValue = dateToChange.getHours();
        var dayValue = dateToChange.getDay();
        var dateValue = dateToChange.getDate();
        var monthValue = dateToChange.getMonth();
        var yearValue = dateToChange.getYear();

        //This fixes the year bugs
        if (yearValue > 98 && yearValue < 105) yearValue += 1900;
        if (yearValue >= 0 && yearValue < 6) yearValue += 2000; 

        //Create arrays for the day and month strings
        var dayArray = new Array('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag');
        var monthArray = new Array('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'Novemeber', 'Dezember');

        //Find the suffix for the date (e.g. st, th, etc) and encase it in <sup> tags
        var dateSuffix = '';
        if (dateValue == 1 || dateValue == 21 || dateValue == 31) dateSuffix = '';
        else if (dateValue == 2 || dateValue == 22) dateSuffix = "";
        else if (dateValue == 3 || dateValue == 23) dateSuffix = "";
        else dateSuffix = "";
        dateSuffix = '<sup>' + dateSuffix + '</sup>'

        //Add : and 0 to the time where needed otherwise 00 seconds = 0 seconds
        var timeValue = '';
        if (hoursValue < 10) timeValue = '0' + hoursValue;
        else timeValue =  hoursValue;
        timeValue += ':';
        if (minutesValue < 10) timeValue +=  '0' + minutesValue;
        else  timeValue +=  minutesValue;
        timeValue += ':';
        if (secondsValue < 10) timeValue += '0' + secondsValue;
        else timeValue += secondsValue;
    
        returnString = dayArray[dayValue] + ' ' + dateValue + dateSuffix + ' ' + monthArray[monthValue] + ' ' + yearValue + ' - ' + timeValue;
      }
    //Return the string to the document
    return returnString;
  }
