/*Created by Rick Bull (http://www.rickmusic.co.uk/ and  http://www.rickmusic.fsnet.co.uk/) - 13 Feb 2001.
 You are free to distribute and use this script anyway you like but please leave this comment here. Thanks.*/
 
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 = '(!)Non saprei(^_^)';

    //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('Domenica', 'Luned&igrave;', 'Marted&igrave;', 'Mercoled&igrave;', 'Gioved&igrave;', 'Venerd&igrave;', 'Sabato');
        var monthArray = new Array('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre');

        //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 = 'st';
        else if (dateValue == 2 || dateValue == 22) dateSuffix = "nd";
        else if (dateValue == 3 || dateValue == 23) dateSuffix = "rd";
        else dateSuffix = "th";
        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 + ' ' + monthArray[monthValue] + ' ' + yearValue + ' - ' + timeValue;
      }
    //Return the string to the document
    return returnString;
  }