var searchBook = "--none--";

var chapters = new Array ();
chapters ['Genesis'] = 50;
chapters ['Exodus'] = 40;
chapters ['Leviticus'] = 27;
chapters ['Numbers'] = 1;
chapters ['Deuteronomy'] = 34;
chapters ['Joshua'] = 24;
chapters ['Judges'] = 21;
chapters ['Ruth'] = 4;
chapters ['1 Samuel'] = 31;
chapters ['2 Samuel'] = 24;
chapters ['1 Kings'] = 22;
chapters ['2 Kings'] = 25;
chapters ['1 Chronicles'] = 29;
chapters ['2 Chronicles'] = 36;
chapters ['Ezra'] = 10;
chapters ['Nehemiah'] = 13;
chapters ['Esther'] = 10;
chapters ['Job'] = 42;
chapters ['Psalm'] = 150;
chapters ['Proverbs'] = 31;
chapters ['Ecclesiastes'] = 12;
chapters ['Song of Solomon'] = 8;
chapters ['Isaiah'] = 66;
chapters ['Jeremiah'] = 52;
chapters ['Lamentations'] = 5;
chapters ['Ezekiel'] = 48;
chapters ['Daniel'] = 12;
chapters ['Hosea'] = 14;
chapters ['Joel'] = 3;
chapters ['Amos'] = 9;
chapters ['Obadiah'] = 1;
chapters ['Jonah'] = 4;
chapters ['Micah'] = 7;
chapters ['Nahum'] = 3;
chapters ['Habakkuk'] = 3;
chapters ['Zephaniah'] = 3;
chapters ['Haggai'] = 2;
chapters ['Zechariah'] = 14;
chapters ['Malachi'] = 4;
chapters ['Matthew'] = 28;
chapters ['Mark'] = 16;
chapters ['Luke'] = 24;
chapters ['John'] = 21;
chapters ['Acts'] = 28;
chapters ['Romans'] = 16;
chapters ['1 Corinthians'] = 16;
chapters ['2 Corinthians'] = 13;
chapters ['Galatians'] = 6;
chapters ['Ephesians'] = 6;
chapters ['Philippians'] = 4;
chapters ['Colossians'] = 4;
chapters ['1 Thessalonians'] = 5;
chapters ['2 Thessalonians'] = 3;
chapters ['1 Timothy'] = 6;
chapters ['2 Timothy'] = 4;
chapters ['Titus'] = 3;
chapters ['Philemon'] = 1;
chapters ['Hebrews'] = 13;
chapters ['James'] = 5;
chapters ['1 Peter'] = 5;
chapters ['2 Peter'] = 3;
chapters ['1 John'] = 5;
chapters ['2 John'] = 1;
chapters ['3 John'] = 1;
chapters ['Jude'] = 1;
chapters ['Revelation'] = 22;
chapters ['PREFACE'] = 0;
chapters ['1 Nephi'] = 22;
chapters ['2 Nephi'] = 33;
chapters ['Jacob'] = 7;
chapters ['Enos'] = 1;
chapters ['Jarom'] = 1;
chapters ['Omni'] = 1;
chapters ['Words of Mormon'] = 1;
chapters ['Mosiah'] = 29;
chapters ['Alma'] = 63;
chapters ['Helaman'] = 16;
chapters ['3 Nephi'] = 30;
chapters ['4 Nephi'] = 1;
chapters ['Mormon'] = 9;
chapters ['Ether'] = 15;
chapters ['Moroni'] = 10;
chapters ['Doctrine and Covenants'] = 138;
chapters ['Declaration'] = 2;
chapters ['Moses'] = 8;
chapters ['Abraham'] = 5;
chapters ['Joseph Smith Matthew'] = 1;
chapters ['Joseph Smith History'] = 1;
chapters ['Articles of Faith'] = 1;


function setChapters (bookName, theForm)
{
   if (bookName != "--none--")
   {
      var chapterSel = theForm.elements.Chapter;
      searchBook = bookName;
      var nChapters = chapters [bookName];
      chapterSel.options.length = 0;
      if (nChapters > 1)
      {
	 chapterSel.options [0] = new Option ("", "--none--");
      }
      for (var count = 1; count <= nChapters; count++)
      {
 	 chapterSel.options [chapterSel.options.length] =
 	    new Option (count, count);
      }
      if (nChapters == 1)
      {
	 gotoChapter (1);
      }
   }
}

function gotoChapter (chapter)
{
   if ((searchBook != "--none--") && (chapter != "--none--"))
   {
      var link = "chapters/" + searchBook.replace (' ', '_')
	 + "_" + chapter + ".html";
      var myWin = parent.frames.Text;
      myWin.location = link;
   }
}

