
var now         = new Date();

function getHoursLeft(theDate) {
    if (theDate == null) 
        theDate = now;
    else 
        theDate = new Date(theDate);
        
    document.write(24 - theDate.getHours() + " hours");
}

function getCalendarDate(theDate) {
   var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December")

    if (theDate == null) 
        theDate = now;
    else 
        theDate = new Date(theDate);
   
   var monthnumber = theDate.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = theDate.getDate();
   var suffix = "th";
   
   if (monthday == 1 || monthday == 21 || monthday == 31) suffix = "st";
   if (monthday == 2 || monthday == 22) suffix = "nd";
   if (monthday == 3 || monthday == 23) suffix = "rd";
   
   var dateString = monthname + ' ' + monthday + suffix;
   document.write(dateString);
} // function getCalendarDate()

function countdown(theDate, specialDay, showMinutes){
    var today = new Date();
    future = new Date(theDate);

    if(future.getFullYear() < 2000) future.setFullYear(future.getFullYear() + 100); 

    dd = future - today;
    
    dday=Math.floor(dd/(60*60*1000*24)*1)
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
    if(dday==0&&dhour==0&&dmin==0&&dsec==1){
        document.write("Today is " + specialDay);
        return;
    }
 
    document.write(dday+ " days, ");
    
    if (!showMinutes)
        document.write("and "+dhour+" hours left until ");
    else {
        document.write(dhour+" hours");
        document.write(", and "+dmin+" minutes left to ");
    }
    
    document.write(specialDay);
    
    //setTimeout("countdown(theDate,specialDay,showMinutes)",60000)
}

/*
function countdown2(theDate, specialDay){
    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

    theyear=yr;themonth=m;theday=d
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000) todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todayh=today.getHours()
    var todaymin=today.getMinutes()
    var todaysec=today.getSeconds()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
    futurestring=montharray[m-1]+" "+d+", "+yr
    dd=Date.parse(futurestring)-Date.parse(todaystring)
    dday=Math.floor(dd/(60*60*1000*24)*1)
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
    if(dday==0&&dhour==0&&dmin==0&&dsec==1){
        document.write("Today is " + specialDay);
        return
    }
    else
        document.write(dday+ " days, "+dhour+" hours, and "+dmin+" minutes left until "+specialDay);
    
    setTimeout("countdown(theyear,themonth,theday)",60000)
}
*/