// ===================================================================
// Class for storing data of one Bible.
// $Id: Book.js 3420 2009-04-25 18:23:36Z helmut $

var Bible20;
if (!Bible20) {
  Bible20 = {};
}
else if (typeof Bible20 != "object") {
  throw new Error("Bible20 already exists and is not an object");
}

if (!Bible20.Bible) {
  Bible20.Bible = {};
}
else if (typeof Bible20.Bible != "object") {
  throw new Error("Bible20.Bible already exists and is not an object");
}

Bible20.Bible.Book = function(name)
{
  try {
    this._name = name;
    this._chapters = [];
  }
  catch (e) {
    alert("Bible.Book: " + e);
  }
}

Bible20.Bible.Book.prototype.getName = function()
{
  return this._name;
}

Bible20.Bible.Book.prototype.getChapters = function()
{
  return this._chapters;
}

Bible20.Bible.Book.prototype.getChapter = function(chapterNumber)
{
  return this._chapters[chapterNumber] || Bible20.Bible.Chapter.NULL;
}

Bible20.Bible.Book.prototype.findChapter = function(chapterNumber)
{
  return this._chapters[chapterNumber];
}

Bible20.Bible.Book.prototype.findAddChapter = function(chapterNumber)
{
  var Chapter = this._chapters[chapterNumber];
  if (!Chapter) {
    Chapter = this._chapters[chapterNumber] = new Bible20.Bible.Chapter(chapterNumber);
  }
  return Chapter;
}

Bible20.Bible.Book.NULL = new Bible20.Bible.Book();
