/*---------------------------------------------------------------
 (c) 2009 Divine Savior United Methodist Church
     5702 South Hill Drive, Madison, WI  53705
     (608) 238-7753, dsumc@wisconsinumc.org

 TITLE: Divine Savior United Methodist Church (dslectionary.js)
 URL..: www.divinesaviorumc.org
 DATA.: This file uses J-script; Readings from http://www.gbod.org/worship/lectionary/default.asp?year=2008
---------------------------------------------------------------*/



function loadLect(lectNum)
{
lect = new Array(new Date("1/1/2009"),
"New Year (A, B, and C) - (White)",
"* Ecclesiastes 3:1-13",
"* Psalm 8 (UMH 743)",
"* Revelation 21:1-6a",
"* Matthew 25:31-46",
"",
new Date("1/4/2009"),
"Epiphany of the Lord/Epiphany Sunday - (White)",
"* Isaiah 60:1-6",
"* Psalm 72:1-7, 10-14 (UMH 795)",
"* Ephesians 3:1-12",
"* Matthew 2:1-12",
"",
new Date("1/6/2009"),
"Epiphany of the Lord/Epiphany Sunday - (White)",
"* Isaiah 60:1-6",
"* Psalm 72:1-7, 10-14 (UMH 795)",
"* Ephesians 3:1-12",
"* Matthew 2:1-12",
"",
new Date("1/11/2009"),
"Baptism of the Lord (White)",
"* Genesis 1:1-5",
"* Psalm 29 (UMH 761)",
"* Acts 19:1-7",
"* Mark 1:4-11",
"",
new Date("1/18/2009"),
"Second Sunday After the Epiphany (Green)",
"* 1 Samuel 3:1-10 (11-20)",
"* Psalm 139:1-6, 13-18 (UMH 854)",
"* 1 Corinthians 6:12-20",
"* John 1:43-51",
"",
new Date("1/25/2009"),
"Third Sunday After the Epiphany (Green)",
"* Jonah 3:1-5, 10",
"* Psalm 62:5-12 (UMH 787)",
"* 1 Corinthians 7:29-31",
"* Mark 1:14-20",
"",
new Date("2/1/2009"),
"Fourth Sunday After the Epiphany (Green)",
"* Deuteronomy 18:15-20",
"* Psalm 111 (UMH 832)",
"* 1 Corinthians 8:1-13",
"* Mark 1:21-28",
"",
new Date("2/2/2009"),
"The Presentation of the Lord/Candlemas (White)",
"* Malachi 3:1-4",
"* Psalm 24 (UMH 755)",
"* Hebrews 2:14-18",
"* Luke 2:22-40",
"",
new Date("2/8/2009"),
"Fifth Sunday after Epiphany (Green)",
"* Isaiah 40:21-31",
"* Psalm 147:1-11, 20c (UMH 859)",
"* 1 Corinthians 9:16-23",
"* Mark 1:29-39",
"",
new Date("2/15/2009"),
"Sixth Sunday after Epiphany (Green)",
"* 2 Kings 5:1-14",
"* Psalm 30 (UMH 762)",
"* 1 Corinthians 9:24-27",
"* Mark 1:40-45",
"",
new Date("2/12/2009"),
"Transfiguration Sunday (White or Gold)",
"* 2 Kings 2:1-12",
"* Psalm 50:1-6 (UMH 783)",
"* 2 Corinthians 4:3-6",
"* Mark 9:2-9",
"",
new Date("2/25/2009"),
"Ash Wednesday (Purple)",
"* Joel 2:1-2, 12-17",
"* Psalm 51:1-17 (UMH 785)",
"* 2 Corinthians 5:20b-6:10",
"* Matthew 6:1-6, 16-21",
"",
new Date("3/1/2009"),
"First Sunday in Lent (Purple)",
"* Genesis 9:8-17",
"* Psalm 25:1-10 (UMH 756)",
"* 1 Peter 3:18-22",
"* Mark 1:9-15",
"",
new Date("3/8/2009"),
"Second Sunday in Lent (Purple)",
"* Genesis 17:1-7, 15-16",
"* Psalm 22:23-31 (UMH 752)",
"* Romans 4:13-25",
"* Mark 8:31-38",
"",
new Date("3/15/2009"),
"Third Sunday in Lent (Purple)",
"* Exodus 20:1-17",
"* Psalm 19 (UMH 750)",
"* 1 Corinthians 1:18-25",
"* John 2:13-22",
"",
new Date("3/22/2009"),
"Fourth Sunday in Lent (Purple)",
"* Numbers 21:4-9",
"* Psalm 107:1-3, 17-22 (UMH 830)",
"* Ephesians 2:1-10",
"* John 3:14-21",
"",
new Date("3/29/2009"),
"Fifth Sunday in Lent (Purple)",
"* Jeremiah 31:31-34",
"* Psalm 51:1-12 (UMH 785)",
"* Hebrews 5:5-10",
"* John 12:20-33",
"",
new Date("4/5/2009"),
"Passion/Palm Sunday (Sixth Sunday in Lent) - Liturgy of the Palms",
"* Matthew 11:1-11",
"* Psalm 118:1-2, 19-29 (UMH 839)",
"",
"",
"",
new Date("4/5/2009"),
"Passion/Palm Sunday (Sixth Sunday in Lent) - Liturgy of the Passion",
"* Isaiah 50:4-9a",
"* Psalm 31:9-16 (UMH 764)",
"* Philippians 2:5-11",
"* Mark 14:1-15:47 or Mark 15:1-39 (40-47)",
"",
new Date("4/6/2009"),
"Monday of Holy Week (Red or Purple)",
"* Isaiah 42:1-9",
"* Psalm 36:5-11 (UMH 771)",
"* Hebrews 9:11-15",
"* John 12:1-11",
"",
new Date("4/7/2009"),
"Tuesday of Holy Week (Red or Purple)",
"* Isaiah 49:1-7",
"* Psalm 71:1-14 (UMH 794)",
"* 1 Corinthians 1:18-31",
"* John 12:20-36",
"",
new Date("4/8/2009"),
"Wednesday of Holy Week (Red or Purple)",
"* Isaiah 50:4-9a",
"* Psalm 70 (UMH 793)",
"* Hebrews 12:1-3",
"* John 13:21-32",
"",
new Date("4/9/2009"),
"Holy Thursday (Red or Purple)",
"* Exodus 12:1-4 (5-10) 11-14",
"* Psalm 116:1-4, 12-19 (UMH 837)",
"* 1 Corinthians 11:23-26",
"* John 13:1-17, 31b-35",
"",
new Date("4/10/2009"),
"Good Friday (No Color)",
"* Isaiah 52:13-53:12",
"* Psalm 22 (UMH 752)",
"* Hebrews 10:16-25",
"* John 18:1-19:42",
"",
new Date("4/11/2009"),
"Easter Vigil (White)",
"* Exodus 14",
"* Psalms/Canticles",
"* Additon Old Testament Readings",
"",
"",
new Date("4/12/2009"),
"Easter (White)",
"* Acts 10:34-43",
"* Psalm 118:1-2, 14-24 (UMH 839)",
"* 1 Corinthians 15:1-11",
"* John 20:1-18 or",
"* Mark 16:1-8",
new Date("4/19/2009"),
"Second Sunday of Easter (White)",
"* Acts 4:32-35",
"* Psalm 133 (UMH 850)",
"* 1 John 1:1-2:2",
"* John 20:19-31",
"",
new Date("4/26/2009"),
"Third Sunday of Easter (White)",
"* Acts 3:12-19",
"* Psalm 4 (UMH 741)",
"* 1 John 3:1-7",
"* Luke 24:36b-48",
"",
new Date("5/3/2009"),
"Fourth Sunday of Easter (White)",
"* Acts 4:5-12",
"* Psalm 23 (UMH 754 or 137)",
"* 1 John 3:16-24",
"* John 10:11-18",
"",
new Date("5/10/2009"),
"Fifth Sunday of Easter (White)",
"* Acts 8:26-40",
"* Psalm 22:25-31 (UMH 752)",
"* 1 John 4:7-21",
"* John 15:1-8",
"",
new Date("5/17/2009"),
"Sixth Sunday of Easter (White)",
"* Acts 10:44-48",
"* Psalm 98 (UMH 818)",
"* 1 John 5:1-6",
"* John 15:9-17",
"",
new Date("5/21/2009"),
"Ascension of the Lord (White)",
"* Acts 1:1-11",
"* Psalm 47 (UMH 781)",
"* Ephesians 1:15-23",
"* Luke 24:44-53",
"",
new Date("5/24/2009"),
"Seventh Sunday of Easter (White)",
"* Acts 1:15-17, 21-26",
"* Psalm 1 (UMH 738)",
"* 1 John 5:9-13",
"* John 17:6-19",
"",
new Date("5/31/2009"),
"Day of Pentecost (Red or White)",
"* Acts 2:1-21",
"* Psalm 104:24-34, 35b (UMH 826)",
"* Romans 8:22-27",
"* John 15:26-27; 16:4b-15",
"",
new Date("6/7/2009"),
"Trinity Sunday/First Sunday after Pentecost (White)",
"* Isaiah 6:1-8",
"* Psalm 29 (UMH 761)",
"* Romans 8:12-17",
"* John 3:1-17",
"",
new Date("6/14/2009"),
"Second Sunday after Pentecost (Green)",
"* 1 Samuel 15:34-16:13",
"* Psalm 20 or Psalm 92 (UMH 811)",
"* 2 Corinthians 5:6-10 (11-13), 14-17",
"* Mark 4:26-34",
"",
new Date("6/21/2009"),
"Third Sunday after Pentecost (Green)",
"* 1 Samuel 17:(1a , 4-11, 19-23), 32-49",
"* Psalm 9:9-20 (UMH 744)",
"* 2 Corinthians 6:1-13",
"* Mark 4:35-41",
"",
new Date("6/28/2009"),
"Fourth Sunday after Pentecost (Green)",
"* 2 Samuel 1:1, 17-27",
"* Psalm 130 (UMH 848)",
"* 2 Corinthians 8:7-15",
"* Mark 5:21-43",
"",
new Date("7/5/2009"),
"Fifth Sunday after Pentecost (Green)",
"* 2 Samuel 5:1-5, 9-10",
"* Psalm 48 (UMH 782)",
"* 2 Corinthians 12:2-10",
"* Mark 6:1-13",
"",
new Date("7/12/2009"),
"Sixth Sunday after Pentecost (Green)",
"* 2 Samuel 6:1-5, 12b-19",
"* Psalm 24 (UMH 755)",
"* Ephesians 1:3-14",
"* Mark 6:14-29",
"",
new Date("7/19/2009"),
"Seventh Sunday after Pentecost (Green)",
"* 2 Samuel 7:1-14a",
"* Psalm 89:20-37 (UMH 807)",
"* Ephesians 2:11-22",
"* Mark 6:30-34, 53-56",
"",
new Date("7/26/2009"),
"Eighth Sunday after Pentecost (Green)",
"* 2 Samuel 11:1-15",
"* Psalm 14 (UMH 746)",
"* Ephesians 3:14-21",
"* John 6:1-21",
"",
new Date("8/2/2009"),
"Ninth Sunday after Pentecost (Green)",
"* 2 Samuel 11:26-12:13a",
"* Psalm 51:1-12 (UMH 785)",
"* Ephesians 4:1-16",
"* John 6:24-35",
"",
new Date("8/9/2009"),
"Tenth Sunday after Pentecost (Green)",
"* 2 Samuel 18:5-9, 15, 31-33",
"* Psalm 130 (UMH 848)",
"* Ephesians 4:25-5:2",
"* John 6:35, 41-51",
"",
new Date("8/16/2009"),
"Eleventh Sunday after Pentecost (Green)",
"* 1 Kings 2:10-12; 3:3-14",
"* Psalm 111 (UMH 832)",
"* Ephesians 5:15-20",
"* John 6:51-58",
"",
new Date("8/23/2009"),
"Twelfth Sunday after Pentecost (Green)",
"* 1 Kings 8:1, 6, 10-11; 22-30, 41-43",
"* Psalm 84 (UMH 804)",
"* Ephesians 6:10-20",
"* John 6:56-69",
"",
new Date("8/30/2009"),
"Thirteenth Sunday after Pentecost (Green)",
"* Song of Solomon 2:8-13",
"* Psalm 45:1-2, 6-9 or Psalm 72 (UMH 795)",
"* James 1:17-27",
"* Mark 7:1-8, 14-15, 21-23",
"",
new Date("9/6/2009"),
"Fourteenth Sunday after Pentecost (Green)",
"* Proverbs 22:1-2, 8-9, 22-23",
"* Psalm 125 or Psalm 124 (UMH 846)",
"* James 2:1-10 (11-13) 14-17",
"* Mark 7:24-37",
"",
new Date("9/13/2009"),
"Fifteenth Sunday after Pentecost (Green)",
"* Proverbs 1:20-33",
"* Psalm 19 (UMH 750)",
"* James 3:1-12",
"* Mark 8:27-38",
"",
new Date("9/20/2009"),
"Sixteenth Sunday after Pentecost (Green)",
"* Proverbs 31:10-31",
"* Psalm 1 (UMH 738)",
"* James 3:13-4:3, 7-8a",
"* Mark 9:30-37",
"",
new Date("9/27/2009"),
"Seventeenth Sunday after Pentecost (Green)",
"* Esther 7:1-6, 9-10; 9:20-22",
"* Psalm 124 (UMH 846)",
"* James 5:13-20",
"* Mark 9:38-50",
"",
new Date("10/4/2009"),
"Eighteenth Sunday after Pentecost (Green)",
"* Job 1:1; 2:1-10",
"* Psalm 26 or Psalm 25 (UMH 756)",
"* Hebrews 1:1-4; 2:5-12",
"* Mark 10:2-16",
"",
new Date("10/11/2009"),
"Nineteenth Sunday after Pentecost/Children's Sabbath (Green)",
"* Job 23:1-9, 16-17",
"* Psalm 22:1-15 (UMH 752)",
"* Hebrews 4:12-16",
"* Mark 10:17-31",
"",
new Date("10/18/2009"),
"Twentieth Sunday after Pentecost/Laity Sunday (Green)",
"* Job 38:1-7 (34-41)",
"* Psalm 104:1-9, 24, 35c (UMH 826)",
"* Hebrews 5:1-10",
"* Mark 10:35-45",
"",
new Date("10/25/2009"),
"Twenty-First Sunday after Pentecost (Green)",
"* Job 42:1-6, 10-17",
"* Psalm 34:1-8 (19-22) (UMH 769)",
"* Hebrews 7:23-28",
"* Mark 10:46-52",
"",
new Date("11/1/2009"),
"All Saints Day (White or Red)",
"* Isaiah 25:6-9",
"* Psalm 24 (UMH 755)",
"* Revelation 21:1-6a",
"* John 11:32-44",
"",
new Date("11/1/2009"),
"Twenty-Second Sunday after Pentecost (Green)",
"* Ruth 1:1-18",
"* Psalm 146 (UMH 858)",
"* Hebrews 9:11-14",
"* Mark 12:28-34",
"",
new Date("11/8/2009"),
"Twenty-Third Sunday after Pentecost (Green)",
"* Ruth 3:1-5; 4:13-17",
"* Psalm 127 or Psalm 42 (UMH 777)",
"* Hebrews 9:24-28",
"* Mark 12:38-44",
"",
new Date("11/15/2009"),
"Twenty-Fourth Sunday after Pentecost (Green)",
"* 1 Samuel 1:4-20",
"* 1 Samuel 2:1-10 or Psalm 113 (UMH 834)",
"* Hebrews 10:11-14 (15-18) 19-25",
"* Mark 13:1-8",
"",
new Date("11/22/2009"),
"Christ the King/Reign of Christ (White or Gold)",
"* 2 Samuel 23:1-7",
"* Psalm 132:1-12 (UMH 849)",
"* Revelation 1:4b-8",
"* John 18:33-37",
"",
new Date("11/26/2009"),
"Thanksgiving Day (Green, White, or Red)",
"* Joel 2:21-27",
"* Psalm 126 (UMH 847)",
"* 1 Timothy 2:1-7",
"* Matthew 6:25-33",
"",
new Date("11/29/2009"),
"First Sunday of Advent (Purple or Blue)",
"* Jeremiah 33:14-16",
"* Psalm 25:1-10 (UMH 756)",
"* 1 Thessalonians 3:9-13",
"* Luke 21:25-36",
"",
new Date("12/6/2009"),
"Second Sunday of Advent (Purple or Blue)",
"* Malachi 3:1-4",
"* Luke 1:68-79 (UMH 208)",
"* Philippians 1:3-11",
"* Luke 3:1-6",
"",
new Date("12/13/2009"),
"Third Sunday of Advent (Purple)",
"* Zephaniah 3:14-20",
"* Isaiah 12:2-6",
"* Philippians 4:4-7",
"* Luke 3:7-18",
"",
new Date("12/20/2009"),
"Fourth Sunday of Advent (Purple)",
"* Micah 5:2-5a",
"* Luke 1:46b-55 (UMH 199)",
"* Hebrews 10:5-10",
"* Luke 1:39-45",
"",
new Date("12/24/2009"),
"Christmas Eve (White or Gold)",
"* Isaiah 9:2-7",
"* Psalm 96 (UMH 815)",
"* Titus 2:11-14",
"* Luke 2:1-20",
"",
new Date("12/25/2009"),
"Christmas Day (White or Gold)",
"* Isaiah 52:7-10",
"* Psalm 98 (UMH 818)",
"* Hebrews 1:1-4 (5-12)",
"* John 1:1-14",
"",
new Date("12/27/2009"),
"First Sunday after Christmas Day (White or Gold)",
"* 1 Samuel 2:18-20, 26",
"* Psalm 148 (UMH 861)",
"* Colossians 3:12-17",
"* Luke 2:41-52",
"");

/* turn a set of the array's rows into an object */
function lectObj(date, desc, v1, v2, v3, v4, v5) {
  	this.date = date;
  	this.desc = desc;
  	this.v1 = v1;
  	this.v2 = v2;
  	this.v3 = v3;
  	this.v4 = v4;
  	this.v5 = v5;
}

var allLects = new Array(2);
var linesPerLect = 7; /* each day's lectionary gets this many lines in the array, even if some are blank */

if (lectNum < 0) { /* if the lectionary number we're passed doesn't make sense we'll look for the next one after the current date */
  currentDate = new Date();
  lectNum = 0;
  do {
    lectNum = lectNum + 1;
    /* create one day's object */
    var offset = (lectNum * linesPerLect);  /* find the spot in the array where the chosen day's lectionary begins */
    var oneDate = new Date(lect[offset]);
  } while (oneDate < currentDate);
}

var offset = (lectNum * linesPerLect);  /* find the spot in the array where the chosen day's lectionary begins */
var oneLect = new lectObj(lect[offset], lect[offset + 1], lect[offset + 2], lect[offset + 3], lect[offset + 4], lect[offset + 5], lect[offset + 6]);
/* the lecture object gets thrown into an array because the originial design called for all the objects to be available simultaneously */
allLects[lectNum] = oneLect;

/* turn the date as stored in the object into the pretty format to be displayed */
var prettyDate = allLects[lectNum].date;
var prettyYear = ((prettyDate.getYear() % 100) + 2000);
var monthNum = prettyDate.getMonth() + 1;
var monthStr = monthNumToWord(monthNum);
var dayNum = prettyDate.getDate();
var dayOfWeekNum = prettyDate.getDay() + 1;
var dayOfWeekStr = dayNumToWord(dayOfWeekNum);
var theDate = " " + dayOfWeekStr + ", " + monthStr + " " + dayNum + ", " + prettyYear;

/* display the day's lectionary */
document.getElementById('slideScreen').innerHTML = theDate + "<br>" + allLects[lectNum].desc + "<br><em>" + allLects[lectNum].v1 + "<br>" + allLects[lectNum].v2 + "<br>" + allLects[lectNum].v3 + "<br>" + allLects[lectNum].v4 + "<br>" + allLects[lectNum].v5 + "</em>";

/* show the control that allows moving forward and back days */
showSlideControl("loadLect",(lectNum+1),68,"Previous","Next"); /* lectNum +1 is because array starts at 0 but control at 1 */

}

function dayNumToWord(dayOfWeekNum) {
  var dayOfWeekStr = "Sunday";
  if (dayOfWeekNum == 1) {
  	dayOfWeekStr = "Sunday";
  } else if (dayOfWeekNum == 2) {
  	dayOfWeekStr = "Monday";
  } else if (dayOfWeekNum == 3) {
  	dayOfWeekStr = "Tuesday";
  } else if (dayOfWeekNum == 4) {
  	dayOfWeekStr = "Wednesday";
  } else if (dayOfWeekNum == 5) {
  	dayOfWeekStr = "Thursday";
  } else if (dayOfWeekNum == 6) {
  	dayOfWeekStr = "Friday";
  } else if (dayOfWeekNum == 7) {
  	dayOfWeekStr = "Saturday";
  }
  return dayOfWeekStr;
}

function monthNumToWord(monthNum) {
  var monthStr = "Month";
  if (monthNum == 1) {
  	monthStr = "January";
  } else if (monthNum == 2) {
  	monthStr = "February";
  } else if (monthNum == 3) {
 	monthStr = "March";
  } else if (monthNum == 4) {
  	monthStr = "April";
  } else if (monthNum == 5) {
  	monthStr = "May";
  } else if (monthNum == 6) {
  	monthStr = "June";
  } else if (monthNum == 7) {
  	monthStr = "July";
  } else if (monthNum == 8) {
  	monthStr = "August";
  } else if (monthNum == 9) {
  	monthStr = "September";
  } else if (monthNum == 10) {
  	monthStr = "October";
  } else if (monthNum == 11) {
  	monthStr = "November";
  } else if (monthNum == 12) {
  	monthStr = "December";
  }
  return monthStr;
}
