<script language="JavaScript">
<!--
  function birthday(year,month,date,person) {

    this.year=year

    this.month=month

    this.date=date

    this.person=person

  }

  function birthdaylist() {

  }



  blist=new birthdaylist()

  blist[0]= new birthday(47,11,27,"Alan")

  blist[1]= new birthday(52,7,31,"Colin")

  blist[2]= new birthday(49,6,15,"Joan")

  blist[3]= new birthday(80,9,1,"Liz")

  blist[4]= new birthday(78,12,31,"Mike")

  blist[5]= new birthday(76,7,2,"Kate")

  var now=new Date()

  today=new Date(now.getYear(),now.getMonth(),now.getDate())   // today 0:00:00

  function daysFromToday(sdate) {

    return Math.round((sdate.getTime()-today.getTime())/(24*60*60*1000))

  }

  function writeNextBirthday(list) {

    var daysToClosest=888

    var closest

    for (var i in list) {

      thisDate=new Date(today.getYear(),list[i].month,list[i].date)

      if (daysFromToday(thisDate)<0)

        thisDate.setYear(today.getYear()+1)

      if (daysFromToday(thisDate)<daysToClosest) {

        daysToClosest=daysFromToday(thisDate)

        closest=i

      }

    }

    if (daysToClosest==0)

      document.write("<p><b>Today "+list[closest].person+" became "+(today.getYear()-list[closest].year)+" years old!</b></p>")

    else if (daysToClosest==1)

      document.write("<p>Tomorrow "+list[closest].person+" will become "+(today.getYear()-list[closest].year)+" .</p>")

    else

      document.write("<p>The next birthday will be "+list[closest].person+"'s, in "+daysToClosest+" days.</p>")

  }
//--> 
</script>
</head>
<center><h1>A Birthday Calendar</h1></center>
<p>The following people's birthdays were entered:
<ul><li>Alan, 27 November 1947
<li>Colin, 31 July 1952
<li>Joan, 15 June 1949
<li>Liz, 1 September 1980
<li>Mike, 31 December 1978
<li>Kate, 2 July 1976</ul></p>
<script language="JavaScript">
<!--
  writeNextBirthday(blist)
//--> 
</script>
<p>For some reason this script does not work with Opera, although all versions of Netscape and Internet Explorer display it perfectly.</p>
