/* http://oluchi.yn.lt */ var today=new Date() var theoccasion=new Date(today.getFullYear(), 1, 1) var beforeOccasionText="to go before New Year" var onOccasiontext="" var monthtext=new Array("Jan","Feb","Mar","April","May","June","July","Aug","Sep","Oct","Nov","Dec") theoccasion.setMonth(theoccasion.getMonth()-1) //change to 0-11 month format var showdate="("+monthtext[theoccasion.getMonth()]+" "+theoccasion.getDate()+","+" "+[today.getFullYear()+1]+"). " //show date of occasion var one_day=1000*60*60*24 var calculatediff="" calculatediff=Math.ceil((theoccasion.getTime()-today.getTime())/(one_day)) if (calculatediff<0){ //if bday already passed var nextyeartoday=new Date() nextyeartoday.setFullYear(today.getFullYear()+1) calculatediff=Math.ceil((nextyeartoday.getTime()-today.getTime())/(one_day)+calculatediff) } var pluraldayornot=(calculatediff==1)? "day" : "days" if (calculatediff>0) document.write(""+calculatediff+" "+pluraldayornot+" "+beforeOccasionText+" "+showdate+"!") else if (calculatediff==0) document.write(""+onOccasiontext+"")