  //--------------------------------------------------------------------
  //- EXTENSIONS TO THE DATE CLASS
  //--------------------------------------------------------------------

  Date.prototype.dayNames = ['Sunday',   'Monday', 'Tuesday', 'Wednesday',
                             'Thursday', 'Friday', 'Saturday'];

  Date.prototype.monthNames = ['January',   'February', 'March',    'April',
                               'May',       'June',     'July' ,    'August',
                               'September', 'October',  'November', 'December'];

  //--------------------------------------------------------------------
  //- aDay - The number of milliseconds in a day.
  //--------------------------------------------------------------------
  Date.prototype.aDay = parseFloat('86400000');

  //--------------------------------------------------------------------
  //- tbaYesterday - 24 hours before this date.
  //--------------------------------------------------------------------
  Date.prototype.yesterday = function ()
  {
     return new Date(Date.parse(this)-this.aDay);
  };

  //--------------------------------------------------------------------
  //- tbaTomorrow - 24 hours after this date.
  //--------------------------------------------------------------------
  Date.prototype.tomorrow = function ()
  {
     return new Date(Date.parse(this)+this.aDay);
  };

  //--------------------------------------------------------------------
  //- tbaFormat - Format date for printing the TBA way.
  //--------------------------------------------------------------------
  Date.prototype.tbaFormat = function(long)
  {
   var s = '';

// if (long)
//  s = this.dayNames[this.getDay()]+', ';

   s = s+(1+this.getMonth())+'/'
        +this.getDate();

   if (long)
    s = s + '/' + this.getFullYear();

   return s;
  };

  //--------------------------------------------------------------------
  //- tbaNextShabbat - Return the date of the closest Shabbat on or
  //  after today.
  //--------------------------------------------------------------------
  Date.prototype.nextShabbat = function()
  {
    var date = this;

    //- If today is Saturday, then we are already in Shabbat that started yesterday.
    if (date.getDay() == 6)
     return date.yesterday();

    //- If today is not Friday, then keep adding one day until we reach Friday.
    while (date.getDay() != 5)
    {
      date = date.tomorrow();
    }

    return date;
  };

  //--------------------------------------------------------------------
  //- tbaIsShabbat - Is the date given a Friday or Saturday?
  //  after today.
  //--------------------------------------------------------------------
  Date.prototype.isShabbat = function()
  {
    return this.getDay()>4;
  };

  //--------------------------------------------------------------------
  //- tbaSameDateAs - Are the YYYY MM DD of this date the same as the
  //  YYYY MM DD of the given date?
  //--------------------------------------------------------------------
  Date.prototype.sameDateAs = function(aDate)
  {
    if (typeof(aDate) != 'object')
     return false;

    if (aDate.constructor != (new Date()).constructor)
     return false;

    return (aDate.getDate()     == this.getDate()  &&
            aDate.getMonth()    == this.getMonth() &&
            aDate.getFullYear() == this.getFullYear());
  };

  //--------------------------------------------------------------------
  //- weekdayOrdinal - Is this weekday the 1st, 2nd, 3rd, 4th, or 5th,
  //- of this weekday in the month? //- e.g. If 12/26/2008 is the 4th
  //- Friday of the month, weekDayOrdinal == 4.
  //--------------------------------------------------------------------
  Date.prototype.weekdayOrdinal = function()
  {
   var target;
   var count = 0;

   for (target = new Date(this.getFullYear(),this.getMonth(),1);
        target.getMonth() == this.getMonth();
        target = target.tomorrow())
   {
     if (target.getDay() == this.getDay())
      count++;

     if (target.getDate() == this.getDate())
      break;
   }

   return count;
  };

  //--------------------------------------------------------------------

