/*
 * OFFLINE BIBLE - BIBLE ENTITIES
 * Objects used to interact with Bible data including
 * verses, books, passages and references.
 *
 * You are free to modify or redistribute this code and
 * any derived works, but where possible please do so
 * without charge. Thanks.
 *
 * Nathan Kitchen (offlinebible.com)
 */

// NAME: BibleTestament
// DESC: Contains data about one of the testaments of the Bible.
function BibleTestament(name, text, title, books, length)
{
  this._name   = name   ? name   : 0;
  this._text   = text   ? text   : 0;
  this._title  = title  ? title  : "";
  this._books  = books  ? books  : new Array();
  this._length = length ? length : 0;

  BibleTestament.prototype.name   = function() { return this._name; }
  BibleTestament.prototype.text   = function() { return this._text; }
  BibleTestament.prototype.title  = function() { return this._title; }
  BibleTestament.prototype.books  = function() { return this._books; }
  BibleTestament.prototype.length = function() { return this._length; }
}

// NAME: BibleBook
// DESC: Contains data about a single book of the Bible.
function BibleBook(bookId, name, text, title, abbr, length, start, breaks, last)
{
  this._bookId        = bookId ? bookId : 0;
  this._name          = name   ? name   : 0;
  this._text          = text   ? text   : 0;
  this._title         = title  ? title  : "";
  this._abbreviations = abbr   ? abbr   : new Array();
  this._length        = length ? length : 0;
  this._start         = start  ? start  : 0;
  this._breaks        = breaks ? breaks : new Array();
  this._last          = last   ? last   : 0;
  
  BibleBook.prototype.bookId  = function() { return this._bookId; }               // Integer value (1-66)
  BibleBook.prototype.name    = function() { return this._name; }                 // Computer readable (no spaces) e.g. "1Samuel"
  BibleBook.prototype.text    = function() { return this._text; }                 // Human readable (short) e.g. "1 Samuel"
  BibleBook.prototype.title   = function() { return this._title; }                // Human readable (long) e.g. "The first book of Samuel"
  BibleBook.prototype.abbreviations = function() { return this._abbreviations; }  // Array of abbreviations e.g. ["1sa", "1sam", "1sml"]
  BibleBook.prototype.length  = function() { return parseInt(this._length); }     // Number of chapters in the book
  BibleBook.prototype.start   = function() { return parseInt(this._start); }      // ID of the chapter that starts the book
  BibleBook.prototype.breaks  = function() { return this._breaks; }               // ID's of the verses which start each chapter in the book
  BibleBook.prototype.last    = function() { return this._last; }                 // ID of the verse which ends the last chapter in the book
  
  BibleBook.prototype.containsVerseId = function(verseId)
  {
    if (this._breaks[0] > verseId) { return false; }
    if (this._last < verseId) { return false; }
    return true;
  }
  
  BibleBook.prototype.getChapterIdByVerseId = function(verseId)
  {
    if (this._breaks[0] > verseId) { return 0; }
    if (this._breaks[0] == verseId) { return this._breaks[0]; }
    if (this._last < verseId) { return 0; }
    
    for (var i=0; i<this._breaks.length; i++)
    {
      if (this._breaks[i] < verseId) { continue; }
      return this._start + i - 1;
    }
    
    return 1;
  }
  
  BibleBook.prototype.getChapterNumByVerseId = function(verseId)
  {
    if (this._breaks[0] > verseId) { return 0; }
    if (this._breaks[0] == verseId) { return 1; }
    if (this._last < verseId) { return 0; }
    
    for (var i=0; i<this._breaks.length; i++)
    {
      if (this._breaks[i] < verseId) { continue; }
      return i;
    }
    
    return this._breaks.length;
  }
  
  BibleBook.prototype.getVerseNumByVerseId = function(verseId)
  {
    if (this._breaks[0] > verseId) { return 0; }
    if (this._last < verseId) { return 0; }
    
    for (var i=0; i<this._breaks.length; i++)
    {
      if (this._breaks[i] < verseId) { continue; }
      return verseId - this._breaks[i - 1] + 1;
    }
    
    return 1;
  }
  
  BibleBook.prototype.getVerseDataByVerseId = function(verseId)
  {
    if (this._breaks[0] > verseId) { return 0; }
    if (this._last < verseId) { return 0; }

    for (var i=0; i<this._breaks.length; i++)
    {
      if (this._breaks[i] <= verseId) { continue; }
      return { "chapterId": (this._start + i - 1), "chapterNum": i, "verseNum": (verseId - this._breaks[i - 1] + 1) };
    }

    return { "chapterId": (this._start + this._breaks.length - 1), "chapterNum": this._breaks.length, "verseNum": (verseId - this._breaks[this._breaks.length - 1] + 1) };
  }
}
BibleBook.FromVerseId = function(vId) 
{
  for (var i=0; i<Bible._books.length; i++)
  {
    if (Bible._books[i].containsVerseId(vId))
    {
      return Bible._books[i];
    }
  }
  return null;
}

// NAME: BibleBookmark
// DESC: Contains data referencing a single chapter of the Bible.
function BibleBookmark(bookId, chapterId, chapterNum)
{
  this._bookId    = bookId     ? bookId     : 0;
  this._chapterId   = chapterId  ? chapterId  : 0;
  this._chapterNum  = chapterNum ? chapterNum : 0;

  BibleBookmark.prototype.bookId     = function() { return this._bookId; }
  BibleBookmark.prototype.chapterId  = function() { return parseInt(this._chapterId); }
  BibleBookmark.prototype.chapterNum = function() { return this._chapterNum; }
  BibleBookmark.prototype.text       = function() { return Bible.Books()[this._bookId - 1].text() + " " + this._chapterNum; }
  BibleBookmark.prototype.position   = function() { return (100 / 1189) * (this._chapterId - 1); }
}
BibleBookmark.ToJson   = function(realBookmark) { return JSON.stringify([realBookmark.bookId(), realBookmark.chapterId(), realBookmark.chapterNum()]); }  
BibleBookmark.FromJson = function(jsonBookmark) { var data = JSON.parse(jsonBookmark); return new BibleBookmark(data[0], data[1], data[2]); }
BibleBookmark.FromBookId = function(bookId)
{
  if (bookId < 1 || bookId > 66) { return null; }
  return new BibleBookmark(bookId, Bible._books[bookId - 1].start(), 1);
}
BibleBookmark.FromChapterId = function(chapterId)
{
  if (chapterId < 0 || chapterId > 1189) { return null; }
  var chapterNumber = chapterId;

  for(var i=0;i<66;i++)
  {
    var book = Bible._books[i];
    if (book.length() - chapterNumber >= 0)
    {
      return new BibleBookmark(book.bookId(), chapterId, Math.floor(chapterNumber));
    }
    else
    {
      chapterNumber = chapterNumber - book.length();
    }
  }
  throw new Error("Could not find chapter");
}
BibleBookmark.FromPosition = function(position) { return BibleBookmark.FromChapterId(Math.round(position*11.89) + 1); }

// NAME: VerseReference
// DESC: Contains data to locate a single Bible verse.
VerseReference.prototype = new BibleBookmark();
VerseReference.prototype.constructor=BibleBookmark;

function VerseReference(bookId, chapterId, chapterNum, verseId, verseNum)
{
  this._bookId      = bookId     ? bookId     : 0;
  this._chapterId   = chapterId  ? chapterId  : 0;
  this._chapterNum  = chapterNum ? chapterNum : 0;
  this._verseId     = verseId    ? verseId    : 0;
  this._verseNumber = verseNum   ? verseNum   : 0;

  VerseReference.prototype.verseId = function() { return this._verseId; }
  VerseReference.prototype.verse   = function() { return this._verseNumber; }

  VerseReference.prototype.toString = function() { return Bible.Books()[this._bookId-1].text() + " " + this._chapterNum.toString() + "v" + this._verseNumber.toString(); }
  
  VerseReference.fromString = function(value)
  {
    if (!value) { return null; }
    var lowerValue = value.toLowerCase();
    var rxReferenceParser = /(^[12]?[ ]*[a-z]+)[ ]*(\d+)?[ ]*(([v\-\.~\:]|vs|verse|[ ]*)[ ]*(\d+))?[ ]*$/;
    var matches = rxReferenceParser.exec(lowerValue);

    if (!matches) { return null; }
    var bookName   = (matches.length > 1) ? matches[1] : null;
    var chapterId  = 0;
    var chapterNum = (matches.length > 2 && matches[2]) ? parseInt(matches[2]) : null;
    var verseId    = 0;
    var verseNum   = (matches.length > 4 && matches[4]) ? parseInt(matches[5]) : 1;
    
    // Must specify a chapter number for a reference to be created.
    if (!chapterNum) { return null; }
    
    var searchBookName = bookName.replace(/ /g,"");
    var bookId = 0;
    var books = Bible.Books();
    
    for (var i=0;i<books.length;i++)
    {
      var abbr = books[i].abbreviations();
      for (var j=0;j<abbr.length;j++)
      {
        if (searchBookName.indexOf(abbr[j])==0)
        {
          bookId = i + 1;
          chapterId = (chapterNum) ? books[i].start() + chapterNum - 1 : books[i].start();
          verseId = (chapterNum && verseNum) ? books[i].breaks()[chapterNum - 1] + verseNum - 1 : books[i].breaks()[0];
          break;
        }
      }
      if (bookId > 0) { break; }
    }
    return new VerseReference(bookId, chapterId, chapterNum, verseId, verseNum);
  }
  
  VerseReference.fromVerseId = function(vId)
  {
    var book = BibleBook.FromVerseId(vId);
    var data = book.getVerseDataByVerseId(vId);
    return new VerseReference(book.bookId(), data.chapterId, data.chapterNum, vId, data.verseNum);
  }
}

// NAME: VerseRange
// DESC: Contains data identifying a sequential series of verses.
VerseRange.prototype = new VerseReference();
VerseRange.prototype.constructor=VerseRange;

function VerseRange(bookId, chapterNum, verseId, verseNum, length)
{
  this._bookId        = bookId;
  this._chapterNumber = chapterNum;
  this._verseId       = verseId;
  this._verseNumber   = verseNum;
  this._length        = length;

  VerseReference.prototype.length   = function() { return this._length; }
}

// NAME: Bible
// DESC: Contains information on the Bible and the books within it. Provides methods
// for accessing the books by testament, position, and other information.
function Bible() {}
Bible._books = [
  new BibleBook(1,"Genesis","Genesis","The book of Genesis",["ge","gen","genesis"],50,1,[1,32,57,81,107,139,161,185,207,236,268,300,320,338,362,383,399,426,459,497,515,549,573,593,660,694,729,775,797,832,875,930,962,982,1013,1042,1085,1121,1151,1174,1197,1254,1292,1326,1360,1388,1422,1453,1475,1508],1533),
  new BibleBook(2,"Exodus","Exodus","The book of Exodus",["ex","exo","exodus"],40,51,[1534,1556,1581,1603,1634,1657,1687,1712,1744,1779,1808,1818,1869,1891,1922,1949,1985,2001,2028,2053,2079,2115,2146,2179,2197,2237,2274,2295,2338,2384,2422,2440,2475,2498,2533,2568,2606,2635,2666,2709],2746),
  new BibleBook(3,"Leviticus","Leviticus","The book of Leviticus",["le","lv","lev","levi","leviticus"],27,91,[2747,2764,2780,2797,2832,2851,2881,2919,2955,2979,2999,3046,3054,3113,3170,3203,3237,3253,3283,3320,3347,3371,3404,3448,3471,3526,3572],3605),
  new BibleBook(4,"Numbers","Numbers","The book of Numbers",["nm","nu","num","numb","numbers"],36,118,[3606,3660,3694,3745,3794,3825,3852,3941,3967,3990,4026,4061,4077,4110,4155,4196,4246,4259,4291,4313,4342,4377,4418,4448,4473,4491,4556,4579,4610,4650,4666,4720,4762,4818,4847,4881],4893),
  new BibleBook(5,"Deuteronomy","Deuteronomy","The book of Deuteronomy",["de","deut","deuter","deuteronomy"],34,154,[4894,4940,4977,5006,5055,5088,5113,5139,5159,5188,5210,5242,5274,5292,5321,5344,5366,5386,5408,5429,5449,5472,5502,5527,5549,5568,5587,5613,5681,5710,5730,5760,5812,5841],5852),
  new BibleBook(6,"Joshua","Joshua","The book of Joshua",["jos","josh","joshua"],24,188,[5853,5871,5895,5912,5936,5951,5978,6004,6039,6066,6109,6132,6156,6189,6204,6267,6277,6295,6323,6374,6383,6428,6462,6478],6510),
  new BibleBook(7,"Judges","Judges","The book of Judges",["jds","judge","judges"],21,212,[6511,6547,6570,6601,6625,6656,6696,6721,6756,6813,6831,6871,6886,6911,6931,6951,6982,6995,7026,7056,7104],7128),
  new BibleBook(8,"Ruth","Ruth","The book of Ruth",["ru","rut","ruth"],4,233,[7129,7151,7174,7192],7213),
  new BibleBook(9,"Samuel1","1 Samuel","The first book of Samuel",["1sa","1sm","1sam","1samuel"],31,237,[7214,7242,7278,7299,7321,7333,7354,7371,7393,7420,7447,7462,7487,7510,7562,7597,7620,7678,7708,7732,7774,7789,7812,7841,7863,7907,7932,7944,7969,7980,8011],8023),
  new BibleBook(10,"Samuel2","2 Samuel","The second book of Samuel",["2sa","2sm","2sam","2samuel"],24,268,[8024,8051,8083,8122,8134,8159,8182,8211,8229,8242,8261,8288,8319,8358,8391,8428,8451,8480,8513,8556,8582,8604,8655,8694],8718),
  new BibleBook(11,"Kings1","1 Kings","The first book of the Kings",["1k","1ki","1kin","1king","1kings"],22,292,[8719,8772,8818,8846,8880,8898,8936,8987,9053,9081,9110,9153,9186,9220,9251,9285,9319,9343,9389,9410,9453,9482],9534),
  new BibleBook(12,"Kings2","2 Kings","The second book of the Kings",["2k","2ki","2kin","2king","2kings"],25,314,[9535,9553,9578,9605,9649,9676,9709,9729,9758,9795,9831,9852,9873,9898,9927,9965,9985,10026,10063,10100,10121,10147,10167,10204,10224],10253),
  new BibleBook(13,"Chronicles1","1 Chronicles","The first book of the Chronicles",["1ch","1chr","1chron","1chronicles"],29,339,[10254,10308,10363,10387,10430,10456,10537,10577,10617,10661,10675,10722,10762,10776,10793,10822,10865,10892,10909,10928,10936,10966,10985,11017,11048,11079,11111,11145,11166],11195),
  new BibleBook(14,"Chronicles2","2 Chronicles","The second book of the Chronicles",["2ch","2chr","2chron","2chronicles"],36,368,[11196,11213,11231,11248,11270,11284,11326,11348,11366,11397,11416,11439,11455,11477,11492,11511,11525,11544,11578,11589,11626,11646,11658,11679,11706,11734,11757,11766,11793,11829,11856,11877,11910,11935,11968,11995],12017),
  new BibleBook(15,"Ezra","Ezra","The book of Ezra",["ez","ezr","ezra"],10,404,[12018,12029,12099,12112,12136,12153,12175,12203,12239,12254],12297),
  new BibleBook(16,"Nehemiah","Nehemiah","The book of Nehemiah",["ne","neh","nehemiah"],13,414,[12298,12309,12329,12361,12384,12403,12422,12495,12513,12551,12590,12626,12673],12703),
  new BibleBook(17,"Esther","Esther","The book of Esther",["es","est","esth","esther"],10,427,[12704,12726,12749,12764,12781,12795,12809,12819,12836,12868,],12870),
  new BibleBook(18,"Job","Job","The book of Job",["job"],42,437,[12871,12893,12906,12932,12953,12980,13010,13031,13053,13088,13110,13130,13155,13183,13205,13240,13262,13278,13299,13328,13357,13391,13421,13438,13463,13469,13483,13506,13534,13559,13590,13630,13652,13685,13722,13738,13771,13795,13836,13866,13890,13924],13940),
  new BibleBook(19,"Psalms","Psalms","The book of the Psalms",["ps","psa","psalm","psalms"],150,479,[13941,13947,13959,13967,13975,13987,13997,14014,14023,14043,14061,14068,14076,14082,14089,14094,14105,14120,14170,14184,14193,14206,14237,14243,14253,14275,14287,14301,14310,14321,14333,14357,14368,14390,14412,14440,14452,14492,14514,14527,14544,14557,14568,14573,14599,14616,14627,14636,14650,14670,14693,14712,14721,14727,14734,14757,14770,14781,14792,14809,14821,14829,14841,14852,14862,14875,14895,14902,14937,14973,14978,15002,15022,15050,15073,15083,15095,15115,15187,15200,15219,15235,15243,15261,15273,15286,15303,15310,15328,15380,15397,15413,15428,15433,15456,15467,15480,15492,15501,15510,15515,15523,15551,15573,15608,15653,15701,15744,15757,15788,15795,15805,15815,15824,15832,15850,15869,15871,15900,16076,16083,16091,16100,16104,16112,16117,16123,16128,16134,16142,16150,16153,16171,16174,16177,16198,16224,16233,16241,16265,16278,16288,16295,16307,16322,16343,16353,16373,16387,16396],16401),
  new BibleBook(20,"Proverbs","Proverbs","The book of Proverbs",["pro","prv","prov","proverb","proverbs"],31,629,[16402,16435,16457,16492,16519,16542,16577,16604,16640,16658,16690,16721,16749,16774,16809,16842,16875,16903,16927,16956,16986,17017,17046,17081,17115,17143,17171,17198,17226,17253,17286],17316),
  new BibleBook(21,"Ecclesiastes","Ecclesiastes","The book of Ecclesiastes",["ec","ecc","eccles","ecclesia","ecclesiastes"],12,660,[17317,17335,17361,17383,17399,17419,17431,17460,17477,17495,17515,17525],17538),
  new BibleBook(22,"SongOfSongs","Song of Songs","The Song of Songs,which is Solomons",["so","ss","son","sos","song","songs","sol","solo","solomon","song of songs","song of solomon"],8,672,[17539,17556,17573,17584,17600,17616,17629,17642],17655),
  new BibleBook(23,"Isaiah","Isaiah","The book of the prophet Isaiah",["is","isa","isaiah"],66,680,[17656,17687,17709,17735,17741,17771,17784,17809,17831,17852,17886,17902,17908,17930,17962,17971,17985,17999,18006,18031,18037,18054,18079,18097,18120,18132,18153,18166,18195,18219,18252,18261,18281,18305,18322,18332,18354,18392,18414,18422,18453,18482,18507,18535,18563,18588,18601,18616,18638,18664,18675,18698,18713,18725,18742,18755,18767,18788,18802,18823,18845,18856,18868,18887,18899,18924],18947),
  new BibleBook(24,"Jeremiah","Jeremiah","The book of the prophet Jeremiah",["je","jer","jerem","jeremiah"],52,746,[18948,18967,19004,19029,19060,19091,19121,19155,19177,19203,19228,19251,19268,19295,19317,19338,19359,19386,19409,19424,19442,19456,19486,19526,19536,19574,19598,19620,19637,19669,19693,19733,19777,19803,19825,19844,19876,19897,19925,19943,19959,19977,19999,20012,20042,20047,20075,20082,20129,20168,20214,20278],20311),
  new BibleBook(25,"Lamentations","Lamentations","The Lamentations of Jeremiah",["lam","lament","laments","lamentation","lamentations"],5,798,[20312,20334,20356,20422,20444],20465),
  new BibleBook(26,"Ezekiel","Ezekiel","The book of the prophet Ezekiel",["ez","eze","ezek","ezekiel"],48,803,[20466,20494,20504,20531,20548,20565,20579,20606,20624,20635,20657,20682,20710,20733,20756,20764,20827,20851,20883,20897,20946,20978,21009,21058,21085,21102,21123,21159,21185,21206,21232,21250,21282,21315,21346,21361,21399,21427,21450,21479,21528,21554,21574,21601,21632,21657,21681,21704],21738),
  new BibleBook(27,"Daniel","Daniel","The book of the prophet Daniel",["da","dan","daniel"],12,851,[21739,21760,21809,21839,21876,21907,21935,21963,21990,22017,22038,22083],22095),
  new BibleBook(28,"Hosea","Hosea","The book of the prophet Hosea",["ho","hos","hose","hosea"],14,863,[22096,22107,22130,22135,22154,22169,22180,22196,22210,22227,22242,22254,22268,22284],22292),
  new BibleBook(29,"Joel","Joel","The book of the prophet Joel",["jl","joe","joel"],3,877,[22293,22313,22345],22365),
  new BibleBook(30,"Amos","Amos","The book of the prophet Amos",["am","amo","ams","amos"],9,880,[22366,22381,22397,22412,22425,22452,22466,22483,22497],22511),
  new BibleBook(31,"Obadiah","Obadiah","The book of the prophet Obadiah",["ob","oba","obad","obadiah"],1,889,[22512],22532),
  new BibleBook(32,"Jonah","Jonah","The book of the prophet Jonah",["jon","jonah"],4,890,[22533,22550,22560,22570],22580),
  new BibleBook(33,"Micah","Micah","The book of the prophet Micah",["mi","mic","micah"],7,894,[22581,22597,22610,22622,22635,22650,22666],22685),
  new BibleBook(34,"Nahum","Nahum","The book of the prophet Nahum",["na","nah","nahum"],3,901,[22686,22701,22714],22732),
  new BibleBook(35,"Habakkuk","Habakkuk","The book of the prophet Habakkuk",["hab","haba","habak","habakkuk","habakuk"],3,904,[22733,22750,22770],22788),
  new BibleBook(36,"Zephaniah","Zephaniah","The book of the prophet Zephaniah",["zeph","zephan","zephaniah"],3,907,[22789,22807,22822],22841),
  new BibleBook(37,"Haggai","Haggai","The book of the prophet Haggai",["hag","hagg","haggai"],2,910,[22842,22857],22879),
  new BibleBook(38,"Zechariah","Zechariah","The book of the prophet Zechariah",["zach","zacheriah","zech","zechariah"],14,912,[22880,22901,22914,22924,22938,22949,22964,22978,23001,23018,23030,23047,23061,23070],23090),
  new BibleBook(39,"Malachi","Malachi","The book of the prophet Malachi",["mal","malachi"],4,926,[23091,23105,23122,23140],23145),
  new BibleBook(40,"Matthew","Matthew","The gospel according to Matthew",["mt","mat","matt","mathew","matthew"],28,930,[23146,23171,23194,23211,23236,23284,23318,23347,23381,23419,23461,23491,23541,23599,23635,23674,23702,23729,23764,23794,23828,23874,23920,23959,24010,24056,24131,24197],24216),
  new BibleBook(41,"Mark","Mark","The gospel according to Mark",["mk","mar","mrk","mark"],16,958,[24217,24262,24290,24325,24366,24409,24465,24502,24540,24590,24642,24675,24719,24756,24828,24875],24894),
  new BibleBook(42,"Luke","Luke","The gospel according to Luke",["lk","lu","luk","luke"],24,974,[24895,24975,25027,25065,25109,25148,25197,25247,25303,25365,25407,25461,25520,25555,25590,25622,25653,25690,25733,25781,25828,25866,25937,25993],26045),
  new BibleBook(43,"John","John","The gospel according to John",["john"],21,998,[26046,26097,26122,26158,26212,26259,26330,26383,26442,26483,26525,26582,26632,26670,26701,26728,26761,26787,26827,26869,26900],26924),
  new BibleBook(44,"Acts","Acts","The Acts of the Apostles",["act","ats","acts"],28,1019,[26925,26951,26998,27024,27061,27103,27118,27178,27218,27261,27309,27339,27364,27416,27444,27485,27525,27559,27587,27628,27666,27706,27736,27771,27798,27825,27857,27901],27931),
  new BibleBook(45,"Romans","Romans","The letter to the believers in Rome",["rom","rome","roman","romans"],16,1047,[27932,27964,27993,28024,28049,28070,28093,28118,28157,28190,28211,28247,28268,28282,28305,28338],28364),
  new BibleBook(46,"Corinthians1","1 Corinthians","The first letter to the believers in Corinth",["1co","1cor","1corinth","1corinthians"],16,1063,[28365,28396,28412,28435,28456,28469,28489,28529,28542,28569,28602,28636,28667,28680,28720,28778],28801),
  new BibleBook(47,"Corinthians2","2 Corinthians","The second letter to the believers in Corinth",["2co","2cor","2corinth","2corinthians"],13,1079,[28802,28826,28843,28861,28879,28900,28918,28934,28958,28973,28991,29024,29045],29058),
  new BibleBook(48,"Galatians","Galatians","The letter to the believers in Galatia",["ga","gal","galatia","galatians"],6,1092,[29059,29083,29104,29133,29164,29190],29207),
  new BibleBook(49,"Ephesians","Ephesians","The letter to the believers in Ephesus",["ep","eph","ephesus","ephesians"],6,1098,[29208,29231,29253,29274,29306,29339],29362),
  new BibleBook(50,"Philippians","Philippians","The letter to the believers in Philippi",["phili","phils","philippi","phillipians","philipians","philippians","phillippians"],4,1104,[29363,29393,29423,29444],29466),
  new BibleBook(51,"Colossians","Colossians","The letter to the believers in Collossae",["co","col","colossia","collossians","colosians","collosians","colossians"],4,1108,[29467,29496,29519,29544],29561),
  new BibleBook(52,"Thessalonians1","1 Thessalonians","The first letter to the believers in Thessalonica",["1th","1thes","1thess","1thessalonia","1thessalonica","1thessalonians"],5,1112,[29562,29572,29592,29605,29623],29650),
  new BibleBook(53,"Thessalonians2","2 Thessalonians","The second letter to the believers in Thessalonica",["2th","2thes","2thess","2thessalonia","2thessalonica","2thessalonians"],3,1117,[29651,29663,29680],29698),
  new BibleBook(54,"Timothy1","1 Timothy","Paul's first letter to Timothy",["1ti","1tim","1timothy","1timotheus"],6,1120,[29698,29718,29733,29749,29765,29790],29810),
  new BibleBook(55,"Timothy2","2 Timothy","Paul's second letter to Timothy",["2ti","2tim","2timothy","2timotheus"],4,1126,[29811,29829,29855,29872],29893),
  new BibleBook(56,"Titus","Titus","The letter to Titus",["ti","tit","titus"],3,1130,[29894,29910,29925],29939),
  new BibleBook(57,"Philemon","Philemon","The letter to Philemon",["phile","philemon"],1,1133,[29940],29964),
  new BibleBook(58,"Hebrews","Hebrews","The letter to the Hebrews",["he","heb","hebrew","hebrews"],13,1134,[29965,29979,29997,30016,30032,30046,30066,30094,30107,30135,30174,30214,30243],30267),
  new BibleBook(59,"James","James","James' letter",["ja","jam","james"],5,1147,[30268,30295,30321,30339,30356],30375),
  new BibleBook(60,"Peter1","1 Peter","Peter's first letter",["1pe","1pet","1peter"],5,1152,[30376,30401,30426,30448,30467],30480),
  new BibleBook(61,"Peter2","2 Peter","Peter's second letter",["2pe","2pet","2peter"],3,1157,[30481,30502,30524],30541),
  new BibleBook(62,"John1","1 John","John's first letter",["1jo","1jon","1john"],5,1160,[30542,30552,30581,30605,30626],30646),
  new BibleBook(63,"John2","2 John","John's second letter",["2jo","2jon","2john"],1,1165,[30647],30659),
  new BibleBook(64,"John3","3 John","John's third letter",["3jo","3jon","3john"],1,1166,[30660],30673),
  new BibleBook(65,"Jude","Jude","The letter from Jude",["jude"],1,1167,[30674],30698),
  new BibleBook(66,"Revelation","Revelation","The Revelation of Jesus the Christ",["re","rev","revs","revl","revln","revltn","revel","revelation","revelations"],22,1168,[30699,30719,30748,30770,30781,30795,30812,30829,30842,30863,30874,30893,30910,30928,30948,30956,30977,30995,31019,31040,31055,31082],31102)
];

Bible.OldTestament = function() { return new BibleTestament("Old", "Old Testament", "The first testament in the Bible", Bible._books.slice(0,39), 929); }
Bible.NewTestament = function() { return new BibleTestament("New", "New Testament", "The second testament in the Bible", Bible._books.slice(39,66), 260); }
Bible.Contents = function() { return [Bible.OldTestament(), Bible.NewTestament()]; }
Bible.Books = function() { return Bible._books; }

