﻿
if (typeof window.addEventListener != 'undefined')
 {
   window.addEventListener('load', sh_onload, false);
 }
 else if (typeof document.addEventListener != 'undefined')
 {
   document.addEventListener('load', sh_onload, false);
 }
 else if (typeof window.attachEvent != 'undefined')
 {
   window.attachEvent('onload', sh_onload);
 }
 else
 {
  var oldfn = window.onload;
   if (typeof window.onload != 'function')
   {
     window.onload = sh_onload;
   }
   else
   {
     window.onload = function()
     {
       oldfn();
       sh_onload()
     }
   } 
 }

function sh_get2day()
{
    var dt=new Date()
    if(document.all)
    {
        document.getElementById('dayDisplay').innerText =getDayWord(dt.getDay()) + ", " +  dt.getDate()
           + " " +  getMonthWord(dt.getMonth()) + " " + dt.getFullYear();
        document.getElementById('dayGreeting').innerText = getGreeting()
    } 
    else
    {
        document.getElementById('dayDisplay').textContent = getDayWord(dt.getDay()) + ", " + dt.getDate() 
            + " " + getMonthWord(dt.getMonth()) + " " + dt.getFullYear();            
        document.getElementById('dayGreeting').textContent = getGreeting()
    }
}

function getGreeting()
{
    var date=new Date();     // Gets the full date!
    var day=date.getHours(); // Gets the hours!
    if(day<=11) 
    {
        return('Good Morning'); // If it's before 12 PM then display this!
    }
    else if(day<18)
    {
        return('Good Afternoon'); // After 12 PM display this!
    } 
    else 
    {
        return('Good Evening'); // After 6 PM display this!
    }
}

function getDayWord(num)
{
    var myDays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
    return myDays[num]
}

function getMonthWord(num)
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   return months[num]
} 

