// ===================================================================
// Class for storing data of one Bible.
// $Id: Bible.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.Bible = function(name)
{
  try {
    this._name = name;
    this._books = {};
  }
  catch (e) {
    alert("Bible.Bible: " + e);
  }
}

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

Bible20.Bible.Bible.prototype.getBooks = function()
{
  return this._books;
}

Bible20.Bible.Bible.prototype.getBook = function(bookName)
{
  return this._books[bookName] || Bible20.Bible.Book.NULL;
}

Bible20.Bible.Bible.prototype.findBook = function(bookName)
{
  return this._books[bookName];
}

Bible20.Bible.Bible.prototype.findAddBook = function(bookName)
{
  var Book = this._books[bookName];
  if (!Book) {
    Book = this._books[bookName] = new Bible20.Bible.Book(bookName);
  }
  return Book;
}

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


