// JavaScript Document for greeting


//greeting script
// Get the current date
today = new Date();
// Get the current month
month = today.getMonth();
// Attach a display name to each of the 12 possible month numbers
switch (month) {
    case 0 :
        displayMonth = "January"
        break
    case 1 :
        displayMonth = "February"
        break
    case 2 :
        displayMonth = "March"
        break
    case 3 :
        displayMonth = "April"
        break
    case 4 :
        displayMonth = "May"
        break
    case 5 :
        displayMonth = "June"
        break
    case 6 :
        displayMonth = "July"
        break
    case 7 :
        displayMonth = "August"
        break
    case 8 :
        displayMonth = "September"
        break
    case 9 :
        displayMonth = "October"
        break
    case 10 :
        displayMonth = "November"
        break
    case 11 :
        displayMonth = "December"
        break

    default: displayMonth = "INVALID"
}
// Set some variables to make the JavaScript code
// easier to read
    var hours = today.getHours()
    var minutes = today.getMinutes()
    var greeting
    var ampm
    // We consider anything up until 11 a.m."morning"
    if (hours <= 11) {
        greeting = "Good morning!"
        ampm="a.m."
        // JavaScript reports midnight as 0, which is just plain
        // crazy; so we want to change 0 to 12.
        if (hours == 0) {
            hours = 12
        }
    }
    // We consider anything after 11:00 a.m. and before 6 p.m. (in
    // military time, 6 p.m. is 18) to be "afternoon"
    else if (hours > 11 && hours < 18) {
        greeting = "Good afternoon!"
        ampm="p.m."
        // We don't want to see military time, so subtract 12
        if (hours > 12) {
            hours-=12
        }
    }
    // We consider anything after five p.m. (17 military) but
    // before nine p.m. (21 in military time) "evening"
    else if (hours > 17 && hours < 21) {
        greeting = "Good evening!"
        ampm="p.m."
        hours-=12
    }
    // We consider nine o'clock until midnight "night"
    else if (hours > 20) {
        greeting = "Good night!"
        ampm="p.m."
        hours-=12
    }
    // We want the minutes to display with "0" in front of them if
    // they're single-digit.  (For example, rather than 1:4 p.m.,
    // we want to see 1:04 p.m.
    if (minutes < 10) {
        minutes = "0" + minutes
    }
var displayGreeting = greeting + "<br /> It's " + hours + ":" + minutes + " " + ampm + "<br/>" + displayMonth + " " + today.getDate() + ", " + today.getYear()