
todaysdate = new Date();

months = new Array(
   "January","February","March","April","May","June",
   "July","August","September","October","November","December"
);

days = new Array(
   "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
);

function todayday()
{
   var datetext = '';
   
   datetext = datetext + days[todaysdate.getDay()] + ", " +todaysdate.getDate() + 
   numberEnding(todaysdate.getDate()) + " " + months[todaysdate.getMonth()] + 
   " " + todaysdate.getFullYear();
   
   //create text node and add it to the correct div
   var textnode = document.createTextNode(datetext);
   
   var positioner = document.getElementById('datetime');
   if(positioner != null)
   {
      positioner.appendChild(textnode);
   }
}

function numberEnding(num)
{
   if(num >= 4 && num <= 20)
   {
     return "th";
   }
   
   lastDigit = num.toString().charAt(num.toString().length-1);
   switch(lastDigit)
   {
     case "1":
     return "st";
     case "2":
     return "nd";
     case "3":
     return "rd";
     case "0":
     return "th";
   }
   
   return "th";
}