function popUpAll()
{
	var verses;
	var newPage = "<HTML> <HEAD> <TITLE> Robert Murray M'Cheyne's Daily Bible Reading Calendar</TITLE> </HEAD><BODY>";
	newPage = newPage + "<TABLE BORDER=1 CELLPADDING=6 WIDTH=100%><TR><TD ALIGN=CENTER COLSPAN=5>"
	newPage = newPage + "<B>Robert Murray M'Cheyne's Calendar for Daily Bible Readings</B></TD></TR>"

	for (var mon = 1; mon < 13; mon++ )
	{
		newPage = newPage + "<TR><TD ALIGN=CENTER COLSPAN=5>" + getMonthName(mon) + "</TD></TR>"
		newPage = newPage + "<TR><TD ALIGN=CENTER COLSPAN=2>Family</TD><TD ALIGN=CENTER>Date</TD>"
		newPage = newPage + "<TD ALIGN=CENTER COLSPAN=2>Secret</TD></TR>"
		{	for (var day = 1; day < (getDaysInMonth(mon) + 1); day++)
			{
				newPage = newPage + "<TR><TD ALIGN=CENTER>" + getFamily1(mon, day) + "</TD>";
				newPage = newPage + "<TD ALIGN=CENTER>" + getFamily2(mon, day) + "</TD>";
				newPage = newPage + "<TD ALIGN=CENTER>" + day + "</TD>";
				newPage = newPage + "<TD ALIGN=CENTER>" + getSecret1(mon, day) + "</TD>";
				newPage = newPage + "<TD ALIGN=CENTER>" + getSecret2(mon, day) + "</TD></TR>";
			}
		}
	}
	newPage = newPage + "</TABLE></BODY> </HTML>";
	
	popUpWindow(newPage);
}

function popUpWindow(newPage)
{
	var now = new Date(); 
	popup = window.open("","Window" + now.getTime() ,"menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,status=yes");
	popup.document.write(newPage);
	popup.document.close();
}

function initMe(form)
{
	var version = getCookie('version');
	var dateOpt = getCookie('dateOpt');
	var win = getCookie('win');

	if (version == null) version = 'NIV';
	if (dateOpt == null) dateOpt = 'CD';
	if (win == null) 
	{	win = 0;}
	else
	{	win = parseInt(win, 10);} // Change it to a number
	form.rdoWin[win].checked = true;

	form.selVersion.value = version;
	form.selDateOpt.value = dateOpt;
	dateOptChange(form);
	if (dateOpt == 'DT')
	{
		var month = getCookie('month');
		var day = getCookie('day');
		if ((month == null) || (day == null))
		{
			form.selDateOpt.value = 'CD';
			dateOptChange(form);
		}
		else
		{
			form.selMonth.value = month;
			form.selDay.value = day;
		}
	}

	setChkBox(form.chkXref, 'xref');
	setChkBox(form.chkFootNote, 'footNote');
	setChkBox(form.chkFamily1, 'family1');
	setChkBox(form.chkFamily2, 'family2');
	setChkBox(form.chkSecret1, 'secret1');
	setChkBox(form.chkSecret2, 'secret2');

	if (!(form.chkFamily1.checked || form.chkFamily2.checked || form.chkSecret1.checked || form.chkSecret2.checked))
	{	// Nothing is checked.  Check them all
		allClick(form);
	}
	
}

function setChkBox(chkBox, lookUpValue)
{
	var lookUp = getCookie(lookUpValue);
	
	if (lookUp == null)
	{
		lookUp = false;
	}
	else
	{
		// The cookie returns a string.  Change it to a boolean.
		lookUp = (lookUp != 'false');
	}
	chkBox.checked = lookUp;
}

function getMonthValue(form)
{
  return form.selMonth[form.selMonth.selectedIndex].value;
}

function getDayValue(form)
{
  return form.selDay[form.selDay.selectedIndex].value;
}

function getDateOptValue(form)
{
  return form.selDateOpt[form.selDateOpt.selectedIndex].value;
}

function getVersionValue(form)
{
  return form.selVersion[form.selVersion.selectedIndex].value;
}

function dateOptChange(form)
{
	var temp;
	var day;
  var mon;
  var dateOpt = getDateOptValue(form); 
  var today  = new Date();
  if (dateOpt == 'DT') /* Date */
  {
    return; /* Nothing to do */
  }
  else if (dateOpt == 'CD') /* Current Date */ 
  {
		mon = (today.getMonth() + 1);
    day = today.getDate();
  }
  else if (dateOpt == 'PD') /* Prior Date */
  {
		day = today.getDate();
		mon = (today.getMonth() + 1);
    day = day - 1;
    if (day == 0) 
	{
	  mon = mon - 1;
    if (mon == 0)
	  {
	    mon = 12;
	  }
	  day = getDaysInMonth(mon);
    }
  }
  else if (dateOpt == 'ND') /* Next Date */
  {
		day = today.getDate();
		mon = (today.getMonth() + 1);
    day = day + 1;
    if (day > getDaysInMonth(mon)) 
		{
			mon = mon + 1;
      if (mon > 12)
			{
				mon = 1;
			}
			day = 1;
    }
  }
	setIndex(form.selMonth, mon);
  setIndex(form.selDay, day);
  // Now set the number of days for the month
  setDaysInMonth(form);
}

function setIndex(list, value)
{
	var found = 0;	// Default value
	for (var i = 0; i < list.length ; i++ )
	{
		if (list[i].value == value)
		{
			found = i;
			break;
		}
	}
	list.options[found].selected = true;
}

function getMonthName(mon)
{
  var monthName = new Array(12);
  monthName[1] = "January";
  monthName[2] = "February";
  monthName[3] = "March";
  monthName[4] = "April";
  monthName[5] = "May";
  monthName[6] = "June";
  monthName[7] = "July";
  monthName[8] = "August";
  monthName[9] = "September";
  monthName[10] = "October";
  monthName[11] = "November";
  monthName[12] = "December";

	return monthName[mon];
}

function getDaysInMonth(mon)
{
  var daysInMonth = new Array(12);
  daysInMonth[1] = 31;
  daysInMonth[2] = 28;
  daysInMonth[3] = 31;
  daysInMonth[4] = 30;
  daysInMonth[5] = 31;
  daysInMonth[6] = 30;
  daysInMonth[7] = 31;
  daysInMonth[8] = 31;
  daysInMonth[9] = 30;
  daysInMonth[10] = 31;
  daysInMonth[11] = 30;
  daysInMonth[12] = 31;
  var today  = new Date();
  var year = today.getYear();
  if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
  {
    daysInMonth[2] = 29;
  }
  return daysInMonth[mon];
}

function monthChange(form)
{
	setDaysInMonth(form);
  setIndex(form.selDateOpt, 'DT');
}

function dayChange(form)
{
  setIndex(form.selDateOpt, 'DT');
}

function setDaysInMonth(form)
{
	var mon = getMonthValue(form);
  var daysInMonth = getDaysInMonth(mon);
  while (form.selDay.length > daysInMonth)
  {
    deleteOption(form.selDay, (form.selDay.length - 1));
  }
  for (var i = form.selDay.length + 1; i <= daysInMonth; i++)
  {
    addOption(form.selDay, i, i);
  }
}

function deleteOption(object, index)
{
  object.options[index] = null;
}

function addOption(object, text, value)
{
  if (text == null || text == '')
  {
    return;
  }
  var optionName = new Option(text, value);
  object.options[object.length] = optionName;
}

function versionChange(form)
{
  var ver = getVersionValue(form);
  if (ver != 'NASB')
  {
	  form.chkXref.checked = false
  }
  if ((ver != 'NASB') && (ver != 'NIV'))
  {
	  form.chkFootNote.checked = false;
  }
}

function xrefClick(form)
{
  var ver = getVersionValue(form);
  if (ver != 'NASB')
  {
    alert("'Show Cross Reference' is only available for NASB version.");
	  form.chkXref.checked = false;
  }
}

function footNoteClick(form)
{
  var ver = getVersionValue(form);
  if ((ver != 'NASB') && (ver != 'NIV') )
  {
    alert("'Show Footnotes' is only available for NIV or NASB version.");
	  form.chkFootNote.checked = false;
  }
}

function getChkFootNote(form)
{	if (form.chkFootNote.checked)
	{	return "yes";}
	else
	{	return "no";}
}

function getChkXref(form)
{	if (form.chkXref.checked)
	{	return "yes";}
	else
	{	return "no";}
}

function displayReading(form, verses, offset)
{
  var site = "http://bible.gospelcom.net/bible?language=English&version=";
  var ver = getVersionValue(form);
  var opts = "";
	var top = 50 * offset;
	var left = 50 * offset;

 	var now = new Date(); 

  verses = "&passage=" + verses;

	opts = "&showfn=" + getChkFootNote(form);
	opts = opts + "&showxref=" + getChkXref(form);

  open(site + ver + opts + verses,"Window" + now.getTime(),"menubar=yes,toolbar=yes,width=500,height=400,top=" + top + ",left=" + left + ",resizable=yes,scrollbars=yes,status=yes");
}

function getRead(form)
{	var offset = 0;
	if (!(form.chkFamily1.checked || form.chkFamily2.checked || form.chkSecret1.checked || form.chkSecret2.checked))
	{	alert("Please choose which readings you would like (Family 1, Family 2, Secret 1, Secret 2).")
		return;
	}

	saveOpts(form);

  var mon = getMonthValue(form);
  var day = getDayValue(form);
	var verses = "";

  if (form.chkFamily1.checked)
  { verses = getFamily1(mon, day);
		if (form.rdoWin[1].checked)		// Display all in their own window
		{	displayReading(form, verses, offset++);
			verses = "";
		}
		else	// Display all in one window
		{	verses = verses + ";"}
	}
  if (form.chkFamily2.checked)
  { verses = verses + getFamily2(mon, day);
		if (form.rdoWin[1].checked)		// Display all in their own window
		{	displayReading(form, verses, offset++);
			verses = "";
		}
		else	// Display all in one window
		{	verses = verses + ";"}
	}

  if (form.chkSecret1.checked)
  { verses = verses + getSecret1(mon, day);
		if (form.rdoWin[1].checked)		// Display all in their own window
		{	displayReading(form, verses, offset++);
			verses = "";
		}
		else	// Display all in one window
		{	verses = verses + ";"}
	}

	if (form.chkSecret2.checked)
  { verses = verses + getSecret2(mon, day);
		if (form.rdoWin[1].checked)		// Display all in their own window
		{	displayReading(form, verses, offset++);
			verses = "";
		}
		else	// Display all in one window
		{	verses = verses + ";"}
	}

	if (form.rdoWin[0].checked)		// Now Display all in their own window
	{	displayReading(form, verses, offset++);}
}

function saveOpts(form)
{
	// Expire the cookie in 30 days
	var day;
	var month;
	var win;
	var expDays = 30;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
	
	setCookie('version', getVersionValue(form), exp);
	setCookie('dateOpt', getDateOptValue(form), exp);
	setCookie('xref', form.chkXref.checked, exp);
	setCookie('footNote', form.chkFootNote.checked, exp);
	setCookie('family1', form.chkFamily1.checked, exp);
	setCookie('family2', form.chkFamily2.checked, exp);
	setCookie('secret1', form.chkSecret1.checked, exp);
	setCookie('secret2', form.chkSecret2.checked, exp);

	if (form.rdoWin[0].checked)
	{	win = 0;}
	else
	{	win = 1;}
	setCookie('win', win, exp);

	if (getDateOptValue(form) == 'DT')
	{
		day = getDayValue(form);
		month = getMonthValue(form);
	}
	else
	{
		day = null;
		month = null;
	}
	setCookie('day', day, exp);
	setCookie('month', month, exp);
}

function allClick(form)
{
	if (form.chkFamily1.checked && form.chkFamily2.checked && form.chkSecret1.checked && form.chkSecret2.checked)
	{
		form.chkFamily1.checked = false;
		form.chkFamily2.checked = false;
		form.chkSecret1.checked = false;
		form.chkSecret2.checked = false;
	}
	else
	{
		form.chkFamily1.checked = true;
		form.chkFamily2.checked = true;
		form.chkSecret1.checked = true;
		form.chkSecret2.checked = true;
	}
}

function familyClick(form)
{
	if (form.chkFamily1.checked && form.chkFamily2.checked)
	{
		form.chkFamily1.checked = false;
		form.chkFamily2.checked = false;
	}
	else
	{
		form.chkFamily1.checked = true;
		form.chkFamily2.checked = true;
	}
}

function secretClick(form)
{
	if (form.chkSecret1.checked && form.chkSecret2.checked)
	{
		form.chkSecret1.checked = false;
		form.chkSecret2.checked = false;
	}
	else
	{
		form.chkSecret1.checked = true;
		form.chkSecret2.checked = true;
	}
}

function oneClick(form)
{
	if (form.chkFamily1.checked && form.chkSecret1.checked)
	{
		form.chkFamily1.checked = false;
		form.chkSecret1.checked = false;
	}
	else
	{
		form.chkFamily1.checked = true;
		form.chkSecret1.checked = true;
	}
}

function twoClick(form)
{
	if (form.chkFamily2.checked && form.chkSecret2.checked)
	{
		form.chkFamily2.checked = false;
		form.chkSecret2.checked = false;
	}
	else
	{
		form.chkFamily2.checked = true;
		form.chkSecret2.checked = true;
	}
}

function getFamily1(mon, day)
{ 
  mon = parseInt(mon, 10);
  day = parseInt(day, 10);
  var book; 
  var num;  
  
  if (mon == 1) // Jan
  {
    book = "Genesis+";
    if (day < 9)
    { num = day;}
    else if (day == 9) 
    { num = "9-10";  }
    else
    { num = day + 1;}
  }
  else if (mon == 2) // Feb
  {
    if (day < 18)
    { book = "Genesis+";}
    else
    { book = "Exodus+";}

    if (day < 3)
    { num = day + 32;}
    else if (day == 3)
    { num = "35-36";}
    else if (day < 18)
    { num = day + 33;}
    else if (day < 28)
    { num = day - 17;} 
    else // 28 feb
    { num = "11:1-Exodus+12:21";}
  }
  else if (mon == 3) // March
  {
    if (day < 30)
    { book = "Exodus+";}
    else
    { book = "Leviticus+";}

    if (day == 1)
    { num = "12:22-Exodus+12:51";}
    else if (day < 30)
    { num = day + 11;}
    else if (day == 30)
    { num = 1;
    }
    else // 31st
    { num = "2-3"; }
  }
  else if (mon == 4) // Apr
  {
    if (day < 24)
    { book = "Leviticus+";}
    else
    { book = "Numbers+";}
   
    if (day < 8)
    { num = day + 3}
    else if (day == 8)
    { num = "11-12";}
    else if (day < 24)
    { num = day + 4}
    else
    { num = day - 23}
  }
  else if (mon == 5) // May
  {
    if (day < 28)
    { book = "Numbers+";}
    else
    { book = "Deuteronomy+";}
   
    if (day < 5)
    { num = day + 7}
    else if (day == 5)
    { num = "12-13";}
    else if (day < 9)
    { num = day + 8}
    else if (day == 9)
    { num = "17-18";}
    else if (day < 28)
    { num = day + 9;}
    else
    { num = day - 27}
  }
  else if (mon == 6) // Jun
  {
    if (day < 29)
    { book = "Deuteronomy+";}
    else
    { book = "Joshua+";}
   
    if (day < 9)
    { num = day + 4}
    else if (day == 9)
    { num = "13-14";}
    else if (day < 22)
    { num = day + 5}
    else if (day == 22)
    { num = "27:1-Deuteronomy+28:19";}
    else if (day == 23)
    { num = "28:20-Deuteronomy+28:68";}
    else if (day < 28)
    { num = day + 5;}
    else if (day == 28)
    { num = "33-34";}
    else
    { num = day - 28}
  }
  else if (mon == 7) // Jul
  {
    if (day < 18)
    { book = "Joshua+";}
    else
    { book = "Judges+";}
   
    if (day < 3)
    { num = day + 2}
    else if (day == 3)
    { num = "5:1-Joshua+6:5";}
    else if (day == 4)
    { num = "6:6-Joshua+6:27";}
    else if (day < 10)
    { num = day + 2}
    else if (day == 10)
    { num = "12-13";}
    else if (day ==11)
    { num = "14-15";}
    else if (day == 12)
    { num = "16-17";}
    else if (day == 13)
    { num = "18-19";}
    else if (day == 14)
    { num = "20-21";}

    else if (day < 18)
    { num = day + 7;}
    else if (day < 27)
    { num = day - 17;}
    else if (day == 27)
    { num = "10:1-Judges+11:11";}
    else if (day == 28)
    { num = "11:12-Judges+11:40";}
    else
    { num = day - 17;}
  }
  else if (mon == 8) // Aug
  { if (day < 8)
    { book = "Judges+";}
    else if (day < 11)
    { book = "Ruth+";}
    else
    { book = "1Samuel+";}
   
    if (day < 8)
    { num = day + 14}
    else if (day < 10)
    { num = day - 7;}
    else if (day == 10)
    { num = "3-4";}
    else if (day < 15)
    { num = day - 10}
    else if (day == 15)
    { num = "5-6";}
    else if (day == 16)
    { num = "7-8";}
    else if (day < 29)
    { num = day - 8;}
    else if (day == 29)
    { num = "21-22";}
    else
    { num = day - 7}
  }
  else if (mon == 9) // Sep
  {
    if (day < 7)
    { book = "1Samuel+";}
    else if (day < 29)
    { book = "2Samuel+";}
    else
    { book = "1Kings+";}
   
    if (day < 5)
    { num = day + 24}
    else if (day == 5)
    { num = "29-30";}
    else if (day == 6)
    { num = 31;}
    else if (day < 10)
    { num = day - 6}
    else if (day == 10)
    { num = "4-5";}
    else if (day < 13)
    { num = day - 5;}
    else if (day == 13)
    { num = "8-9";}
    else if (day < 29)
    { num = day - 4;}
    else
    { num = day - 28}
  }
  else if (mon == 10) // Oct
  {
    if (day < 20)
    { book = "1Kings+";}
    else
    { book = "2Kings+";}
   
    if (day == 1)
    { num = 3}
    else if (day == 2)
    { num = "4-5";}
    else if (day < 20)
    { num = day + 3;}
    else if (day < 30)
    { num = day - 19}
    else if (day == 30)
    { num = "11-12";}
    else
    { num = 13}
  }
  else if (mon == 11) // Nov
  {
    if (day < 13)
    { book = "2Kings+";}
    else
    { book = "1Chronicles+";}
   
    if (day < 13)
    { num = day + 13}
    else if (day == 13)
    { num = "1-2";}
    else if (day == 14)
    { num = "3-4";}
    else if (day == 15)
    { num = "5-6";}
    else if (day == 16)
    { num = "7-8";}
    else if (day == 17)
    { num = "9-10";}
    else if (day == 18)
    { num = "11-12";}
    else if (day == 19)
    { num = "13-14";}
    else if (day < 24)
    { num = day - 5;}
    else if (day == 24)
    { num = "19-20";}
    else if (day < 28)
    { num = day - 4;}
    else if (day == 28)
    { num = "24-25";}
    else if (day == 29)
    { num = "26-27";}
    else
    { num = 28;}
  }
  else // Dec
  {
    if (day == 1)
    { book = "1Chronicles+";}
    else
    { book = "2Chronicles+";}
   
    if (day == 1)
    { num = 29}
    else if (day < 4)
    { num = day - 1}
    else if (day == 4)
    { num = "3-4";}
    else if (day == 5)
    { num = "5:1-2Chron+6:11";}
    else if (day == 6)
    { num = "6:12-2Chron+6:42";}
    else if (day < 11)
    { num = day;}
    else if (day == 11)
    { num = "11-12";}
    else if (day == 12)
    { num = 13;}
    else if (day == 13)
    { num = "14-15";}
    else if (day < 17)
    { num = day + 2;}
    else if (day == 17)
    { num = "19-20";}
    else if (day == 18)
    { num = 21;}
    else if (day == 19)
    { num = "22-23";}
    else if (day < 23)
    { num = day + 4;}
    else if (day == 23)
    { num = "27-28";}
    else
    { num = day + 5;}
  }
  return book + num; 
}

function getFamily2(mon, day)
{ 
  mon = parseInt(mon, 10);
  day = parseInt(day, 10);
  var book; 
  var num;  
  
  if (mon == 1) // Jan
  {
    if (day < 29)
    { book = "Matthew+";
      num = day;
    }
    else
    { book = "Mark+";
      num = day - 28;
    }
  }
  else if (mon == 2) // Feb
  {
    if (day < 14)
    { book = "Mark+";}
    else
    { book = "Luke+";}

    if (day < 14)
    { num = day + 3;}
    else if (day == 14)
    { num = "1:1-Luke+1:38";}
    else if (day == 15)
    { num = "1:39-Luke+1:80";}
    else 
    { num = day - 14;}
  }
  else if (mon == 3) // Mar
  {
    if (day < 11)
    { book = "Luke+";
      num = day + 14;
    }
    else
    { book = "John+";
      num = day - 10;
    }
  }
  else if (mon == 4) // Apr
  {
    book = "Psalms+";
    if (day == 1) 
    { num = "1-2";}  
    else if (day == 2) 
    { num = "3-4";}  
    else if (day == 3)
    { num = "5-6";}
    else if (day == 4)
    { num = "7-8";}
    else if (day < 7)
    { num = day + 4;}
    else if (day == 7)
    { num = "11-12";}
    else if (day == 8)
    { num = "13-14";}
    else if (day == 9)
    { num = "15-16";}
    else if (day < 13)
    { num = day + 7;}
    else if (day == 13)
    { num = "20-21";}
    else if (day == 14)
    { num = 22}
    else if (day == 15)
    { num = "23-24";}
    else if (day == 16)
    { num = 25}
    else if (day == 17)
    { num = "26-27";}
    else if (day == 18)
    { num = "28-29";}
    else if (day < 29)
    { num = day + 11;}
    else if (day == 29)
    { num = "40-41";}
    else
    { num = "42-43";}
  }
  else if (mon == 5) // May
  {
    book = "Psalms+";
    if (day < 3) 
    { num = day + 43;}  
    else if (day == 3) 
    { num = "46-47";}  
    else if (day < 8)
    { num = day + 44;}
    else if (day == 8)
    { num = "52-54";}
    else if (day < 10)
    { num = day + 46;}
    else if (day == 10)
    { num = "56-57";}
    else if (day == 11)
    { num = "58-59";}
    else if (day == 12)
    { num = "60-61";}
    else if (day == 13)
    { num = "62-63";}
    else if (day == 14)
    { num = "64-65";}
    else if (day == 15)
    { num = "66-67"}
    else if (day < 18)
    { num = day + 52;}
    else if (day == 18)
    { num = "70-71"}
    else if (day < 22)
    { num = day + 53;}
    else if (day == 22)
    { num = "75-76";}
    else if (day < 24)
    { num = day + 54;}
    else if (day == 24)
    { num = "78:1-Psalms+78:37";}
    else if (day == 25)
    { num = "78:38-Psalms+78:72";}
    else if (day < 28)
    { num = day + 53;}
    else if (day == 28)
    { num = "81-82";}
    else if (day == 29)
    { num = "83-84";}
    else if (day < 31)
    { num = day + 55;}
    else
    { num = "86-87";}
  }
  else if (mon == 6) // Jun
  {
    book = "Psalms+";
    if (day < 5) 
    { num = day + 87;}  
    else if (day == 5) 
    { num = "92-93";} 
    else if (day < 7)
    { num = day + 88;}
    else if (day == 7)
    { num = "95-96";}
    else if (day == 8)
    { num = "97-98";}
    else if (day == 9)
    { num = "99-101";}
    else if (day < 16)
    { num = day + 92;}
    else if (day == 16)
    { num = "108-109";}
    else if (day == 17)
    { num = "110-111";}
    else if (day == 18)
    { num = "112-113";}
    else if (day == 19)
    { num = "114-115";}
    else if (day < 21)
    { num = day + 96;}
    else if (day == 21)
    { num = "117-118";}
    else if (day == 22)
    { num = "119:1-Psalms+119:24";}
    else if (day == 23)
    { num = "119:25-Psalms+119:48";}
    else if (day == 24)
    { num = "119:49-Psalms+119:72";}
    else if (day == 25)
    { num = "119:73-Psalms+119:96";}
    else if (day == 26)
    { num = "119:97-Psalms+119:120";}
    else if (day == 27)
    { num = "119:121-Psalms+119:144";}
    else if (day == 28)
    { num = "119:145-Psalms+119:176";}
    else if (day == 29)
    { num = "120-122";}
    else // 30th
    { num = "123-125";}
  }
  else if (mon == 7) // Jul
  {
    if (day < 14)
    { book = "Psalms+";}
    else
    { book = "Acts+";}

    if (day == 1) 
    { num = "126-128";}
    else if (day == 2)
    { num = "129-131";}
    else if (day == 3)
    { num = "132-134";}
    else if (day == 4)
    { num = "135-136";}
    else if (day == 5)
    { num = "137-138";}
    else if (day == 6)
    { num = 139;}
    else if (day == 7)
    { num = "140-141";}
    else if (day == 8)
    { num = "142-143";}
    else if (day < 11)
    { num = day + 135;}
    else if (day == 11)
    { num = "146-147";}
    else if (day == 12)
    { num = 148;}
    else if (day == 13)
    { num = "149-150";}
    else 
    { num = day - 13;}
  }
  else if (mon == 8) // Aug
  {
    if (day < 11)
    { book = "Acts+";
      num = day + 18;
    }
    else if (day < 27)
    { book = "Romans+";
      num = day - 10;
    }
    else
    { book = "1Corinthians+";
      num = day - 26;
    }
  }
  else if (mon == 9) // Sep
  {
    if (day < 12)
    { book = "1Corinthians+";
      num = day + 5;
    }
    else if (day < 25)
    { book = "2Corinthians+";
      num = day - 11;
    }
    else
    { book = "Galatians+";
      num = day - 24;
    }
  }
  else if (mon == 10) // Oct
  {
    if (day < 7)
    { book = "Ephesians+";
      num = day;
    }
    else if (day < 11)
    { book = "Philippians+";
      num = day - 6;
    }
    else if (day < 15)
    { book = "Colossians+";
      num = day - 10;
    }
    else if (day < 20)
    { book = "1Thessalonians+";
      num = day - 14;
    }
    else if (day < 23)
    { book = "2Thessalonians+";
      num = day - 19;
    }
    else if (day < 29)
    { book = "1Timothy+";
      num = day - 22;
    }
    else
    { book = "2Timothy+";
      num = day - 28;
    }
  }
  else if (mon == 11) // Nov
  {
    if (day == 1)
    { book = "2Timothy+";
      num = 4;
    }
    else if (day < 5)
    { book = "Titus+";
      num = day - 1;
    }
    else if (day == 5)
    { book = "Philemon+";
      num = 1;
    }
    else if (day < 19)
    { book = "Hebrews+";
      num = day - 5;
    }
    else if (day < 24)
    { book = "James+";
      num = day - 18;
    }  
    else if (day < 29)
    { book = "1Peter+";
      num = day - 23;
    }
    else
    { book = "2Peter+";
      num = day - 28;
    }
  }
  else // December
  { if (day == 1)
    { book = "2Peter+";
      num = 3;
    }
    else if (day < 7)
    { book = "1John+";
      num = day - 1;
    }
    else if (day == 7)
    { book = "2John+";
      num = 1;
    }
    else if (day == 8)
    { book = "3John+";
      num = 1;
    }
    else if (day == 9)
    { book = "Jude+";
      num = 1;
    }
    else
    { book = "Revelation+";
      num = day - 9;
    }
  }
  return book + num; 
}

function getSecret1(mon, day)
{ 
  mon = parseInt(mon, 10);
  day = parseInt(day, 10);
  var book; 
  var num;  

	if (mon == 1)	// Jan
	{
		if (day < 11)
		{	book = "Ezra+";
			num = day;
		}
		else if (day < 24)
		{	book = "Nehemiah+";
			num = day - 10;
		}
		else 
		{	book = "Esther+";
			num = day - 23;
		}
	}
	else if (mon == 2) // Feb
	{	
		if (day == 1)
		{	book = "Esther+";}
		else
		{	book = "Job+";}

		if (day == 1)
		{	num = "9-10";}
		else if (day < 17)
		{	num = day - 1;}
		else if (day == 17)
		{	num = "16-17";}
		else if (day < 25)
		{	num = day;}
		else if (day == 25)
		{	num = "25-26";}
		else 
		{	num = day + 1;}
	}
	else if (mon == 3)	// Mar
	{
		if (day < 14)
		{	book = "Job+";
			num = day + 29;
		}
		else 
		{	book = "Proverbs+";
			num = day - 13;
		}
	}
	else if (mon == 4)	// Apr
	{
		if (day < 14)
		{	book = "Proverbs+";
			num = day + 18;
		}
		else if (day < 26)
		{	book = "Ecclesiastes+";
			num = day - 13;
		}
		else 
		{	book = "Song+";
			num = day - 25;
		}
	}
	else if (mon == 5)
	{
		if (day < 4)
		{	book = "Song+";}
		else
		{	book = "Isaiah+";}

		if (day < 4)
		{	num = day + 5;}
		else if (day < 6)
		{	num = day - 3;}
		else if (day == 6)
		{	num = "3-4";}
		else if (day < 10)
		{	num = day - 2;}
		else if (day == 10)
		{	num = "8:1-Isaiah+9:7";}
		else if (day == 11)
		{	num =	"9:8-Isaiah+10:4";}
		else if (day == 12)
		{	num = "10:5-Isaiah+10:34";}
		else if (day == 13)
		{ num = "11-12";}
		else if (day < 18)
		{	num = day - 1;}
		else if (day == 18)
		{	num = "17-18";}
		else if (day == 19)
		{	num = "19-20";}
		else
		{	num = day + 1;}
	}
	else if (mon == 6)	// Jun
	{	book = "Isaiah+";
		num = day + 32;
	}
	else if (mon == 7)	// Jul
	{	
		if (day < 5)
		{	book = "Isaiah+";
			num = day + 62;
		}
		else 
		{	book = "Jeremiah+";
			num = day - 4;
		}
	}
	else if (mon == 8)	// Aug
	{
		if (day < 24)
		{	book = "Jeremiah+";}
		else if (day < 29)
		{	book = "Lamentations+";}
		else
		{	book = "Ezekiel+";}

		if (day < 3)
		{	num = day + 27;}
		else if (day == 3)
		{	num = "30-31";}
		else if (day < 8)
		{	num = day + 28;}
		else if (day == 8)
		{	num = "36,Jeremiah+45";}
		else if (day < 17)
		{	num = day + 28;}
		else if (day < 24)
		{	num = day + 29;}
		else if (day < 29)
		{	num = day - 23;}
		else 
		{	num = day - 28;}
	}
	else if (mon == 9)	// Sep
	{	book = "Ezekiel+";
		num = day + 3;
	}
	else if (mon == 10)	// Oct
	{	
		if (day < 16)
		{	book = "Ezekiel+";}
		else if (day < 28)
		{	book = "Daniel+";}
		else
		{	book = "Hosea+";}

		if (day < 16)
		{	num = day + 33;}
		else if (day < 28)
		{	num = day - 15;}
		else if (day < 30)
		{	num = day - 27;}
		else if (day == 30)
		{	num = "3-4";}
		else
		{	num = "5-6";}
	}
	else if (mon == 11)	// Nov
	{
		if (day < 9)
		{	book = "Hosea+";
			num = day + 6;
		}
		else if (day < 12)
		{	book = "Joel+";
			num = day - 8;
		}
		else if (day < 21)
		{	book = "Amos+";
			num = day - 11;
		}
		else if (day == 21)
		{	book = "Obadiah+";
			num = 1;
		}
		else if (day < 26)
		{	book = "Jonah+";
			num = day - 21;
		}
		else 
		{	book = "Micah+";
			num = day - 25;
		}
	}
	else if (mon == 12)	// Dec
	{
		if (day < 3)
		{	book = "Micah+";}
		else if (day < 6)
		{	book = "Nahum+";}
		else if (day < 9)
		{	book = "Habakkuk+";}
		else if (day < 12)
		{	book = "Zephaniah+";}
		else if (day < 14)
		{	book = "Haggai+";}
		else if (day < 28)
		{	book = "Zechariah+";}
		else 
		{	book = "Malachi+";}

		if (day < 3)
		{	num = day + 5;}
		else if (day < 6)
		{	num = day - 2;}
		else if (day < 9)
		{	num = day - 5;}
		else if (day < 12)
		{	num = day - 8;}
		else if (day < 14)
		{	num = day - 11;}
		else if (day < 25)
		{	num = day - 13;}
		else if (day == 25)
		{	num = "12:1-Zechariah+13:1";}
		else if (day == 26)
		{	num = "13:2-Zechariah+13:9";}
		else if (day == 27)
		{	num = 14;}
		else 
		{	num = day - 27;}
	}

  return book + num; 
}

function getSecret2(mon, day)
{ 
  mon = parseInt(mon, 10);
  day = parseInt(day, 10);
  var book; 
  var num;  

	if (mon == 1)	// Jan
	{
		if (day < 29)
		{	book = "Acts+";
			num = day;
		}
		else
		{	book = "Romans+";
			num = day - 28;
		}
	}
	else if (mon == 2)	// Feb
	{
		if (day < 14)
		{	book = "Romans+";
			num = day + 3;
		}
		else
		{	book = "1Corinthians+";
			num = day - 13;
		}
	}
	else if (mon == 3)
	{
		if (day < 2)
		{	book = "1Corinthians+";
			num = day + 15;
		}
		else if (day < 15)
		{	book = "2Corinthians+";
			num = day - 1;
		}
		else if (day < 21)
		{	book = "Galatians+";
			num = day - 14;
		}
		else if (day < 27)
		{	book = "Ephesians+";
			num = day - 20;
		}
		else if (day < 31)
		{	book = "Philippians+";
			num = day - 26;
		}
		else	// 31st
		{	book = "Colossians+";
			num = 1;
		}
	}
	else if (mon == 4)	// Apr
	{
		if (day < 4)
		{	book = "Colossians+";
			num = day + 1;
		}
		else if (day < 9)
		{	book = "1Thessalonians+";
			num = day - 3;
		}
		else if (day < 12)
		{	book = "2Thessalonians+";
			num = day - 8;
		}
		else if (day < 18)
		{	book = "1Timothy+";
			num = day - 11;
		}
		else if (day < 22)
		{	book = "2Timothy+";
			num = day - 17;
		}
		else if (day < 25)
		{	book = "Titus+";
			num = day - 21;
		}
		else if (day == 25)
		{	book = "Philemon+";
			num = 1;
		}
		else 
		{	book = "Hebrews+";
			num = day - 25;
		}
	}
	else if (mon == 5)	// May
	{
		if (day < 9)
		{	book = "Hebrews+";
			num = day + 5;
		}
		else if (day < 14)
		{	book = "James+";
			num = day - 8;
		}
		else if (day < 19)
		{	book = "1Peter+";
			num = day - 13;
		}
		else if (day < 22)
		{	book = "2Peter+";
			num = day - 18;
		}
		else if (day < 27)
		{	book = "1John+";
			num = day - 21;
		}
		else if (day == 27)
		{	book = "2John+";
			num = 1;
		}
		else if (day == 28)
		{	book = "3John+";
			num = 1;
		}
		else if (day == 29)
		{	book = "Jude+";
			num = 1;
		}
		else
		{	book = "Revelation+";
			num = day - 29;
		}
	}
	else if (mon == 6)
	{	
		if (day < 21)
		{	book = "Revelation+";
			num = day + 2;
		}
		else
		{
			book = "Matthew+";
			num = day - 20;
		}
	}
	else if (mon == 7)
	{
		if (day < 19)
		{	book = "Matthew+";
			num = day + 10;
		}
		else
		{	book = "Mark+";
			num = day - 18;
		}
	}
	else if (mon == 8)
	{
		if (day < 4)
		{	book = "Mark+";}
		else
		{	book = "Psalm+";}

		if (day < 4)
		{	num = day + 13;}
		else if (day == 4)
		{	num = "1-2"}
    else if (day == 5) 
    { num = "3-4";}  
    else if (day == 6)
    { num = "5-6";}
    else if (day == 7)
    { num = "7-8";}
    else if (day < 10)
    { num = day + 1;}
    else if (day == 10)
    { num = "11-12";}
    else if (day == 11)
    { num = "13-14";}
    else if (day == 12)
    { num = "15-16";}
    else if (day < 16)
    { num = day + 4;}
    else if (day == 16)
    { num = "20-21";}
    else if (day == 17)
    { num = 22}
    else if (day == 18)
    { num = "23-24";}
    else if (day == 19)
    { num = 25}
    else if (day == 20)
    { num = "26-27";}
    else if (day == 21)
    { num = "28-29";}
    else
    { num = day + 8;}
	}
	else if (mon == 9)	// Sep
	{
		book = "Psalms+";
    if (day == 1)
    { num = "40-41";}
    else if (day == 2)
    { num = "42-43";}
    else if (day < 5) 
    { num = day + 41;}  
    else if (day == 5) 
    { num = "46-47";}  
    else if (day < 10)
    { num = day + 42;}
    else if (day == 10)
    { num = "52-54";}
    else if (day == 11)
    { num = 55;}
    else if (day == 12)
    { num = "56-57";}
    else if (day == 13)
    { num = "58-59";}
    else if (day == 14)
    { num = "60-61";}
    else if (day == 15)
    { num = "62-63";}
    else if (day == 16)
    { num = "64-65";}
    else if (day == 17)
    { num = "66-67"}
    else if (day < 20)
    { num = day + 50;}
    else if (day == 20)
    { num = "70-71"}
    else if (day < 24)
    { num = day + 51;}
    else if (day == 24)
    { num = "75-76";}
    else if (day == 25)
    { num = 77;}
    else if (day == 26)
    { num = "78:1-Psalms+78:37";}
    else if (day == 27)
    { num = "78:38-Psalms+78:72";}
    else if (day < 30)
    { num = day + 51;}
    else
    { num = "81-82";}
	}
	else if (mon == 10)	// Oct
	{
		book = "Psalms+";
		if (day == 1)
    { num = "83-84";}
    else if (day < 4)
    { num = day + 83;}
    else if (day == 4)
    { num = "87-88";}
		else if (day < 8)
		{	num = day + 84}
		else if (day == 8)
		{ num = "92-93";} 
    else if (day == 9)
    { num = 94;}
    else if (day == 10)
    { num = "95-96";}
    else if (day == 11)
    { num = "97-98";}
    else if (day == 12)
    { num = "99-101";}
    else if (day < 19)
    { num = day + 89;}
    else if (day == 19)
    { num = "108-109";}
    else if (day == 20)
    { num = "110-111";}
    else if (day == 21)
    { num = "112-113";}
    else if (day == 22)
    { num = "114-115";}
    else if (day == 23)
    { num = 116;}
    else if (day == 24)
    { num = "117-118";}
    else if (day == 25)
    { num = "119:1-Psalms+119:24";}
    else if (day == 26)
    { num = "119:25-Psalms+119:48";}
    else if (day == 27)
    { num = "119:49-Psalms+119:72";}
    else if (day == 28)
    { num = "119:73-Psalms+119:96";}
    else if (day == 29)
    { num = "119:97-Psalms+119:120";}
    else if (day == 30)
    { num = "119:121-Psalms+119:144";}
    else
    { num = "119:145-Psalms+119:176";}
	}
	else if (mon == 11)
	{	if (day < 16)
		{	book = "Psalms+";}
		else
		{	book = "Luke+";}

		if (day == 1)
    { num = "120-122";}
    else if (day == 2)
    { num = "123-125";}
		else if (day == 3) 
    { num = "126-128";}
    else if (day == 4)
    { num = "129-131";}
    else if (day == 5)
    { num = "132-134";}
    else if (day == 6)
    { num = "135-136";}
    else if (day == 7)
    { num = "137-138";}
    else if (day == 8)
    { num = 139;}
    else if (day == 9)
    { num = "140-141";}
    else if (day < 14)
    { num = day + 132;}
    else if (day == 14)
    { num = "146-147";}
    else if (day == 15)
    { num = "148-150";}
		else if (day == 16)
		{	num = "1:1-Luke+1:38";}
		else if (day == 17)
		{	num = "1:39-Luke+1:80";}
		else 
		{	num = day - 16;}
	}
	else	// Dec
	{
		if (day < 11)
		{	book = "Luke+";
			num = day + 14;
		}
		else 
		{
			book = "John+";
			num = day - 10;
		}
	}

  return book + num; 
}

function buildBibleReading(form) 
{
		document.write("<FORM NAME=frmCalendar>");
		document.write("<TABLE BORDER=1 CELLPADDING=6 WIDTH=100%>");
		document.write("<TR>");
		document.write("  <TD ALIGN=CENTER COLSPAN=4>	");
		document.write("    <FONT class='MyLargeTextFormat'>Robert Murray M'Cheyne Daily Bible Reading Calendar</FONT>");
		document.write("  </TD>");
		document.write("</TR>");
		document.write("<TR>");
		document.write("  <TD ALIGN=CENTER ROWSPAN=1>");
		document.write("    <TABLE BORDER=0 CELLPADDING=0 WIDTH=100%>");
		document.write("	    <TR>");
		document.write("	      <TD COLSPAN=4 ALIGN=CENTER>");
		document.write("          <B>Version</B><BR>");
		document.write("		    </TD>");
		document.write("	    </TR>");
		document.write("	    <TR>");
		document.write("		    <TD WIDTH=20%>&nbsp;</TD>");
		document.write("	      <TD WIDTH=60% ALIGN=CENTER>");
		document.write("		      <SELECT NAME=selVersion onChange=versionChange(this.form)>");
		document.write("            <OPTION value=NIV>New International Version");
		document.write("            <OPTION value=NKJV>New King James Version");
		document.write("            <OPTION value=KJV>King James Version");
 		document.write("            <OPTION value=AMP>Amplified Bible");
 		document.write("            <OPTION value=KJ21>21st Century King James Version");
 		document.write("            <OPTION value=ASV>American Standard Version");
		document.write("            <OPTION value=NASB>New American Standard Bible");
		document.write("            <OPTION value=YLT>Young's Literal Translation");
		document.write("            <OPTION value=DARBY>Darby Translation");
		document.write("						<OPTION value=NLT>New Living Translation");
		document.write("					</SELECT>");
		document.write("        </TD>");
		document.write("        <TD WIDTH=20%>&nbsp;</TD>");
		document.write("      </TR>");
		document.write("	    <TR>");
		document.write("	      <TD>&nbsp;</TD>");
		document.write("		    <TD>");
		document.write("	        <INPUT type=checkbox NAME=chkXref onClick=xrefClick(this.form)> <B>Show cross references (NASB)</B><BR>");
		document.write("	        <INPUT type=checkbox NAME=chkFootNote onClick=footNoteClick(this.form)> <B>Show footnotes (NIV/ NASB)</B><BR>");
		document.write("		    </TD>");
		document.write("        <TD>&nbsp;</TD>");
		document.write("      </TR>");
		document.write("	  </TABLE>");
		document.write("  </TD>");
		document.write("  <TD ALIGN=CENTER COLSPAN=3>");
		document.write("    <TABLE BORDER=0 CELLPADDING=0 WIDTH=100%>");
		document.write("	    <TR>");
		document.write("	      <TD COLSPAN=3 ALIGN=CENTER>");
		document.write("	        <B>Date</B>");
		document.write("		    </TD>");
		document.write("      </TR>");
		document.write("		  <TR>");
		document.write("        <TD WIDTH=10%>&nbsp;</TD>");
		document.write("	      <TD WIDTH=80%>");
		document.write("	        <SELECT NAME=selDateOpt onChange=dateOptChange(this.form)>");
		document.write("	          <OPTION value=CD>Current Date");
		document.write(" 					  <OPTION value=PD>Prior Date");
		document.write("					  <OPTION value=ND>Next Date");
		document.write("					  <OPTION value=DT>Date");
		document.write("	        </SELECT><BR>");
		document.write("	        <SELECT NAME=selMonth onChange=monthChange(this.form)>");
		document.write("            <OPTION value=1>January");
		document.write("            <OPTION value=2>February");
		document.write("            <OPTION value=3>March");
		document.write("            <OPTION value=4>April");
		document.write("            <OPTION value=5>May");
		document.write("            <OPTION value=6>June");
		document.write("            <OPTION value=7>July");
		document.write("            <OPTION value=8>August");
		document.write("            <OPTION value=9>September");
		document.write("            <OPTION value=10>October");
		document.write("            <OPTION value=11>November");
		document.write("            <OPTION value=12>December");
		document.write("          </SELECT>");
		document.write("          <SELECT NAME=selDay onChange=dayChange(this.form)>");
		document.write("            <OPTION value=1>01");
		document.write("            <OPTION value=2>02");
		document.write("            <OPTION value=3>03");
		document.write("            <OPTION value=4>04");
		document.write("            <OPTION value=5>05");
		document.write("            <OPTION value=6>06");
		document.write("            <OPTION value=7>07");
		document.write("            <OPTION value=8>08");
		document.write("            <OPTION value=9>09");
		document.write("            <OPTION value=10>10");
		document.write("            <OPTION value=11>11");
		document.write("            <OPTION value=12>12");
		document.write("            <OPTION value=13>13");
		document.write("            <OPTION value=14>14");
		document.write("            <OPTION value=15>15");
		document.write("            <OPTION value=16>16");
		document.write("            <OPTION value=17>17");
		document.write("            <OPTION value=18>18");
		document.write("            <OPTION value=19>19");
		document.write("            <OPTION value=20>20");
		document.write("            <OPTION value=21>21");
		document.write("            <OPTION value=22>22");
		document.write("            <OPTION value=23>23");
		document.write("            <OPTION value=24>24");
		document.write("            <OPTION value=25>25");
		document.write("            <OPTION value=26>26");
		document.write("            <OPTION value=27>27");
		document.write("            <OPTION value=28>28");
		document.write("            <OPTION value=29>29");
		document.write("            <OPTION value=30>30");
		document.write("            <OPTION value=31>31");
		document.write("          </SELECT><BR>");
		document.write("        </TD>");
		document.write("        <TD WIDTH=10%>&nbsp;</TD>");
		document.write("      </TR>");
		document.write("	  </TABLE>");
		document.write("	</TD>");
		document.write("</TR>");
		document.write("<TR>");
		document.write("	<TD ROWSPAN=4 ALIGN=CENTER>");
		document.write("		<TABLE WIDTH=100%>");
		document.write("			<TR>");
		document.write("				<TD WIDTH=20%>");
		document.write("					&nbsp;");
		document.write("				</TD>");
		document.write("				<TD WIDTH=60%>");
		document.write("					<input type=radio name=rdoWin><B>All in One Window</B>&nbsp;&nbsp;&nbsp;<BR>");
		document.write("					<input type=radio name=rdoWin><B>All in Separate Windows</B>&nbsp;&nbsp;&nbsp;");
		document.write("				</TD>");
		document.write("				<TD WIDTH=20%>");
		document.write("					&nbsp;");
		document.write("				</TD>");
		document.write("			</TR>");
		document.write("		</TABLE>");
		document.write("	</TD>");
		document.write("	<TD COLSPAN=3 ALIGN=CENTER>");
		document.write("		<B>Which Readings</B>");
		document.write("	</TD>");
		document.write("</TR>");
		document.write("<TR>");
		document.write("	<TD ALIGN=CENTER><A class='select' href=JavaScript:allClick(document.frmCalendar)>All</A></TD>");
		document.write("	<TD ALIGN=CENTER><A class='select' href=JavaScript:oneClick(document.frmCalendar)>First</A></TD>");
		document.write("	<TD ALIGN=CENTER><A class='select' href=JavaScript:twoClick(document.frmCalendar)>Second</A></TD>");
		document.write("</TR>");
		document.write("<TR>");
		document.write("	<TD ALIGN=CENTER><A class='select' href=JavaScript:familyClick(document.frmCalendar)>Family</A></TD>");
		document.write("	<TD ALIGN=CENTER><INPUT type=checkbox NAME=chkFamily1></TD>");
		document.write("	<TD ALIGN=CENTER><INPUT type=checkbox NAME=chkFamily2></TD>");
		document.write("</TR>");
		document.write("<TR>");
		document.write("	<TD ALIGN=CENTER><A class='select' href=JavaScript:secretClick(document.frmCalendar)>Secret</A></TD>");
		document.write("	<TD ALIGN=CENTER><INPUT type=checkbox NAME=chkSecret1></TD>");
		document.write("	<TD ALIGN=CENTER><INPUT type=checkbox NAME=chkSecret2></TD>");
		document.write("</TR>");
		document.write("<TR>");
		document.write("  <TD ALIGN=CENTER COLSPAN=4>");
		//		document.write("		<BR>");
		document.write("    <INPUT TYPE=button VALUE='Get Readings' NAME=btnRead onClick='getRead(this.form)'>");
		document.write("	  <INPUT TYPE=button VALUE=Reset NAME=btnReset onClick=initMe(this.form)>");
		document.write("		<BR>");
		document.write("  </TD>");
		document.write("</TR>");
		document.write("</TABLE>");
		document.write("</FORM>");
		
}