diff --git a/index.html b/index.html
index 8ed94fc0..265c0438 100644
--- a/index.html
+++ b/index.html
@@ -87,14 +87,11 @@
@@ -115,7 +112,7 @@
John 1:3-5 (displays verses starting with chapter 1 verse 3 through chapter 1 vs 5)
H1234 (displays the strongs definition for the Hebrew # 1234)
G1234 (displays the strongs definition for the Greek # 1234)
-
Jesus (searches for "Jesus". all search terms assume boolean AND, i.e. "Jesus Christ" assumes "Jesus AND Christ". All words without a number are interpreted as search items).
+
Jesus (searches for "Jesus". all search terms assume boolean AND, i.e. "Jesus Christ" assumes "Jesus AND Christ". an word without a number is interpreted as search).
Notes: multiple lookups can be made useing a semicolon as a seperator, i.e. "Ruth 1; g1234; jesus").
All greek/hebrew cross references translations are taken from the 1933 Websters version and often are not the same as the KJV translation.
diff --git a/js/bible_ref_parsing.js b/js/bible_ref_parsing.js
new file mode 100644
index 00000000..30d4f5e2
--- /dev/null
+++ b/js/bible_ref_parsing.js
@@ -0,0 +1,651 @@
+//
+// This code was written by Jason Wall. Feel free to use, and if you can, include a link back to www.walljm.com
+// Jason@walljm.com // www.walljm.com
+//
+
+String.prototype.trim = function()
+{
+ return this.replace(/^\s+|\s+$/g, "");
+}
+String.prototype.ltrim = function()
+{
+ return this.replace(/^\s+/, "");
+}
+String.prototype.rtrim = function()
+{
+ return this.replace(/\s+$/, "");
+}
+
+function Reference(ref)
+{
+ ref = ref.toLowerCase().trim();
+ var bibleNames = new Object;
+ var fbook = ref.substring(0, ref.search(/\w\s+\d/i)+1);
+
+ if (fbook.search(/\b(genesis|gen|ge|gn)\b/i) != -1)
+ {
+ this.book = 1;
+ this.bookname = "Genesis";
+ this.longbookname = "Genesis";
+ this.lastchapter = 50;
+ }
+ if (fbook.search(/\b(exodus|ex|exo|exod|exd)\b/i) != -1)
+ {
+ this.book = 2;
+ this.bookname = "Exodus";
+ this.longbookname = "Exodus";
+ this.lastchapter = 40;
+ }
+ if (fbook.search(/\b(leviticus|lev|le|levi|lv)\b/i) != -1)
+ {
+ this.book = 3;
+ this.bookname = "Leviticus";
+ this.longbookname = "Leviticus";
+ this.lastchapter = 27;
+ }
+ if (fbook.search(/\b(numbers|num|nu|numb|number)\b/i) != -1)
+ {
+ this.book = 4;
+ this.bookname = "Numbers";
+ this.longbookname = "Book_of_Numbers";
+ this.lastchapter = 36;
+ }
+ if (fbook.search(/\b(deuteronomy|deut|de|dt|deu)\b/i) != -1)
+ {
+ this.book = 5;
+ this.bookname = "Deuteronomy";
+ this.longbookname = "Deuteronomy";
+ this.lastchapter = 34;
+ }
+ if (fbook.search(/\b(joshua|josh|jos)\b/i) != -1)
+ {
+ this.book = 6;
+ this.bookname = "Joshua";
+ this.longbookname = "Book_of_Joshua";
+ this.lastchapter = 24;
+ }
+ if (fbook.search(/\b(judges|jud|ju|jdg|judg)\b/i) != -1)
+ {
+ this.book = 7;
+ this.bookname = "Judges";
+ this.longbookname = "Book_of_Judges";
+ this.lastchapter = 21;
+ }
+ if (fbook.search(/\b(ruth|ru)\b/i) != -1)
+ {
+ this.book = 8;
+ this.bookname = "Ruth";
+ this.longbookname = "Book_of_Ruth";
+ this.lastchapter = 4;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(samuel|sa|sam|sml)\b/i) != -1)
+ {
+ this.book = 9;
+ this.bookname = "1 Samuel";
+ this.longbookname = "First_Samuel";
+ this.lastchapter = 31;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(samuel|sa|sam|sml)\b/i) != -1)
+ {
+ this.book = 10;
+ this.bookname = "2 Samuel";
+ this.longbookname = "Second_Samuel";
+ this.lastchapter = 24;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(kings|king|kgs|kn|k|ki)\b/i) != -1)
+ {
+ this.book = 11;
+ this.bookname = "1 Kings";
+ this.longbookname = "First_Kings";
+ this.lastchapter = 22;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(kings|king|kgs|kn|k|ki)\b/i) != -1)
+ {
+ this.book = 12;
+ this.bookname = "2 Kings";
+ this.longbookname = "Second_Kings";
+ this.lastchapter = 25;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(chronicles|chron|ch|chr)\b/i) != -1)
+ {
+ this.book = 13;
+ this.bookname = "1 Chronicles";
+ this.longbookname = "First_Chronicles";
+ this.lastchapter = 29;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(chronicles|chron|ch|chr)\b/i) != -1)
+ {
+ this.book = 14;
+ this.bookname = "2 Chronicles";
+ this.longbookname = "Second_Chronicles";
+ this.lastchapter = 36;
+ }
+ if (fbook.search(/\b(ezra|ez|ezr)\b/i) != -1)
+ {
+ this.book = 15;
+ this.bookname = "Ezra";
+ this.longbookname = "Book_of_Ezra";
+ this.lastchapter = 10;
+ }
+ if (fbook.search(/\b(nehemiah|neh|ne|nehamiah)\b/i) != -1)
+ {
+ this.book = 16;
+ this.bookname = "Nehemiah";
+ this.longbookname = "Book_of_Nehemiah";
+ this.lastchapter = 13;
+ }
+ if (fbook.search(/\b(esther|est|es|esth)\b/i) != -1)
+ {
+ this.book = 17;
+ this.bookname = "Esther";
+ this.longbookname = "Book_of_Esther";
+ this.lastchapter = 10;
+ }
+ if (fbook.search(/\b(job|jo|jb)\b/i) != -1)
+ {
+ this.book = 18;
+ this.bookname = "Job";
+ this.longbookname = "Book_of_Job";
+ this.lastchapter = 42;
+ }
+ if (fbook.search(/\b(psalms|ps|psa|psalm|psm)\b/i) != -1)
+ {
+ this.book = 19;
+ this.bookname = "Psalm";
+ this.longbookname = "Psalm";
+ this.lastchapter = 150;
+ }
+ if (fbook.search(/\b(proverbs|prov|pr|pro|proverb|prv|prvbs)\b/i) != -1)
+ {
+ this.book = 20;
+ this.bookname = "Proverbs";
+ this.longbookname = "Book_of_Proverbs";
+ this.lastchapter = 31;
+ }
+ if (fbook.search(/\b(ecclesiastes|eccl|ecc|eccles|ec|ecl|ecclesiaste)\b/i) != -1)
+ {
+ this.book = 21;
+ this.bookname = "Ecclesiastes";
+ this.longbookname = "Ecclesiastes";
+ this.lastchapter = 12;
+ }
+ if (fbook.search(/\b(song\sof\ssolomon|song\sof\ssongs|sos|ss|son|so|song|songs)\b/i) != -1)
+ {
+ this.book = 22;
+ this.bookname = "Song of Solomon";
+ this.longbookname = "Song_of_Solomon";
+ this.lastchapter = 8;
+ }
+ if (fbook.search(/\b(isaiah|is|is|isah|isai|ia)\b/i) != -1)
+ {
+ this.book = 23;
+ this.bookname = "Isaiah";
+ this.longbookname = "Book_of_Isaiah";
+ this.lastchapter = 66;
+ }
+ if (fbook.search(/\b(jerimiah|jeremiah|jer|je|jere)\b/i) != -1)
+ {
+ this.book = 24;
+ this.bookname = "Jeremiah";
+ this.longbookname = "Book_of_Jeremiah";
+ this.lastchapter = 52;
+ }
+ if (fbook.search(/\b(lamentations|lam|la|lamentation)\b/i) != -1)
+ {
+ this.book = 25;
+ this.bookname = "Lamentations";
+ this.longbookname = "Book_of_Lamentations";
+ this.lastchapter = 5;
+ }
+ if (fbook.search(/\b(ezekiel|eze|ez|ezk|ezek)\b/i) != -1)
+ {
+ this.book = 26;
+ this.bookname = "Ezekiel";
+ this.longbookname = "Book_of_Ezekiel";
+ this.lastchapter = 48;
+ }
+ if (fbook.search(/\b(daniel|dan|dn|dl|da)\b/i) != -1)
+ {
+ this.book = 27;
+ this.bookname = "Daniel";
+ this.longbookname = "Book_of_Daniel";
+ this.lastchapter = 12;
+ }
+ if (fbook.search(/\b(hosea|hos|ho)\b/i) != -1)
+ {
+ this.book = 28;
+ this.bookname = "Hosea";
+ this.longbookname = "Book_of_Hosea";
+ this.lastchapter = 14;
+ }
+ if (fbook.search(/\b(joel|joe|jl)\b/i) != -1)
+ {
+ this.book = 29;
+ this.bookname = "Joel";
+ this.longbookname = "Book_of_Joel";
+ this.lastchapter = 3;
+ }
+ if (fbook.search(/\b(amos|am|amo)\b/i) != -1)
+ {
+ this.book = 30;
+ this.bookname = "Amos";
+ this.longbookname = "Book_of_Amos";
+ this.lastchapter = 9;
+ }
+ if (fbook.search(/\b(obadiah|oba|ob|obad)\b/i) != -1)
+ {
+ this.book = 31;
+ this.bookname = "Obadiah";
+ this.longbookname = "Book_of_Obadiah";
+ this.lastchapter = 1;
+ }
+ if (fbook.search(/\b(jonah|jnh|jon)\b/i) != -1)
+ {
+ this.book = 32;
+ this.bookname = "Jonah";
+ this.longbookname = "Book_of_Jonah";
+ this.lastchapter = 4;
+ }
+ if (fbook.search(/\b(micah|mic|mi)\b/i) != -1)
+ {
+ this.book = 33;
+ this.bookname = "Micah";
+ this.longbookname = "Book_of_Micah";
+ this.lastchapter = 7;
+ }
+ if (fbook.search(/\b(nahum|nah|na)\b/i) != -1)
+ {
+ this.book = 34;
+ this.bookname = "Nahum";
+ this.longbookname = "Book_of_Nahum";
+ this.lastchapter = 3;
+ }
+ if (fbook.search(/\b(habakkuk|hab|ha|habakuk)\b/i) != -1)
+ {
+ this.book = 35;
+ this.bookname = "Habakkuk";
+ this.longbookname = "Book_of_Habakkuk";
+ this.lastchapter = 3;
+ }
+ if (fbook.search(/\b(zephaniah|zeph|zep)\b/i) != -1)
+ {
+ this.book = 36;
+ this.bookname = "Zephaniah";
+ this.longbookname = "Book_of_Zephaniah";
+ this.lastchapter = 3;
+ }
+ if (fbook.search(/\b(haggia|hag|hg|haggai)\b/i) != -1)
+ {
+ this.book = 37;
+ this.bookname = "Haggai";
+ this.longbookname = "Book_of_Haggai";
+ this.lastchapter = 2;
+ }
+ if (fbook.search(/\b(zechariah|zech|zch|zec)\b/i) != -1)
+ {
+ this.book = 38;
+ this.bookname = "Zechariah";
+ this.longbookname = "Book_of_Zechariah";
+ this.lastchapter = 14;
+ }
+ if (fbook.search(/\b(malachi|mal)\b/i) != -1)
+ {
+ this.book = 39;
+ this.bookname = "Malachi";
+ this.longbookname = "Book_of_Malachi";
+ this.lastchapter = 4;
+ }
+ if (fbook.search(/\b(matthew|mt|matt|mat)\b/i) != -1)
+ {
+ this.book = 40;
+ this.bookname = "Matthew";
+ this.longbookname = "Gospel_of_Matthew";
+ this.lastchapter = 28;
+ }
+ if (fbook.search(/\b(mark|mrk|mk|mr)\b/i) != -1)
+ {
+ this.book = 41;
+ this.bookname = "Mark";
+ this.longbookname = "Gospel_of_Mark";
+ this.lastchapter = 16;
+ }
+ if (fbook.search(/\b(luke|lu|lke|luk|lk)\b/i) != -1)
+ {
+ this.book = 42;
+ this.bookname = "Luke";
+ this.longbookname = "Gospel_of_Luke";
+ this.lastchapter = 24;
+ }
+ if (fbook.search(/\b(john|jn|jhn)\b/i) != -1)
+ {
+ this.book = 43;
+ this.bookname = "John";
+ this.longbookname = "Gospel_of_John";
+ this.lastchapter = 21;
+ }
+ if (fbook.search(/\b(acts|ac|act)\b/i) != -1)
+ {
+ this.book = 44;
+ this.bookname = "Acts";
+ this.longbookname = "Acts_of_the_Apostles";
+ this.lastchapter = 28;
+ }
+ if (fbook.search(/\b(romans|rom|ro|rm|roman)\b/i) != -1)
+ {
+ this.book = 45;
+ this.bookname = "Romans";
+ this.longbookname = "Epistle_to_the_Romans";
+ this.lastchapter = 16;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) != -1)
+ {
+ this.book = 46;
+ this.bookname = "1 Corinthians";
+ this.longbookname = "First_Epistle_to_the_Corinthians";
+ this.lastchapter = 16;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(corinthian|cor|corinthians|corinth|corin|corth|corint)\b/i) != -1)
+ {
+ this.book = 47;
+ this.bookname = "2 Corinthians";
+ this.longbookname = "Second_Epistle_to_the_Corinthians";
+ this.lastchapter = 13;
+ }
+ if (fbook.search(/\b(galatians|galatian|galations|gal|ga|gala|galation|galat)\b/i) != -1)
+ {
+ this.book = 48;
+ this.bookname = "Galatians";
+ this.longbookname = "Epistle_to_the_Galatians";
+ this.lastchapter = 6;
+ }
+ if (fbook.search(/\b(ephesians|eph|ep|ephes|ephe|ephs)\b/i) != -1)
+ {
+ this.book = 49;
+ this.bookname = "Ephesians";
+ this.longbookname = "Epistle_to_the_Ephesians";
+ this.lastchapter = 6;
+ }
+ if (fbook.search(/\b(philippians|phi|phil|ph|philip)\b/i) != -1)
+ {
+ this.book = 50;
+ this.bookname = "Philippians";
+ this.longbookname = "Epistle_to_the_Philippians";
+ this.lastchapter = 4;
+ }
+ if (fbook.search(/\b(colossians|col|co|colossian|colos|coloss)\b/i) != -1)
+ {
+ this.book = 51;
+ this.bookname = "Colossians";
+ this.longbookname = "Epistle_to_the_Colossians";
+ this.lastchapter = 4;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) != -1)
+ {
+ this.book = 52;
+ this.bookname = "1 Thessalonians";
+ this.longbookname = "First_Epistle_to_the_Thessalonians";
+ this.lastchapter = 5;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(thessalonians|the|thessa|thessalonian|thes|thess|th)\b/i) != -1)
+ {
+ this.book = 53;
+ this.bookname = "2 Thessalonians";
+ this.longbookname = "Second_Epistle_to_the_Thessalonians";
+ this.lastchapter = 3;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(timothy|tim|ti|timoth|tm)\b/i) != -1)
+ {
+ this.book = 54;
+ this.bookname = "1 Timothy";
+ this.longbookname = "First_Epistle_to_Timothy";
+ this.lastchapter = 6;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(timothy|tim|timoth|tm)\b/i) != -1)
+ {
+ this.book = 55;
+ this.bookname = "2 Timothy";
+ this.longbookname = "Second_Epistle_to_Timothy";
+ this.lastchapter = 4;
+ }
+ if (fbook.search(/\b(titus|tit)\b/i) != -1)
+ {
+ this.book = 56;
+ this.bookname = "Titus";
+ this.longbookname = "Epistle_to_Titus";
+ this.lastchapter = 3;
+ }
+ if (fbook.search(/\b(philemon|phlmn|phl|phm|phile|philem)\b/i) != -1)
+ {
+ this.book = 57;
+ this.bookname = "Philemon";
+ this.longbookname = "Epistle_to_Philemon";
+ this.lastchapter = 1;
+ }
+ if (fbook.search(/\b(hebrews|heb|he|hebrew)\b/i) != -1)
+ {
+ this.book = 58;
+ this.bookname = "Hebrews";
+ this.longbookname = "Epistle_to_the_Hebrews";
+ this.lastchapter = 13;
+ }
+ if (fbook.search(/\b(james|jam|ja|jas|jms|jame|jm)\b/i) != -1)
+ {
+ this.book = 59;
+ this.bookname = "James";
+ this.longbookname = "Epistle_of_James";
+ this.lastchapter = 5;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(peter|pe|pet|pete|pt|p)\b/i) != -1)
+ {
+ this.book = 60;
+ this.bookname = "1 Peter";
+ this.longbookname = "First_Epistle_of_Peter";
+ this.lastchapter = 5;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(peter|pe|pet|pete|pt|p)\b/i) != -1)
+ {
+ this.book = 61;
+ this.bookname = "2 Peter";
+ this.longbookname = "Second_Epistle_of_Peter";
+ this.lastchapter = 3;
+ }
+ if (fbook.search(/\b(1|i|1st|first)\s*(john|jn|jo)\b/i) != -1)
+ {
+ this.book = 62;
+ this.bookname = "1 John";
+ this.longbookname = "First_Epistle_of_John";
+ this.lastchapter = 5;
+ }
+ if (fbook.search(/\b(2|ii|2nd|second|sec)\s*(john|jn|jo)\b/i) != -1)
+ {
+ this.book = 63;
+ this.bookname = "2 John";
+ this.longbookname = "Second_Epistle_of_John";
+ this.lastchapter = 1;
+ }
+ if (fbook.search(/\b(3|iii|3rd|third)\s*(john|jn|jo)\b/i) != -1)
+ {
+ this.book = 64;
+ this.bookname = "3 John";
+ this.longbookname = "Third_Epistle_of_John";
+ this.lastchapter = 1;
+ }
+ if (fbook.search(/\b(jude|jud|ju)\b/i) != -1)
+ {
+ this.book = 65;
+ this.bookname = "Jude";
+ this.longbookname = "Epistle_of_Jude";
+ this.lastchapter = 1;
+ }
+ if (fbook.search(/\b(revelation|rev|re|revelations|rv)\b/i) != -1)
+ {
+ this.book = 66;
+ this.bookname = "Revelation";
+ this.longbookname = "Book_of_Revelations";
+ this.lastchapter = 22;
+ }
+ var rexp = new RegExp(fbook, "gi");
+ var secondbook = ref.match(rexp);
+ // first, remove the book from the ref.
+ ref = ref.replace(rexp, "").trim();
+
+ // ok. we're going to deal with any of the following types of refernces:
+ /*
+ 1:1 - 2:3 // chapter/verse range.
+ 1:1 -2 // chapter/verse range. this one is special, because its indistinguisable from book 1:1 - book 2 when you remove the book, which i do. i'm ok with this.
+ 1-2 // chapter range
+ 1 // chapter
+ 2:1 // verse
+ 2:1 - 2:3 // verse range
+ */
+ // first, see if we're dealing with a range.
+ if (ref.match(/\-/) != null)
+ {
+ var sref = ref.split("-")[0].trim();
+ var eref = ref.split("-")[1].trim();
+
+ // if a colon is found, then its a chapter verse combo.
+ if (sref.match(/\:/) != null)
+ {
+ this.startchapter = sref.split(":")[0].trim();
+ this.startverse = sref.split(":")[1].trim();
+ }
+ else
+ {
+ // no : was found, must be whole chapter.
+ this.startchapter = sref.trim();
+ this.startverse = 1;
+ }
+
+ // if a colon is found, then its a chapter verse combo.
+ if (eref.match(/\:/) != null)
+ {
+ this.endchapter = eref.split(":")[0].trim();
+ this.endverse = eref.split(":")[1].trim();
+ }
+ else
+ {
+ // no : was found, must be whole chapter or a verse range. test secondbook array to find out.
+ if (secondbook.length == 2 || sref.match(/\:/) == null)
+ {
+ // chapter range.
+ this.endchapter = eref.trim();
+ this.endverse = "*";
+ }
+ else
+ {
+ // verse range.
+ this.endchapter = this.startchapter;
+ this.endverse = eref.trim();
+ }
+ }
+ }
+ else
+ {
+ // if no - was found, then the ref can only be a single chapter or single verse.
+ if (ref.match(/\:/) != null)
+ {
+ this.startchapter = ref.split(":")[0].trim();
+ this.endchapter = ref.split(":")[0].trim();
+ this.startverse = ref.split(":")[1].trim(); ;
+ this.endverse = ref.split(":")[1].trim(); ;
+ }
+ else
+ {
+ // no : was found, must be whole chapter.
+ this.startchapter = ref.trim();
+ this.endchapter = ref.trim();
+ this.startverse = 1;
+ this.endverse = "*";
+ }
+
+ }
+
+ // make sure you don't return an invalid chapter.
+ if (this.endchapter > this.lastchapter)
+ {
+ this.endchapter = this.lastchapter;
+ }
+ if (this.startchapter > this.endchapter)
+ {
+ this.startchapter = this.endchapter;
+ }
+ if (this.startchapter == this.endchapter && this.startverse > this.endverse && this.endverse != "*")
+ {
+ this.endverse = this.startverse;
+ }
+}
+
+function bookName(booknum)
+{
+ var book = new Array();
+ book[0] = "";
+ book[1] = "Genesis";
+ book[2] = "Exodus";
+ book[3] = "Leviticus";
+ book[4] = "Numbers";
+ book[5] = "Deuteronomy";
+ book[6] = "Joshua";
+ book[7] = "Judges";
+ book[8] = "Ruth";
+ book[9] = "1 Samuel";
+ book[10] = "2 Samuel";
+ book[11] = "1 Kings";
+ book[12] = "2 Kings";
+ book[13] = "1 Chronicles";
+ book[14] = "2 Chronicles";
+ book[15] = "Ezra";
+ book[16] = "Nehemiah";
+ book[17] = "Esther";
+ book[18] = "Job";
+ book[19] = "Psalm";
+ book[20] = "Proverbs";
+ book[21] = "Ecclesiastes";
+ book[22] = "Song of Songs";
+ book[23] = "Isaiah";
+ book[24] = "Jeremiah";
+ book[25] = "Lamentations";
+ book[26] = "Ezekiel";
+ book[27] = "Daniel";
+ book[28] = "Hosea";
+ book[29] = "Joel";
+ book[30] = "Amos";
+ book[31] = "Obadiah";
+ book[32] = "Jonah";
+ book[33] = "Micah";
+ book[34] = "Nahum";
+ book[35] = "Habakkuk";
+ book[36] = "Zephaniah";
+ book[37] = "Haggai";
+ book[38] = "Zechariah";
+ book[39] = "Malachi";
+ book[40] = "Matthew";
+ book[41] = "Mark";
+ book[42] = "Luke";
+ book[43] = "John";
+ book[44] = "Acts";
+ book[45] = "Romans";
+ book[46] = "1 Corinthians";
+ book[47] = "2 Corinthians";
+ book[48] = "Galatians";
+ book[49] = "Ephesians";
+ book[50] = "Philippians";
+ book[51] = "Colossians";
+ book[52] = "1 Thessalonians";
+ book[53] = "2 Thessalonians";
+ book[54] = "1 Timothy";
+ book[55] = "2 Timothy";
+ book[56] = "Titus";
+ book[57] = "Philemon";
+ book[58] = "Hebrews";
+ book[59] = "James";
+ book[60] = "1 Peter";
+ book[61] = "2 Peter";
+ book[62] = "1 John";
+ book[63] = "2 John";
+ book[64] = "3 John";
+ book[65] = "Jude";
+ book[66] = "Revelation";
+
+ return book[booknum];
+}
\ No newline at end of file
diff --git a/js/common.js b/js/common.js
new file mode 100644
index 00000000..50fa2385
--- /dev/null
+++ b/js/common.js
@@ -0,0 +1,1287 @@
+function SortNumeric(x, y)
+{
+ return x - y
+}
+
+String.prototype.trim = function()
+{
+ return this.replace(/^\s+|\s+$/g, "");
+}
+String.prototype.ltrim = function()
+{
+ return this.replace(/^\s+/, "");
+}
+String.prototype.rtrim = function()
+{
+ return this.replace(/\s+$/, "");
+}
+
+function Traverse(node, testament)
+{
+ try
+ {
+ var treeText = "";
+ if (node != null)
+ {
+ if (node.hasChildNodes())
+ {
+ if (node.nodeName == "s")
+ {
+ // you need to test if this is the OT or NT and set the attribute accordingly.
+ var t = "";
+ if (testament == "old")
+ {
+ t = "H";
+ }
+ if (testament == "new")
+ {
+ t = "G";
+ }
+ treeText += "
" + t + node.getAttribute("n") + "" + Traverse(node.childNodes.item(0), testament) + "";
+ } else
+ {
+ treeText += '<' + node.nodeName + '>';
+ for (var i = 0; i < node.childNodes.length; i++)
+ {
+ treeText += Traverse(node.childNodes.item(i), testament);
+ }
+ treeText += '' + node.nodeName + '>';
+ }
+ } else
+ {
+ if (node.nodeValue != null)
+ {
+ if (node.nodeValue.search(/^(\,|\.|\:|\?|\;|\!)/) != -1)
+ {
+ treeText += node.nodeValue;
+ } else
+ {
+ treeText += " " + node.nodeValue;
+ }
+ }
+ }
+ }
+ return treeText;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+}
+
+function Search(sv)
+{
+ try
+ {
+ var qs = sv.split(";");
+
+ for (var x in qs)
+ {
+ var q = qs[x].trim();
+ if (q != "")
+ {
+ // its a search term.
+ if (q.search(/[0-9]/i) == -1)
+ {
+ // get new results.
+ Words.FindReferences(q);
+ }
+
+ // its a strongs lookup
+ else if (q.search(/(H|G)[0-9]/i) != -1)
+ {
+ var dict = q.substring(0, 1);
+ if (dict.search(/h/i) != -1) { dict = "heb"; } else { dict = "grk"; }
+ q = q.substring(1, q.length);
+ var results = Strongs.GetStrongs(q, dict);
+
+ // display results.
+ Strongs.DisplayStrongs(results);
+
+
+ }
+ // its a verse reference.
+ else
+ {
+ var passage = "";
+ if (q.trim() != "")
+ {
+ var myref = new Reference(q.trim());
+ var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
+
+ Bible.DisplayPassage(r.cs, myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse, r.testament);
+ }
+ }
+ }
+
+ }
+
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+
+ return false;
+}
+
+
+var Settings = {
+ Load: function()
+ {
+ var str = $.cookie('settings');
+ if (str != null)
+ {
+ var s = str.split(",");
+
+ $("#resultwrap").css("float", s[0]);
+ $("#searchresultswrap").css("float", s[0]);
+
+ if (s[1] == "none")
+ {
+ $("#searchresultswrap").css("display", "none");
+ $("#showhidesearch").html("Show Search");
+ $("#resultwrap").css("width", "100%");
+
+ }
+ else
+ {
+ $("#searchresultswrap").css("display", "block");
+ $("#showhidesearch").html("Hide Search");
+ $("#resultwrap").css("width", "70%");
+ }
+
+ $("#result").css("font-size", s[2]);
+ $("#result").css("font-family", s[3]);
+ }
+ },
+ Save: function()
+ {
+ var s = {};
+ s.Panes = $("#resultwrap").css("float");
+ s.Search = $("#searchresultswrap").css("display");
+ s.FontSize = $("#result").css("font-size");
+ s.Font = $("#result").css("font-family");
+
+ var str = s.Panes + "," + s.Search + "," + s.FontSize + "," + s.Font;
+
+ $.cookie('settings', str, { expires: 365 });
+ },
+ ShowHideSearch: function()
+ {
+ var o = $("#showhidesearch");
+ var s = $("#searchresultswrap");
+ var r = $("#resultwrap");
+
+ if (s.css("display") != "none")
+ {
+ s.css("display", "none");
+ o.html("Show Search");
+ r.css("width", "100%");
+
+ }
+ else
+ {
+ s.css("display", "block");
+ o.html("Hide Search");
+ r.css("width", "70%");
+ }
+ this.Save();
+ },
+ SwitchPanes: function()
+ {
+ var s = $("#searchresultswrap");
+ var r = $("#resultwrap");
+ var v = s.css("float");
+ if (v == "right")
+ {
+ s.css("float", "left");
+ r.css("float", "left");
+ }
+ else
+ {
+ s.css("float", "right");
+ r.css("float", "right");
+ }
+ this.Save();
+ },
+ IncreaseResultFontSize: function()
+ {
+ var s = $("#result").css("font-size");
+ $("#result").css("font-size", parseInt(s) + 1);
+ this.Save();
+ },
+ DecreaseResultFontSize: function()
+ {
+ var s = $("#result").css("font-size");
+ $("#result").css("font-size", parseInt(s) - 1);
+ this.Save();
+ },
+ ChangeResultFont: function(fontfamily)
+ {
+ $("#result").css("font-family", fontfamily);
+ this.Save();
+ }
+}
+
+var Util = {
+ HandleLink: function(e)
+ {
+ Search($(e.target).text());
+ },
+ HandleHiddenLink: function(e)
+ {
+ Search($(e.target).find(".searchvalue").text());
+ },
+ RemoveResult: function(e)
+ {
+ $(e.target).parent().parent().remove();
+ },
+ HandleError: function(e)
+ {
+ // for now we're going to put the error in the main result div.
+ var t = $("
" + e + "");
+
+ return false;
+ }
+}
+
+var Bible = {
+ DisplayPassage: function(cs, b, sch, ech, sv, ev, testament)
+ {
+ try
+ {
+ var r = "";
+ // make the end verse pretty.
+ var tvs = cs[cs.length - 1].vs.length;
+
+ if (ev == "*" || ev > tvs)
+ {
+ ev = tvs;
+ }
+
+ for (var j = 0; j < cs.length; j++)
+ {
+ if (sch < ech)
+ {
+ r += "
Chapter: " + cs[j].ch + "";
+ }
+ var vs = cs[j].vs;
+
+ for (var m = 0; m < vs.length; m++)
+ {
+ var v = vs[m];
+
+ r += "
" + $(v).attr("n") + ". ";
+
+ for (var w = 0; w < v.childNodes.length; w++)
+ {
+ r += Traverse(v.childNodes[w], testament);
+ }
+
+
+ r += "
";
+ }
+ }
+ var t = $("
" + "" + bookName(b) + " " + sch + ":" + sv + "-" + ech + ":" + ev + "
" + r + "");
+
+ t.find(".hiddenlink").click(function(e)
+ {
+ Util.HandleHiddenLink(e);
+ });
+ t.find(".removeresult").click(function(e)
+ {
+ Util.RemoveResult(e);
+ });
+ $("#result").prepend(t);
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ GetPassage: function(b, sch, ech, sv, ev)
+ {
+ try
+ {
+ var xml = []; // the verses from the chapter.
+ var cs = []; // the verses requested.
+ var r = {};
+
+ for (var i = sch; i <= ech; i++)
+ {
+ var url = "xml/" + b + "-" + i + ".xml"
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "xml",
+ success: function(d, t, x)
+ {
+ xml.push({ "ch": i, "vs": d });
+ },
+ error: function(request, status, error)
+ {
+ Util.HandleError(error, request);
+ }
+ });
+ }
+
+ for (var j = 0; j < xml.length; j++)
+ {
+ var vs = [];
+ var start;
+ var end;
+
+ // figure out the start verse.
+ if (j == 0)
+ { start = sv; }
+ else
+ { start = 1; }
+
+ if ((j + 1) == xml.length)
+ { end = ev; }
+ else
+ { end = "*"; }
+
+ var tvs = $(xml[j].vs).find("v").length;
+
+ // get the verses requested.
+ if (end == "*" || end > tvs)
+ {
+ end = tvs;
+ }
+
+ for (var i = start; i <= end; i++)
+ {
+ vs.push($(xml[j].vs).find('v[n="' + i + '"]')[0])
+ }
+
+ cs.push({ "ch": xml[j].ch, "vs": vs });
+ }
+
+ r.cs = cs;
+ r.testament = $(xml[0].vs).find("b").attr("testament");
+ return r;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ }
+}
+
+var Strongs = {
+ GetStrongs: function(sn, dict)
+ {
+ try
+ {
+ var self = this;
+ var results = {};
+ var url = dict + parseInt((sn - 1) / 100) + ".xml"
+ if (dict == "grk") { results.prefix = "G"; } else { results.prefix = "H"; }
+ results.sn = sn;
+
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: "xml/" + url,
+ dataType: "xml",
+ success: function(d, t, x)
+ {
+ results.strongs = d;
+ },
+ error: function(request, status, error)
+ {
+ Util.HandleError(error, request);
+ }
+ });
+
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: "xml/cr" + url,
+ dataType: "xml",
+ success: function(d, t, x)
+ {
+ results.crossrefs = d;
+ },
+ error: function(request, status, error)
+ {
+ Util.HandleError(error, request);
+ }
+ });
+
+ if (dict == "grk")
+ {
+ url = "xml/rs" + parseInt((sn - 1) / 1000) + ".xml";
+ // rmac is a two get process.
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "xml",
+ success: function(d, t, x)
+ {
+ results.rmac = d;
+ },
+ error: function(request, status, error)
+ {
+ Util.HandleError(error, request);
+ }
+ });
+
+ // deal with RMAC
+ results.rmaccode = $(results.rmac).find('s[id="' + sn + '"]').attr("r");
+ url = "xml/r-" + results.rmaccode.substring(0, 1) + ".xml";
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "xml",
+ success: function(d, t, x)
+ {
+ results.rmac = d;
+ },
+ error: function(request, status, error)
+ {
+ Util.HandleError(error, request);
+ }
+ });
+ }
+ return results;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+
+ DisplayStrongs: function(r)
+ {
+ try
+ {
+ // first deal with strongs data.
+ var entry = $(r.strongs).find("i#" + r.prefix + r.sn);
+ var title = $(entry).find("t").text();
+ var trans = $(entry).find("tr").text();
+ var pron = $(entry).find("p").text();
+ var desc = Traverse($(entry).find("d")[0]);
+
+ var re = /([hg][0-9]{1,4})/gi;
+
+ desc = desc.replace(re, "
$1");
+
+ // now deal with cross references.
+ var cr = $(r.crossrefs).find("i#" + r.prefix + r.sn).find("rs");
+
+ var crtxt = "
Cross References: Show";
+
+ cr.each(function(i)
+ {
+ crtxt += "" + $(this).find("t").text() + ": ";
+
+ $(this).find("r").each(function(j)
+ {
+ var ref = $(this).attr("r").split(";");
+ crtxt += "" + bookName(ref[0]) + " " + ref[1] + ":" + ref[2] + ", ";
+ });
+ crtxt = crtxt.substr(0, crtxt.length - 2);
+ crtxt += "
";
+ });
+ crtxt += " ";
+
+ // ...processing statements go here...
+ var rtxt = "";
+ if (r.prefix == "G")
+ {
+ rtxt += "
Robinsons Morphological Analysis Code: " + r.rmaccode + " Show"; ;
+ $(r.rmac).find('i[id="' + r.rmaccode.toUpperCase() + '"]').find("d").each(function()
+ {
+ rtxt += $(this).text() + "
";
+ });
+ rtxt += " ";
+ }
+ // put together the display.
+
+ // ok. we have to do this because click events seem to be cumulative with jquery.
+ var t = $("
" + trans + " (" + r.sn + ") - " + pron + " - " + title + " - " + desc + "
" + rtxt + crtxt + "");
+
+ t.find(".link").click(function(e)
+ {
+ Util.HandleLink(e);
+ });
+ t.find(".removeresult").click(function(e)
+ {
+ Util.RemoveResult(e);
+ });
+
+ t.find(".showhide").click(function(e)
+ {
+ Strongs.ShowHide(e);
+ });
+
+ $("#result").prepend(t);
+ return false;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ ShowHide: function(e)
+ {
+ var o = $(e.target);
+ var c = o.parent().find(".contents");
+
+ if (c.css("display") != "none")
+ {
+ c.css("display", "none");
+ o.html("Show");
+ }
+ else
+ {
+ c.css("display", "inline");
+ o.html("Hide");
+ }
+ }
+}
+
+var Words = {
+ ConvertResultsToArray: function(r)
+ {
+ try
+ {
+ var results = new Array();
+ $(r).each(function()
+ {
+ results.push([$(this).attr("b"), $(this).attr("ch"), $(this).attr("v")]);
+ });
+ return results;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ DisplayResults: function(results, q)
+ {
+ try
+ {
+ var txt = "
";
+
+ var t = $(txt);
+
+ t.find(".link").click(function(e)
+ {
+ Util.HandleLink(e);
+ });
+
+ $("#searchresults").html(t);
+ $("#searchTotal").html(results.length);
+ return false;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ FindReferences: function(q)
+ {
+ try
+ {
+ q = q.toLowerCase();
+ var qs = q.split(" ");
+ var refs;
+ var words = this.BuildIndexArray().sort();
+ var results = new Array();
+
+ // Loop through each query term.
+ for (i = 0; i < qs.length; i++)
+ {
+ var q = qs[i];
+ // For each query term, figure out which xml file it is in, and get it.
+ // getSearchRefs returns an array of references.
+ for (var w = 0; w < words.length; w++)
+ {
+ // If we are at the end of the array, we want to use a different test.
+ if (w == words.length)
+ {
+ if (q >= words[w])
+ {
+
+ results.unshift(this.ConvertResultsToArray(this.GetSearchReferences("index/i" + words[w] + ".xml", q)));
+ break;
+ }
+ } else
+ {
+ if (q >= words[w] && q < words[w + 1])
+ {
+ results.unshift(this.ConvertResultsToArray(this.GetSearchReferences("index/i" + words[w] + ".xml", q)));
+ break;
+ }
+ }
+ }
+ } // End of loop through query terms
+
+ // Now we need to test results. If there is more than one item in the array, we need to find the set
+ // that is shared by all of them. IF not, we can just return those refs.
+ if (results.length == 1)
+ {
+ this.DisplayResults(results[0], q);
+ } else
+ {
+ this.DisplayResults(this.FindSharedSet(results), q);
+ }
+
+ return false;
+
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ GetSearchReferences: function(url, query)
+ {
+ try
+ {
+ // getSearchRefs takes a url and uses ajax to retrieve the references and returns an array of references.
+ var r;
+
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "xml",
+ success: function(d, t, x)
+ {
+ r = d;
+ },
+ error: function(request, status, error)
+ {
+ Util.HandleError(error, request);
+ }
+ });
+
+ // find the right word
+ var refs = $(r).find('i[w="' + query + '"]').children();
+
+ return refs;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ BuildIndexArray: function()
+ {
+ try
+ {
+ var words = new Array();
+ words.unshift('abhorring');
+ words.unshift('abinoam');
+ words.unshift('abounding');
+ words.unshift('acceptest');
+ words.unshift('accuseth');
+ words.unshift('acquainting');
+ words.unshift('addeth');
+ words.unshift('admonition');
+ words.unshift('adulteries');
+ words.unshift('affected');
+ words.unshift('afterwards');
+ words.unshift('aharah');
+ words.unshift('ahio');
+ words.unshift('aijalon');
+ words.unshift('aliah');
+ words.unshift('alms');
+ words.unshift('amad');
+ words.unshift('amerce');
+ words.unshift('amos');
+ words.unshift('ancestors');
+ words.unshift('annas');
+ words.unshift('antothite');
+ words.unshift('apostleship');
+ words.unshift('apples');
+ words.unshift('arabia');
+ words.unshift('ardites');
+ words.unshift('ark');
+ words.unshift('array');
+ words.unshift('asarelah');
+ words.unshift('ashkelon');
+ words.unshift('aspatha');
+ words.unshift('assurance');
+ words.unshift('athenians');
+ words.unshift('augment');
+ words.unshift('await');
+ words.unshift('azem');
+ words.unshift('baana');
+ words.unshift('backslider');
+ words.unshift('balah');
+ words.unshift('baptism');
+ words.unshift('bark');
+ words.unshift('basin');
+ words.unshift('bazluth');
+ words.unshift('beauties');
+ words.unshift('beelzebub');
+ words.unshift('beggar');
+ words.unshift('beholdeth');
+ words.unshift('belong');
+ words.unshift('benjamite');
+ words.unshift('berothai');
+ words.unshift('bethel');
+ words.unshift('bewailed');
+ words.unshift('bilhah');
+ words.unshift('biteth');
+ words.unshift('blasphemers');
+ words.unshift('blind');
+ words.unshift('boanerges');
+ words.unshift('bold');
+ words.unshift('booties');
+ words.unshift('boughs');
+ words.unshift('bracelet');
+ words.unshift('breakest');
+ words.unshift('bride');
+ words.unshift('broken');
+ words.unshift('bucklers');
+ words.unshift('bulwarks');
+ words.unshift('bush');
+ words.unshift('cab');
+ words.unshift('calleth');
+ words.unshift('canaanitish');
+ words.unshift('carbuncle');
+ words.unshift('carpenter');
+ words.unshift('casteth');
+ words.unshift('ceased');
+ words.unshift('chain');
+ words.unshift('changers');
+ words.unshift('chariots');
+ words.unshift('chedorlaomer');
+ words.unshift('cherished');
+ words.unshift('child');
+ words.unshift('choosest');
+ words.unshift('cinnamon');
+ words.unshift('claudius');
+ words.unshift('climb');
+ words.unshift('cluster');
+ words.unshift('color');
+ words.unshift('comings');
+ words.unshift('commonly');
+ words.unshift('compassed');
+ words.unshift('conceit');
+ words.unshift('condition');
+ words.unshift('confirming');
+ words.unshift('consent');
+ words.unshift('consultation');
+ words.unshift('content');
+ words.unshift('convert');
+ words.unshift('cord');
+ words.unshift('corruptly');
+ words.unshift('countenances');
+ words.unshift('covenants');
+ words.unshift('crag');
+ words.unshift('cried');
+ words.unshift('crowns');
+ words.unshift('cups');
+ words.unshift('cuth');
+ words.unshift('dalmatia');
+ words.unshift('darda');
+ words.unshift('dawning');
+ words.unshift('deaths');
+ words.unshift('deceiver');
+ words.unshift('decrees');
+ words.unshift('defer');
+ words.unshift('deliciously');
+ words.unshift('den');
+ words.unshift('descendeth');
+ words.unshift('despair');
+ words.unshift('determinate');
+ words.unshift('dew');
+ words.unshift('diggedst');
+ words.unshift('dip');
+ words.unshift('disciple');
+ words.unshift('disguised');
+ words.unshift('displease');
+ words.unshift('dissolvest');
+ words.unshift('divideth');
+ words.unshift('doers');
+ words.unshift('doubled');
+ words.unshift('drawers');
+ words.unshift('drinking');
+ words.unshift('drunken');
+ words.unshift('dwellers');
+ words.unshift('earthquakes');
+ words.unshift('edar');
+ words.unshift('eglon');
+ words.unshift('elder');
+ words.unshift('eliashib');
+ words.unshift('elishua');
+ words.unshift('elymas');
+ words.unshift('emptied');
+ words.unshift('encumbereth');
+ words.unshift('enfolding');
+ words.unshift('enos');
+ words.unshift('entrance');
+ words.unshift('ephesian');
+ words.unshift('eranites');
+ words.unshift('eshcol');
+ words.unshift('esteeming');
+ words.unshift('euroclydon');
+ words.unshift('evilfavoredness');
+ words.unshift('exceeding');
+ words.unshift('execution');
+ words.unshift('expound');
+ words.unshift('ezbon');
+ words.unshift('fainted');
+ words.unshift('familiar');
+ words.unshift('fasted');
+ words.unshift('favorable');
+ words.unshift('feedest');
+ words.unshift('fence');
+ words.unshift('fifteenth');
+ words.unshift('filthy');
+ words.unshift('firstfruit');
+ words.unshift('flags');
+ words.unshift('fleshhooks');
+ words.unshift('floweth');
+ words.unshift('followeth');
+ words.unshift('forbore');
+ words.unshift('foreseeth');
+ words.unshift('forgiveness');
+ words.unshift('fort');
+ words.unshift('fountains');
+ words.unshift('freed');
+ words.unshift('front');
+ words.unshift('fully');
+ words.unshift('gad');
+ words.unshift('galilaeans');
+ words.unshift('garmite');
+ words.unshift('gaze');
+ words.unshift('genealogy');
+ words.unshift('geshurites');
+ words.unshift('gideon');
+ words.unshift('girding');
+ words.unshift('glass');
+ words.unshift('gnasheth');
+ words.unshift('gog');
+ words.unshift('gorgeously');
+ words.unshift('grasshopper');
+ words.unshift('greediness');
+ words.unshift('grinding');
+ words.unshift('guests');
+ words.unshift('habergeons');
+ words.unshift('hadst');
+ words.unshift('hakupha');
+ words.unshift('hammer');
+ words.unshift('handkerchiefs');
+ words.unshift('hanun');
+ words.unshift('hare');
+ words.unshift('harpers');
+ words.unshift('hashum');
+ words.unshift('hateth');
+ words.unshift('hazael');
+ words.unshift('healed');
+ words.unshift('hearth');
+ words.unshift('hedged');
+ words.unshift('helez');
+ words.unshift('hena');
+ words.unshift('heresy');
+ words.unshift('hewed');
+ words.unshift('higher');
+ words.unshift('hiram');
+ words.unshift('hodaiah');
+ words.unshift('holy');
+ words.unshift('hopeth');
+ words.unshift('horseback');
+ words.unshift('household');
+ words.unshift('humiliation');
+ words.unshift('hurl');
+ words.unshift('hypocrisy');
+ words.unshift('idolatry');
+ words.unshift('imagined');
+ words.unshift('impoverish');
+ words.unshift('increasest');
+ words.unshift('inflicted');
+ words.unshift('inkhorn');
+ words.unshift('instructor');
+ words.unshift('into');
+ words.unshift('is');
+ words.unshift('islands');
+ words.unshift('ithmah');
+ words.unshift('jaalam');
+ words.unshift('jadon');
+ words.unshift('jakeh');
+ words.unshift('jarkon');
+ words.unshift('jeaterai');
+ words.unshift('jehieli');
+ words.unshift('jehudijah');
+ words.unshift('jerimoth');
+ words.unshift('jesse');
+ words.unshift('jeziah');
+ words.unshift('joed');
+ words.unshift('jona');
+ words.unshift('josiphiah');
+ words.unshift('juda');
+ words.unshift('justification');
+ words.unshift('kedemoth');
+ words.unshift('kernels');
+ words.unshift('kindle');
+ words.unshift('kishion');
+ words.unshift('knocketh');
+ words.unshift('laban');
+ words.unshift('lady');
+ words.unshift('lancets');
+ words.unshift('lasea');
+ words.unshift('lawfully');
+ words.unshift('leannoth');
+ words.unshift('led');
+ words.unshift('leopard');
+ words.unshift('lewdly');
+ words.unshift('liest');
+ words.unshift('lign');
+ words.unshift('lintels');
+ words.unshift('lo');
+ words.unshift('lofty');
+ words.unshift('lords');
+ words.unshift('lowering');
+ words.unshift('lusty');
+ words.unshift('maaziah');
+ words.unshift('magicians');
+ words.unshift('mahol');
+ words.unshift('maktesh');
+ words.unshift('manaen');
+ words.unshift('maoch');
+ words.unshift('marred');
+ words.unshift('masrekah');
+ words.unshift('matthew');
+ words.unshift('measured');
+ words.unshift('meet');
+ words.unshift('melita');
+ words.unshift('mentioned');
+ words.unshift('merodach');
+ words.unshift('messes');
+ words.unshift('michmash');
+ words.unshift('mijamin');
+ words.unshift('minds');
+ words.unshift('mirth');
+ words.unshift('missing');
+ words.unshift('mock');
+ words.unshift('moneychangers');
+ words.unshift('mosera');
+ words.unshift('mouths');
+ words.unshift('munition');
+ words.unshift('mustereth');
+ words.unshift('nabal');
+ words.unshift('naioth');
+ words.unshift('naturally');
+ words.unshift('nebo');
+ words.unshift('neglecting');
+ words.unshift('nephtoah');
+ words.unshift('new');
+ words.unshift('nineteenth');
+ words.unshift('noon');
+ words.unshift('nourishing');
+ words.unshift('obed');
+ words.unshift('obtained');
+ words.unshift('offenses');
+ words.unshift('oldness');
+ words.unshift('ono');
+ words.unshift('oppress');
+ words.unshift('ordinary');
+ words.unshift('our');
+ words.unshift('overcometh');
+ words.unshift('overtaken');
+ words.unshift('ozias');
+ words.unshift('palace');
+ words.unshift('paphos');
+ words.unshift('part');
+ words.unshift('pass');
+ words.unshift('patience');
+ words.unshift('peaceable');
+ words.unshift('pelonite');
+ words.unshift('perfect');
+ words.unshift('perizzite');
+ words.unshift('persons');
+ words.unshift('pethor');
+ words.unshift('philemon');
+ words.unshift('pictures');
+ words.unshift('pine');
+ words.unshift('pithon');
+ words.unshift('planters');
+ words.unshift('please');
+ words.unshift('plucketh');
+ words.unshift('pommels');
+ words.unshift('portray');
+ words.unshift('pound');
+ words.unshift('pray');
+ words.unshift('prepare');
+ words.unshift('presume');
+ words.unshift('princess');
+ words.unshift('prochorus');
+ words.unshift('progenitors');
+ words.unshift('prophesyings');
+ words.unshift('proverb');
+ words.unshift('psalm');
+ words.unshift('pulse');
+ words.unshift('purim');
+ words.unshift('puttest');
+ words.unshift('quickened');
+ words.unshift('rachal');
+ words.unshift('raiser');
+ words.unshift('ransomed');
+ words.unshift('readeth');
+ words.unshift('rebel');
+ words.unshift('reckoned');
+ words.unshift('redeemedst');
+ words.unshift('refuse');
+ words.unshift('reigneth');
+ words.unshift('remainest');
+ words.unshift('rendered');
+ words.unshift('repentest');
+ words.unshift('reproofs');
+ words.unshift('reserve');
+ words.unshift('restoreth');
+ words.unshift('revealeth');
+ words.unshift('revolt');
+ words.unshift('richly');
+ words.unshift('rinsed');
+ words.unshift('roaring');
+ words.unshift('rohgah');
+ words.unshift('rottenness');
+ words.unshift('ruins');
+ words.unshift('s');
+ words.unshift('sadducees');
+ words.unshift('salcah');
+ words.unshift('samaritans');
+ words.unshift('sapphire');
+ words.unshift('satyr');
+ words.unshift('scabbed');
+ words.unshift('scoff');
+ words.unshift('scribes');
+ words.unshift('seas');
+ words.unshift('seduced');
+ words.unshift('seir');
+ words.unshift('sending');
+ words.unshift('serah');
+ words.unshift('settest');
+ words.unshift('shaalbonite');
+ words.unshift('shalim');
+ words.unshift('shammah');
+ words.unshift('sharpeneth');
+ words.unshift('sheaves');
+ words.unshift('sheepskins');
+ words.unshift('shemidaites');
+ words.unshift('sheth');
+ words.unshift('shimeath');
+ words.unshift('shiphrah');
+ words.unshift('shoco');
+ words.unshift('shoulders');
+ words.unshift('shubael');
+ words.unshift('sibbecai');
+ words.unshift('sighs');
+ words.unshift('silverlings');
+ words.unshift('single');
+ words.unshift('sitnah');
+ words.unshift('skippedst');
+ words.unshift('sleeper');
+ words.unshift('slowly');
+ words.unshift('smooth');
+ words.unshift('soberness');
+ words.unshift('sold');
+ words.unshift('soothsayer');
+ words.unshift('sosipater');
+ words.unshift('space');
+ words.unshift('spears');
+ words.unshift('spikenard');
+ words.unshift('spokes');
+ words.unshift('sprinkled');
+ words.unshift('stalled');
+ words.unshift('staves');
+ words.unshift('steward');
+ words.unshift('stocks');
+ words.unshift('storehouse');
+ words.unshift('strangled');
+ words.unshift('striker');
+ words.unshift('struck');
+ words.unshift('subjection');
+ words.unshift('suchathites');
+ words.unshift('summer');
+ words.unshift('supply');
+ words.unshift('sustenance');
+ words.unshift('swellings');
+ words.unshift('syntyche');
+ words.unshift('tachmonite');
+ words.unshift('tales');
+ words.unshift('tarea');
+ words.unshift('taunting');
+ words.unshift('tekoa');
+ words.unshift('temple');
+ words.unshift('teresh');
+ words.unshift('thahash');
+ words.unshift('themselves');
+ words.unshift('thick');
+ words.unshift('thirteenth');
+ words.unshift('threatening');
+ words.unshift('throughout');
+ words.unshift('tidings');
+ words.unshift('timnathserah');
+ words.unshift('tittle');
+ words.unshift('tolerable');
+ words.unshift('tormentors');
+ words.unshift('trading');
+ words.unshift('translated');
+ words.unshift('treason');
+ words.unshift('tribulations');
+ words.unshift('troublest');
+ words.unshift('tubal');
+ words.unshift('twins');
+ words.unshift('uncircumcised');
+ words.unshift('undertook');
+ words.unshift('unleavened');
+ words.unshift('unsearchable');
+ words.unshift('upbraideth');
+ words.unshift('uriel');
+ words.unshift('uzai');
+ words.unshift('vaniah');
+ words.unshift('venture');
+ words.unshift('vilely');
+ words.unshift('virtuous');
+ words.unshift('vowedst');
+ words.unshift('waketh');
+ words.unshift('wanton');
+ words.unshift('wash');
+ words.unshift('watchtower');
+ words.unshift('wayfaring');
+ words.unshift('weather');
+ words.unshift('well');
+ words.unshift('when');
+ words.unshift('which');
+ words.unshift('whips');
+ words.unshift('whoremongers');
+ words.unshift('willing');
+ words.unshift('winneth');
+ words.unshift('withdraw');
+ words.unshift('wives');
+ words.unshift('woods');
+ words.unshift('worshiped');
+ words.unshift('wrath');
+ words.unshift('wrongeth');
+ words.unshift('yoke');
+ words.unshift('zaccai');
+ words.unshift('zareth');
+ words.unshift('zedad');
+ words.unshift('zereda');
+ words.unshift('ziklag');
+ words.unshift('zoba');
+ return words;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ FindSharedSet: function(results)
+ {
+ try
+ {
+ // FindSharedSet takes an array of reference arrays, and figures out which references are shared
+ // by all arrays/sets, then returns a single array of references.
+
+ for (var j in results)
+ {
+ var refs = results[j];
+
+ for (var i = 0; i < refs.length; i++)
+ {
+ var r = refs[i];
+ // convert references to single integers.
+ // Book * 100000, Chapter * 1000, Verse remains same, add all together.
+ var ref = parseInt(r[0]) * 100000000;
+ ref = ref + parseInt(r[1]) * 10000;
+ ref = ref + parseInt(r[2]);
+ results[j][i] = ref;
+ }
+ }
+
+ // get the first result
+ var result = results[0];
+
+ // for each additional result, get the shared set
+ for (var i = 1; i < results.length; i++)
+ {
+ result = this.ReturnSharedSet(results[i], result);
+ }
+
+ // convert the references back into book, chapter and verse.
+ for (var i = 0; i < result.length; i++)
+ {
+ var ref = result[i];
+ result[i] = [parseInt(ref / 100000000), parseInt((ref % 100000000) / 10000), ((ref % 100000000) % 10000)];
+ }
+
+ return result;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ },
+ ReturnSharedSet: function(x, y)
+ {
+ try
+ {
+ ///
+ /// Takes two javascript arrays and returns an array
+ /// containing a set of values shared by arrays.
+ ///
+
+ // declare iterator
+ var i = 0;
+
+ // declare terminator
+ var t = (x.length < y.length) ? x.length : y.length
+
+ // sort the arrays
+ x.sort(SortNumeric);
+ y.sort(SortNumeric);
+
+ // in this loop, we remove from the arrays, the
+ // values that aren't shared between them.
+ while (i < t)
+ {
+ if (x[i] == y[i])
+ {
+ i++;
+ }
+ if (x[i] < y[i])
+ {
+ x.splice(i, 1);
+ }
+ if (x[i] > y[i])
+ {
+ y.splice(i, 1);
+ }
+ t = (x.length < y.length) ? x.length : y.length;
+
+ // we have to make sure to remove any extra values
+ // at the end of an array when we reach the end of
+ // the other.
+ if (t == i && t < x.length) { x.splice(i, x.length - i); }
+ if (t == i && t < y.length) { y.splice(i, x.length - i); }
+ }
+ // we could return y, because at this time, both arrays
+ // are identical.
+ return x;
+ }
+ catch (err)
+ {
+ Util.HandleError(err);
+ }
+ }
+}
\ No newline at end of file