function produceDate() {
  var today = new Date();
  var day = today.getDay();
  var date = today.getDate();
  var month = today.getMonth();
  var year = today.getFullYear();

  if (day==1)
    dayofweek = "Monday";
  if (day==2)
    dayofweek = "Tuesday";
  if (day==3)
    dayofweek = "Wednesday";
  if (day==4)
    dayofweek = "Thursday";
  if (day==5)
    dayofweek = "Friday";
  if (day==6)
    dayofweek = "Saturday";
  if (day==0)
    dayofweek = "Sunday";

  if (month == 0)
    mth_nm = "January";
  if (month == 1)
    mth_nm = "February";
  if (month == 2)
    mth_nm = "March";
  if (month == 3)
    mth_nm = "April";
  if (month == 4)
    mth_nm = "May";
  if (month == 5)
    mth_nm = "June";
  if (month == 6)
    mth_nm = "July";
  if (month == 7)
    mth_nm = "August";
  if (month == 8)
    mth_nm = "September";
  if (month == 9)
    mth_nm = "October";
  if (month == 10)
    mth_nm = "November";
  if (month == 11)
    mth_nm = "December";

  if ( (date == 1) || (date == 21) || (date == 31) )
    {
      var rank = 'st';
    }
  else if ( (date == 2) || (date == 22) )
    {
      var rank = 'nd';
    }
  else if ( (date == 3) || (date == 23) )
    {
      var rank = 'rd';
    }
  else if ( (date >= 4 && date <= 20 ) ||  (date >= 24 && date <= 30 ) )
    {
      var rank = 'th';
    }

  the_date = mth_nm + " " + date + rank + " " + year;

  month_day = mth_nm + "_" + date;

  moments_number = date;

  booklet_number = eval(month + 1);

}

produceDate();

function writeDate(id) {
  var nodeObj = document.getElementById(id);
  nodeObj.firstChild.nodeValue = the_date;
}

function auto_word(){
  location.href= 'devotions.php?' + month_day;
}

function auto_moments(){
  alert('Real Audio Player, if it\'s installed on your computer, will now open\nand today\'s Moments of Music and Inspiration will stream for you automatically.\n\nPlease consider supporting this ministry\nby ordering the CD \'One for the Road\'');
  location.href = '../momentsProgram.php?' + 'moments_' + moments_number;
}
function auto_booklet(){
  alert('Adobe Acrobat Reader, if it\'s installed on your computer, will now open\nand the Daily Guide month booklet will be loaded in it.\n\nYou can print it directly from there.\nHowever, it might be better to save it to disk first.\n\nInstructions for Printing:\nprint on both sides of your paper,\nput the papers together in order and fold as a booklet.');
  location.href = '../documents/devotional_' + booklet_number + '.pdf';
}
