function applyParameters() {
     // Use URL to determine initial properties of page
     // Called from index.html

  var parametersURL = document.location.href;
  var parameters = parametersURL.split("/");
  parameters = parameters[parameters.length-1];
  if (parameters.match("index.html")) { parameters = parameters.replace("index.html", ""); }

  var userlang = "en";
  if (parameters.match(/lang=fr/)) {
    userlang = "fr";
    document.myForm.languages[5].selected = true;
  }
  else if (parameters.match(/lang=es/)) {
    userlang = "es";
    document.myForm.languages[3].selected = true;
  }
  else {
    userlang = "en";
    document.myForm.languages[2].selected = true;
  }

  if (parameters.match("0")) { toggleLayer("advanced"); }
  if (parameters.match("1")) { document.myForm.autoscroll.checked = false }
  if (parameters.match("2")) { document.myForm.highlight.checked = false }
  if (parameters.match("3")) { document.myForm.withhref.checked = true }
  if (parameters.match("4")) { document.myForm.newwindow.checked = true }

       if (parameters.match(/[^=]da/)) { document.myForm.languages[0].selected = true; }
  else if (parameters.match(/[^=]de/)) { document.myForm.languages[1].selected = true; }
  else if (parameters.match(/[^=]en/)) { document.myForm.languages[2].selected = true; }
  else if (parameters.match(/[^=]es/)) { document.myForm.languages[3].selected = true; }
  else if (parameters.match(/[^=]fi/)) { document.myForm.languages[4].selected = true; }
  else if (parameters.match(/[^=]fr/)) { document.myForm.languages[5].selected = true; }
  else if (parameters.match(/[^=]hu/)) { document.myForm.languages[6].selected = true; }
  else if (parameters.match(/[^=]it/)) { document.myForm.languages[7].selected = true; }
  else if (parameters.match(/[^=]nl/)) { document.myForm.languages[8].selected = true; }
  else if (parameters.match(/[^=]no/)) { document.myForm.languages[9].selected = true; }
  else if (parameters.match(/[^=]pt/)) { document.myForm.languages[10].selected = true; }
  else if (parameters.match(/[^=]sv/)) { document.myForm.languages[11].selected = true; }
  else if (parameters.match(/[^=]to/)) { document.myForm.languages[12].selected = true; }
  else {  }

  if (userlang == "en") {
    document.title = "Scripture Reference URL Generator";
    document.getElementById("title").innerHTML = "Scripture References";
    document.getElementById("description").innerHTML = "This tool generates web addresses for <a href='http://scriptures.lds.org/' target='_blank'>online scriptures</a>, from a scripture reference that you type in. The script supports any chapter, verse, or series of verses from the <a href='http://www.mormonwiki.com/Old_Testament' target='_blank'><i>Old Testament</i></a> (KJV), the <a href='http://www.mormonwiki.com/New_Testament' target='_blank'><i>New Testament</i></a> (KJV), the <a href='http://www.mormonwiki.com/Book_of_Mormon' target='_blank'><i>Book of Mormon</i></a>, the <a href='http://www.mormonwiki.com/Doctrine_and_Covenants' target='_blank'><i>Doctrine and Covenants</i></a>, or the <a href='http://www.mormonwiki.com/Pearl_of_Great_Price' target='_blank'><i>Pearl of Great Price</i></a>.";
    document.getElementById("title2").innerHTML = "Generate Scripture URLs";
    document.getElementById("label-inputref").innerHTML = "Scripture Reference:";
    document.getElementById("toggle-advanced").innerHTML = "(Advanced options)";
    document.getElementById("label-autoscroll").innerHTML = "Auto scroll (include anchor tag)";
    document.getElementById("label-highlight").innerHTML = "Highlight specified verses";
    document.getElementById("label-withhref").innerHTML = "Output as HTML hyperlink";
    document.getElementById("label-newwindow").innerHTML = "Automatically open link in new window";
    document.getElementById("label-languages").innerHTML = "Destination URL language:";
    document.getElementById("asterisk-note").innerHTML = "Other languages currently supported for Book of Mormon, Doctrine and Covenants, and Pearl of Great Price references only.";
    document.myForm.submission.value = "Get Scripture URL";
    document.getElementById("lastupdate").innerHTML = "Last updated: ";
    document.getElementById("howtouse").innerHTML = "How to use this page";
    document.getElementById("howtouse").href = "help.html?lang=en";
  }
  else if (userlang == "fr") {
    document.title = "G\351n\351rateur d'URL de r\351f\351rences d'Ecriture";
    document.getElementById("title").innerHTML = "R\351f\351rences des Ecritures";
    document.getElementById("description").innerHTML = "Cet outil g\351n\350re des adresses de sites Web pour les <a href='http://scriptures.lds.org/fr/' target='_blank'>Ecritures sur internet</a>, \340 partir d'une r\351f\351rence d'\351criture que vous tapez. Le script marche pour quelconque chapitre, verset ou  s\351rie de versets du <a href='http://fr.mormonwiki.com/Livre_de_Mormon' target='_blank'><i>Livre de Mormon</i></a>, des <a href='http://fr.mormonwiki.com/Doctrine_et_Alliances' target='_blank'><i>Doctrine et Alliances</i></a> ou de la <a href='http://fr.mormonwiki.com/Perle_de_Grand_Prix' target='_blank'><i>Perle de Grand Prix</i></a>.";
    document.getElementById("title2").innerHTML = "G\351n\350rer URLs d'Ecriture";
    document.getElementById("label-inputref").innerHTML = "R\351f\351rence d'Ecriture :";
    document.getElementById("toggle-advanced").innerHTML = "(Options avanc\351es)";
    document.getElementById("label-autoscroll").innerHTML = "Auto d\351filer (ajouter balise ancre)";
    document.getElementById("label-highlight").innerHTML = "Surligner les versets sp\351cifi\351es";
    document.getElementById("label-withhref").innerHTML = "Sortie en lien hypertexte HTML";
    document.getElementById("label-newwindow").innerHTML = "Ouvrir automatiquement le lien dans une nouvelle fen\352tre";
    document.getElementById("label-languages").innerHTML = "Langue d'URL de destination :";
    document.getElementById("asterisk-note").innerHTML = "Langues autrement d'anglais actuellement ne marchent que pour les r\351f\351rences dans le Livre de Mormon, les Doctrine et Alliances, et la Perle de Grand Prix.";
    document.myForm.submission.value = "Chercher l'URL de l'Ecriture";
    document.getElementById("lastupdate").innerHTML = "Mise \340 jour: ";
    document.getElementById("howtouse").innerHTML = "Comment utiliser cette page";
    document.getElementById("howtouse").href = "help.html?lang=fr";
  }
  else if (userlang == "es") {
    document.title = "Generador de URL de las referencias de las Escrituras";
    document.getElementById("title").innerHTML = "Referencias de las Escrituras";
    document.getElementById("description").innerHTML = "Este instrumento genera des direcciones webs para las <a href='http://scriptures.lds.org/es/' target='_blank'>Escrituras en Internet</a>, a partir de un texto de referencia que escribe. El script funciona para cualquier cap\355tulo, vers\355culo o serie de vers\355culos del <a href='http://es.mormonwiki.com/Antiguo_Testamento' target='_blank'><i>Antiguo Testamento</i></a> (RV 2009), del <a href='http://es.mormonwiki.com/Nuevo_Testamento' target='_blank'><i>Nuevo Testamento</i></a> (RV 2009), del <a href='http://es.mormonwiki.com/Libro_de_Morm\363n' target='_blank'><i>Libro de Morm\363n</i></a>, de los <a href='http://es.mormonwiki.com/Doctrina_y_Convenios' target='_blank'><i>Doctrina y Convenios</i></a> o de la <a href='http://es.mormonwiki.com/La_Perla_de_Gran_Precio' target='_blank'><i>Perla de Gran Precio</i></a>.";
    document.getElementById("title2").innerHTML = "Generar URLs de las Escrituras";
    document.getElementById("label-inputref").innerHTML = "Referencia de la Escritura:";
    document.getElementById("toggle-advanced").innerHTML = "(Opciones avanzadas)";
    document.getElementById("label-autoscroll").innerHTML = "Auto avanzar (a\361adir identificador de fragmento)";
    document.getElementById("label-highlight").innerHTML = "Resaltar los vers\355culos especificados";
    document.getElementById("label-withhref").innerHTML = "Salida como hiperv\355nculo HTML";
    document.getElementById("label-newwindow").innerHTML = "Abrir\341 autom\341ticamente el enlace en una nueva ventana";
    document.getElementById("label-languages").innerHTML = "Idioma de URL de destino:";
    document.getElementById("asterisk-note").innerHTML = "Hasta septiembre de 2009, solo Ingl\351s funciona para las referencias fuera del Libro de Morm\363n, Doctrina y Convenios y la Perla de Gran Precio.";
    document.myForm.submission.value = "Obtenir el URL de la Escritura";
    document.getElementById("lastupdate").innerHTML = "Actualizaci\363n: ";
    document.getElementById("howtouse").innerHTML = "C\363mo utilizar esta p\341gina web";
    document.getElementById("howtouse").href = "help.html?lang=es";
  }

  document.myForm.inputref.focus();    // focus on input box when page is loaded

}


// ===================================================================================================================

function JavaScriptuReference() {
     // Connect user input and computer output
     // Called from index.html

var language = document.myForm.languages.options[myForm.languages.selectedIndex].value;
var inputref = document.myForm.inputref.value;

var ref = inputref.toLowerCase();                                                // lowercase with arabic numerals
ref = ref.replace(/^iiii /, "4_").replace(/^4th /, "4_").replace(/^fourth /, "4_").replace(/^4 /, "4_").
          replace(/^iii /, "3_").replace(/^3rd /, "3_").replace(/^third /, "3_").replace(/^3 /, "3_").
          replace(/^ii /, "2_").replace(/^2nd /, "2_").replace(/^second /, "2_").replace(/^2 /, "2_").
          replace(/^i /, "1_").replace(/^1st /, "1_").replace(/^first /, "1_").replace(/^1 /, "1_").
          replace(/ ,/g, ",").replace(/, /g, ",").replace(/ (?=\D)/g, "_");      // remove unwanted spaces

ref = ref.split(" ");                  // separate book title from numerical reference

var book = standardizeBook(ref[0], inputref)[0];   // get standard book abbreviation
var i = standardizeBook(ref[0], inputref)[1];      // get location of book in array of abbreviations

var numref = ref[1];                   // define numerical reference alone

if (numref == undefined) {                                                       // if there is no numerical reference specified
  if (book == "obad" || book == "philem" || book == "1_jn" || book == "2_jn" ||
      book == "3_jn" || book == "jude" || book == "enos" || book == "jarom" ||
      book == "omni" || book == "w_of_m" || book == "4_ne" || book == "js_m" ||
      book == "js_h" || book == "a_of_f") { numref = ""; }                       // if the book only has one chapter, do nothing
  else { return alert("Please specify a specific chapter or verse."); }          // otherwise, bring up an error
}

if (numref.match(":")) {               // REFERENCES WITH CHAPTERS AND VERSES
  numref = numref.split(":");
  var chapter = numref[0];
  var verse = numref[1];
  if (verse.match(/\W/)) {             // if there are multiple verses, get first verse number
    var verses = verse.split(/\W/);
    var multipleverses = "true";
    var firstverse = verses[0];
  }
  else if (verse.match(/\D/)) {        // if there is a footnote letter, get only the verse number
    var verses = verse.split(/\D/);
    var multipleverses = "false";
    var firstverse = verses[0];
  }
  else {
    var multipleverses = "false";
    var firstverse = verse;
  }
  var anchor = "#"+firstverse;         // define anchor for auto-scroll
}
else if (book == "obad" || book == "philem" || book == "1_jn" || book == "2_jn" ||
      book == "3_jn" || book == "jude" || book == "enos" || book == "jarom" ||
      book == "omni" || book == "w_of_m" || book == "4_ne" || book == "js_m" ||
      book == "js_h" || book == "a_of_f") {      // SHORT BOOKS WITH ONLY ONE CHAPTER
  if (numref == "") {
    var chapter = "1";
    var multipleverses = "true";
    var verse = "";
    var anchor = "";
  }
  else {
    var chapter = "1";
    var verse = numref;
    if (verse.match(/\W/)) {           // if there are multiple verses, get first verse number
      var verses = verse.split(/\W/);
      var multipleverses = "true";
      var firstverse = verses[0];
    }
    else if (verse.match(/\D/)) {      // if there is a footnote letter, get only the verse number
      var verses = verse.split(/\D/);
      var multipleverses = "false";
      var firstverse = verses[0];
    }
    else {
      var multipleverses = "false";
      var firstverse = verse;
    }
    var anchor = "#"+firstverse;       // define anchor for auto-scroll
  }
}
else {                                 // NO VERSES SPECIFIED - CHAPTER ONLY
  var chapter = numref;
  var multipleverses = "false";
  var verse = "";
  var anchor = "";
}

if (book == "od") { verse = ""; anchor = ""; }        // get rid of invalid verse numbers for Official Declarations (before url generated)

var outputurl = "http://scriptures.lds.org/"+language+"/"+book+"/"+chapter+"/";           // default url for output
if (document.myForm.highlight.checked == true) { outputurl = outputurl+verse; }           // if checked, highlight specified verses
if (document.myForm.autoscroll.checked == true) { outputurl = outputurl+anchor; }         // if checked, add anchor tag to url

if (i<=65 && language != "en" && language != "es") {
  document.getElementById("hyperlink").innerHTML="Bible not online in this language";     // if scripture not available, create generic hyperlink
  document.getElementById("hyperlink").href="http://scriptures.lds.org/"+language+"/";
  var available = "false";
}
else {
  document.getElementById("hyperlink").innerHTML="Open link in new window &#187;";        // else, create specific hyperlink
  document.getElementById("hyperlink").href=outputurl;
  var available = "true";
}

if (document.myForm.newwindow.checked == true) {                   // if "Automatically open link in new window" is checked
  if (available == "true") {                                       // if scripture is available online, open window in new window
    window.open(outputurl,"","");
  }
  else {                                                           // else, bring up an error message
    alert("Sorry, the Bible is not available at LDS.org in the specified language (only English and Spanish are currently available).");
  }
}

if (book == "a_of_f") { chapter = ""; }                            // hide chapter number for Articles of Faith (after url generated)

if (verse == "" && chapter == "") { var numrefoutput = ""; }       // numerical reference output with neither chapter nor verse (all Articles of Faith)
else if (book == "od") { var numrefoutput = chapter; }             // numerical reference output with chapter but no verse (Official Declaration only)
else if (verse == "") { var numrefoutput = " "+chapter; }          // numerical reference output with chapter but no verse (verses not specified)
else if (chapter == "") { var numrefoutput = " "+verse; }          // numerical reference output with verse but no chapter (specific Articles of Faith)
else { var numrefoutput = " "+chapter+":"+verse; }                 // numerical reference output with chapter and verse

var stndrdwork = standardWorks(i, language);
var readablebook = readableBooks(i, multipleverses, language);
var readablebookc = changeBookLength(readablebook, "condensed", language);

// var readablebook3 = readableBooks(i, "extended", multipleverses, language);
// var readablebook4 = readableBooks(i, "full", multipleverses, language);

document.myForm.inputref.value = readablebookc+numrefoutput;       // replace user input in case of spelling errors

document.getElementById("fullinfo").innerHTML = "<b>"+stndrdwork+"</b><br>"+readablebook+numrefoutput;     // write standard work and reference below

if (document.myForm.withhref.checked == true) { outputurl = "<a href=\""+outputurl+"\">"+readablebookc+numrefoutput+"</a>"; }   // if checked, output url as HTML hyperlink code

document.myForm.urlarea.value = outputurl;                         // output url to textarea
document.myForm.urlarea.select();                                  // select text in textarea

}


// ===================================================================================================================

function standardizeBook(book, inputref) {
     // Convert input book title into a standardized book
     // Called from JavaScriptuReference()
     // - book: unmodified input without the numerical reference
     // - inputref: unmodified input including the numerical reference

book_abrs = new Array("gen","ex","lev","num","deut","josh","judg","ruth","1_sam","2_sam",
                      "1_kgs","2_kgs","1_chr","2_chr","ezra","neh","esth","job","ps","prov",
                      "eccl","song","isa","jer","lam","ezek","dan","hosea","joel","amos",
                      "obad","jonah","micah","nahum","hab","zeph","hag","zech","mal",  // The 39 books of the Old Testament (0-38)
                      "matt","mark","luke","john","acts","rom","1_cor","2_cor","gal","eph",
                      "philip","col","1_thes","2_thes","1_tim","2_tim","titus","philem","heb","james",
                      "1_pet","2_pet","1_jn","2_jn","3_jn","jude","rev",               // The 27 books of the New Testament (39-65)
                      "1_ne","2_ne","jacob","enos","jarom","omni","w_of_m","mosiah","alma","hel",
                      "3_ne","4_ne","morm","ether","moro",    // The 15 books of the Book of Mormon (66-80)
                      "dc","od",                              // The 2 parts of the Doctrine and Covenants (81-82)
                      "moses","abr","js_m","js_h","a_of_f");  // The 5 parts of the Pearl of Great Price (83-87)

for (i in book_abrs) {                           // for every item in the array of abbreviations
  if (book.indexOf(book_abrs[i]) == 0) {         // if the given book starts with one of the abbreviations
    var bookid = i;                              // get the book's number in the array
    book = book_abrs[i];                         // then rename the book to its abbreviation
    var foundbook = "true";
    break;                                       // stop the loop
  }
}

if (foundbook != "true") {                       // spell check and standardization
            // OLD TESTAMENT STANDARDIZATION
       if (book.match(/^ge/)) { book = "gen"; }
  else if (book.match(/^g\351/)) { book = "gen"; }                             // SPANISH
  else if (book.match(/^\351x/)) { book = "ex"; }                              // SPANISH
  else if (book.match(/^l.v/) || book.match(/^le/)) { book = "lev"; }
  else if (book.match(/^l\351/)) { book = "lev"; }                             // FRENCH
  else if (book.match(/^nu/)) { book = "num"; }
  else if (book.match(/^n\372/)) { book = "num"; }                             // SPANISH
  else if (book.match(/^no/)) { book = "num"; }                                // FRENCH
  else if (book.match(/^du/) || book.match(/^de/)) { book = "deut"; }
  else if (book.match(/^jos/)) { book = "josh"; }
  else if (book.match(/^jug/) || book.match(/^jg/)) { book = "judg"; }
  else if (book.match(/^jue/)) { book = "judg"; }                              // SPANISH
  else if (book.match(/^ru/)) { book = "ruth"; }
  else if (book.match(/^1_s/)) { book = "1_sam"; }
  else if (book.match(/^2_s/)) { book = "2_sam"; }
  else if (book.match(/^1_k/)) { book = "1_kgs"; }
  else if (book.match(/^1_r/)) { book = "1_kgs"; }                             // FRENCH/SPANISH
  else if (book.match(/^2_k/)) { book = "2_kgs"; }
  else if (book.match(/^2_r/)) { book = "2_kgs"; }                             // FRENCH/SPANISH
  else if (book.match(/^1_ch/) || book.match(/^1_cr/)) { book = "1_chr"; }
  else if (book.match(/^2_ch/) || book.match(/^2_cr/)) { book = "2_chr"; }
  else if (book.match(/^ezr/) || book.match(/^esr/)) { book = "ezra"; }
  else if (book.match(/^esd/)) { book = "ezra"; }                              // FRENCH/SPANISH
  else if (book.match(/^ne/)) { book = "neh"; }
  else if (book.match(/^n\351/)) { book = "neh"; }                             // FRENCH
  else if (book.match(/^est/)) { book = "esth"; }
  else if (book.match(/^jo.b/)) { book = "job"; }
  else if (book.match(/^sal/)) { book = "ps"; }
  else if (book.match(/^pr/)) { book = "prov"; }
  else if (book.match(/^.c/)) { book = "eccl"; }
  else if (book.match(/^sol.m.n$/) || book.match(/^son/)) { book = "song"; }
  else if (book.match(/^ca/)) { book = "song"; }                               // FRENCH/SPANISH
  else if (book.match(/^is/)) { book = "isa"; }
  else if (book.match(/^es$/)) { book = "isa"; }                               // FRENCH
  else if (book.match(/^\351s/)) { book = "isa"; }                             // FRENCH
  else if (book.match(/^je$/)) { book = "jer"; }
  else if (book.match(/^j\351/)) { book = "jer"; }                             // FRENCH
  else if (book.match(/^la/)) { book = "lam"; }
  else if (book.match(/^ez/)) { book = "ezek"; }
  else if (book.match(/^\351z/)) { book = "ezek"; }                            // FRENCH
  else if (book.match(/^da/)) { book = "dan"; }
  else if (book.match(/^ho/)) { book = "hosea"; }
  else if (book.match(/^os/)) { book = "hosea"; }                              // FRENCH/SPANISH
  else if (book.match(/^joe/) || book.match(/^joa?l/)) { book = "joel"; }
  else if (book.match(/^jo\353/)) { book = "joel"; }                           // FRENCH
  else if (book.match(/^am/) || book.match(/^a.m.s/)) { book = "amos"; }
  else if (book.match(/^ob/)) { book = "obad"; }
  else if (book.match(/^abd/)) { book = "obad"; }                              // FRENCH/SPANISH
  else if (book.match(/^jon/) || book.match(/^joan/)) { book = "jonah"; }
  else if (book.match(/^mi/)) { book = "micah"; }
  else if (book.match(/^na/)) { book = "nahum"; }
  else if (book.match(/^ha/) || book.match(/^hub/)) { book = "hab"; }
  else if (book.match(/^zef/)) { book = "zeph"; }
  else if (book.match(/^so/)) { book = "zeph"; }                               // FRENCH/SPANISH
  else if (book.match(/^ag/)) { book = "hag"; }                                // FRENCH
  else if (book.match(/^za/) || book.match(/^zec/)) { book = "zech"; }
            // NEW TESTAMENT STANDARDIZATION
  else if (book.match(/^mat/)) { book = "matt"; }
  else if (book.match(/^mt/)) { book = "matt"; }                               // FRENCH
  else if (book.match(/^mar/)) { book = "mark"; }
  else if (book.match(/^mc/)) { book = "mark"; }                               // FRENCH
  else if (book.match(/^lu/)) { book = "luke"; }
  else if (book.match(/^jn/)) { book = "john"; }
  else if (book.match(/^jua/)) { book = "john"; }                              // SPANISH
  else if (book.match(/^ac/) || book.match(/^ax/)) { book = "acts"; }
  else if (book.match(/^hec/)) { book = "acts"; }                              // SPANISH
  else if (book.match(/^ro/)) { book = "rom"; }
  else if (book.match(/^1_co/)) { book = "1_cor"; }
  else if (book.match(/^2_co/)) { book = "2_cor"; }
  else if (book.match(/^g/)) { book = "gal"; }
  else if (book.match(/^ep/) || book.match(/^ef/)) { book = "eph"; }
  else if (book.match(/^\351p/)) { book = "eph"; }                             // FRENCH
  else if (book.match(/^phil+i/) || book.match(/^fil+i/)) { book = "philip"; }
  else if (book.match(/^cal/)) { book = "col"; }
  else if (book.match(/^1_th/)) { book = "1_thes"; }
  else if (book.match(/^1_te/)) { book = "1_thes"; }                           // SPANISH
  else if (book.match(/^2_th/)) { book = "2_thes"; }
  else if (book.match(/^2_te/)) { book = "2_thes"; }                           // SPANISH
  else if (book.match(/^1_ti/)) { book = "1_tim"; }
  else if (book.match(/^2_ti/)) { book = "2_tim"; }
  else if (book.match(/^t.t/)) { book = "titus"; }
  else if (book.match(/^phil+e/) || book.match(/^fil+e/)) { book = "philem"; }
  else if (book.match(/^phm/)) { book = "philem"; }                            // FRENCH
  else if (book.match(/^h\351/)) { book = "heb"; }                             // FRENCH
  else if (book.match(/^ja/)) { book = "james"; }
  else if (book.match(/^san/) || book.match(/^stg/)) { book = "james"; }       // SPANISH
  else if (book.match(/^1_p/)) { book = "1_pet"; }
  else if (book.match(/^2_p/)) { book = "2_pet"; }
  else if (book.match(/^1_j/)) { book = "1_jn"; }
  else if (book.match(/^2_j/)) { book = "2_jn"; }
  else if (book.match(/^3_j/)) { book = "3_jn"; }
  else if (book.match(/^ju/) || book.match(/^jew/)) { book = "jude"; }
  else if (book.match(/^re/)) { book = "rev"; }
  else if (book.match(/^ap/)) { book = "rev"; }                                // FRENCH/SPANISH
            // BOOK OF MORMON STANDARDIZATION
  else if (book.match(/^1_n/)) { book = "1_ne"; }
  else if (book.match(/^2_n/)) { book = "2_ne"; }
  else if (book.match(/^jac/) || book.match(/^jak/) || book.match(/^jcb/)) { book = "jacob"; }
  else if (book.match(/^en/)) { book = "enos"; }
  else if (book.match(/^\351n/)) { book = "enos"; }                            // FRENCH
  else if (book.match(/^jar/) || book.match(/^j.r.m$/)) { book = "jarom"; }
  else if (book.match(/^jm/)) { book = "jarom"; }                              // FRENCH
  else if (book.match(/^om/)) { book = "omni"; }
  else if (book.match(/^wo/) || book.match(/of m/) || book.match(/^w.*m\.?$/)) { book = "w_of_m"; }
  else if (book.match(/^pa/) || book.match(/de m/) || book.match(/^p.*m\.?$/)) { book = "w_of_m"; }  // FRENCH/SPANISH
  else if (book.match(/^mosia/) || book.match(/^mozia/)) { book = "mosiah"; }
  else if (book.match(/^mos\355/)) { book = "mosiah"; }                        // SPANISH
  else if (book.match(/^al/)) { book = "alma"; }
  else if (book.match(/^he/) || book.match(/^h.l/)) { book = "hel"; }
  else if (book.match(/^3_n/)) { book = "3_ne"; }
  else if (book.match(/^4_n/)) { book = "4_ne"; }
  else if (book.match(/^et/)) { book = "ether"; }
  else if (book.match(/^\351t/)) { book = "ether"; }                           // FRENCH/SPANISH
  else if (book.match(/^mro/)) { book = "moro"; }                              // FRENCH
            // DOCTRINE AND COVENANTS STANDARDIZATION
  else if (book.match(/^doc/) || book.match(/&/)) { book = "dc"; }
  else if (book.match(/D ?y/)) { book = "dc"; }                                // SPANISH
  else if (book.match(/^of/) || book.match(/^o\./)) { book = "od"; }
  else if (book.match(/^d/)) { book = "od"; }                                  // FRENCH/SPANISH
            // PEARL OF GREAT PRICE STANDARDIZATION
  else if (book.match(/^mo/)) { book = "moses"; }
  else if (book.match(/^ab/)) { book = "abr"; }
  else if (book.match(/j.+w$/) || book.match(/^j.+m\.?/)) { book = "js_m"; }
  else if (book.match(/j.+y$/) || book.match(/^j.+h\.?/)) { book = "js_h"; }
  else if (book.match(/^ar/) || book.match(/^a.*f\.?$/)) { book = "a_of_f"; }
            // NOT FOUND
  else { return alert("We don't recognize this reference:\n\n      "+inputref+"\n\nCould you make sure it was spelled correctly?"); }
  
  for (i in book_abrs) {                         // for every item in the array of abbreviations
    if (book.indexOf(book_abrs[i]) == 0) {       // if the given book is found
      i = i;                                     // get the book's number in the array
      book = book;                               // get the book title
      break;                                     // stop the loop
    }
  }
}

return [book,i];
}


// ===================================================================================================================

function readableBooks(i, multipleverses, language) {
     // Translate given book abbreviations into user languages
     // Called from JavaScriptuReference()
     // - i: location of book in array of abbreviations
     // - multipleverses: "true" or "false"
     // - language: language code as specified from select menu

if (language == "da") { 
readableBooks = new Array("F\370rste Mosebog","Anden Mosebog","Tredje Mosebog","Fjerde Mosebog","Femte Mosebog","Josvabogen","Dommerbogen","Ruths Bog","F\370rste Samuelsbog","Anden Samuelsbog",
                      "F\370rste Kongebog","Anden Kongebog","F\370rste Kr\370nikebog","Anden Kr\370nikebog","Ezras Bog","Nehemias' Bog","Esters Bog","Jobs Bog","Salmernes Bog","Ordsprogenes Bog",
                      "Pr\346dikerens Bog","H\370jsangen","Esajas' Bog","Jeremias' Bog","Klagesangene","Ezekiels Bog","Daniels Bog","Hoseas' Bog","Joels Bog","Amos' Bog",
                      "Obadias' Bog","Jonas' Bog","Mikas Bog","Nahums Bog","Habakkuks Bog","Sefanias' Bog","Haggajs Bog","Zakarias' Bog","Malakias' Bog",  // The 39 books of the Old Testament (0-38)
                      "Matth\346usevangeliet","Markusevangeliet","Lukasevangeliet","Johannesevangeliet","Apostlenes Gerninger","Romerbrevet","F\370rste Korintherbrev","Andet Korintherbrev","Galaterbrevet","Efeserbrevet",
                      "Filipperbrevet","Kolossenserbrevet","F\370rste Thessalonikerbrev","Anden Thessalonikerbrev","F\370rste Timotheusbrev","Andet Timotheusbrev","Titusbrevet","Filemonbrevet","Hebr\346erbrevet","Jakobsbrevet",
                      "F\370rste Petersbrev","Andet Petersbrev","F\370rste Johannesbrev","Andet Johannesbrev","Tredje Johannesbrev","Judasbrevet","Johannes' \305benbaring",                       // The 27 books of the New Testament (39-65)
                      "1 Nefi","2 Nefi","Jakob","Enosh","Jarom","Omni","Mormons Ord","Mosija","Alma","Helaman",
                      "3 Nefi","4 Nefi","Mormon","Eter","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "L&P","Officiel Erkl\346ring &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Moses","Abraham","Joseph Smith &#151; Matth\346usevangeliet","Joseph Smith &#151; Historie","Trosartiklerne"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "de") { 
readableBooks = new Array("Genesis","Exodus","Levitikus","Numeri","Deuteronomium","Josua","Richter","Rut","1 Samuel","2 Samuel",
                      "1 K\366nige","2 K\366nige","1 Chronik","2 Chronik","Esra","Nehemia","Ester","Ijob","Psalmen","Sprichw\366rter",
                      "Kohelet","Das Hohelied","Jesaja","Jeremia","Klagelieder","Ezechiel","Daniel","Hosea","Jo\353l","Amos",
                      "Obadja","Jona","Micha","Nahum","Habakuk","Zefanja","Haggai","Sacharja","Maleachi",  // The 39 books of the Old Testament (0-38)
                      "Matth\344us","Markus","Lukas","Johannes","Apostelgeschichte","R\366mer","1 Korinther","2 Korinther","Galater","Epheser",
                      "Philipper","Kolosser","1 Thessalonicher","2 Thessalonicher","1 Timotheus","2 Timotheus","Titus","Philemon","Hebr\344er","Jakobus",
                      "1 Petrus","2 Petrus","1 Johannes","2 Johannes","3 Johannes","Judas","Offenbarung",                       // The 27 books of the New Testament (39-65)
                      "1 Nephi","2 Nephi","Jakob","Enos","Jarom","Omni","Worte Mormons","Mosia","Alma","Helaman",
                      "3 Nephi","4 Nephi","Mormon","Ether","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "L&B","Amtliche Erkl\344rung &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Mose","Abraham","Joseph Smith &#151; Matth\344us","Joseph Smith &#151; Lebensgeschichte","Die Glaubensartikel"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "en") { 
readableBooks = new Array("Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua","Judges","Ruth","1 Samuel","2 Samuel",
                      "1 Kings","2 Kings","1 Chronicles","2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
                      "Ecclesiastes","Song of Solomon","Isaiah","Jeremiah","Lamentations","Ezekiel","Daniel","Hosea","Joel","Amos",
                      "Obadiah","Jonah","Micah","Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi",  // The 39 books of the Old Testament (0-38)
                      "Matthew","Mark","Luke","John","Acts","Romans","1 Corinthians","2 Corinthians","Galatians","Ephesians",
                      "Philippians","Colossians","1 Thessalonians","2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews","James",
                      "1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation",                       // The 27 books of the New Testament (39-65)
                      "1 Nephi","2 Nephi","Jacob","Enos","Jarom","Omni","Words of Mormon","Mosiah","Alma","Helaman",
                      "3 Nephi","4 Nephi","Mormon","Ether","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "D&C","Official Declaration &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Moses","Abraham","Joseph Smith &#151; Matthew","Joseph Smith &#151; History","Articles of Faith"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "es") { 
readableBooks = new Array("G\351nesis","Exodo","Lev\355tico","N\372meros","Deuteronomio","Josu\351","Jueces","Rut","1 Samuel","2 Samuel",
                      "1 Reyes","2 Reyes","1 Cr\363nicas","2 Cr\363nicas","Esdras","Nehem\355as","Ester","Job","Salmos","Proverbios",
                      "Eclesiast\351s","Cantares de Salom\363n","Isa\355as","Jerem\355as","Lamentaciones","Ezequiel","Daniel","Oseas","Joel","Am\363s",
                      "Abd\355as","Jon\341s","Miqueas","Nahum","Habacuc","Sofon\355as","Hageo","Zacar\355as","Malaqu\355as",  // The 39 books of the Old Testament (0-38)
                      "Mateo","Marcos","Lucas","Juan","Hechos","Romanos","1 Corintios","2 Corintios","G\341latas","Efesios",
                      "Filipenses","Colosenses","1 Tesalonicenses","2 Tesalonicenses","1 Timoteo","2 Timoteo","Tito","Filem\363n","Hebreos","Santiago",
                      "1 Pedro","2 Pedro","1 Juan","2 Juan","3 Juan","Judas","Apocalipsis",                       // The 27 books of the New Testament (39-65)
                      "1 Nefi","2 Nefi","Jacob","En\363s","Jarom","Omni","Palabras Morm\363n","Mos\355ah","Alma","Helam\341n",
                      "3 Nefi","4 Nefi","Morm\363n","Eter","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "DyC","Declaraci\363n Oficial &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Mois\351s","Abraham","Jos\351 Smith &#151; Mateo","Jos\351 Smith &#151; Historia","Art\355culos de Fe"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "fi") { 
readableBooks = new Array("1 Mooseksen kirja","2 Mooseksen kirja","3 Mooseksen kirja","4 Mooseksen kirja","5 Mooseksen kirja","Joosua","Tuomarien kirja","Ruut","1 Samuelin kirja","2 Samuelin kirja",
                      "1 Kuningasten kirja","2 Kuningasten kirja","1 Aikakirja","2 Aikakirja","Esra","Nehemia","Ester","Job","Psalmit","Sananlaskut",
                      "Saarnaaja","Korkea veisu","Jesaja","Jeremia","Valitusvirret","Hesekiel","Daniel","Hoosea","Jooel","Aamos",
                      "Obadja","Joona","Miika","Naahum","Habakuk","Sefanja","Haggai","Sakarja","Malakia",  // The 39 books of the Old Testament (0-38)
                      "Evankeliumi Matteuksen mukaan","Evankeliumi Markuksen mukaan","Evankeliumi Luukkaan mukaan","Evankeliumi Johanneksen mukaan","Apostolien teot","Kirje roomalaisille","1 kirje korinttilaisille","2 kirje korinttilaisille","Kirje galatalaisille","Kirje efesolaisille",
                      "Kirje filippil\344isille","Kirje kolossalaisille","1 kirje tessalonikalaisille","2 kirje tessalonikalaisille","1 kirje Timoteukselle","2 kirje Timoteukselle","Kirje Titukselle","Kirje Filemonille","Kirje heprealaisille","Jaakobin kirje",
                      "1 Pietarin kirje","2 Pietarin kirje","1 Johanneksen kirje","2 Johanneksen kirje","3 Johanneksen kirje","Juudaksen kirje","Johanneksen ilmestys",                       // The 27 books of the New Testament (39-65)
                      "1 Nefin kirja","2 Nefin kirja","Jaakobin kirja","Enosin kirja","Jaromin kirja","Omnin kirja","Mormonin sanat","Moosian kirja","Alman kirja","Helamanin kirja",
                      "3 Nefin kirja","4 Nefin kirja","Mormonin kirja","Eterin kirja","Moronin kirja",      // The 15 books of the Book of Mormon (66-80)
                      "O&L","Virallinen julistus &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Mooseksen kirjasta","Abrahamin kirja","Joseph Smith &#151; Matteus","Joseph Smith &#151; historia","Uskonkappaleet"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "fr") { 
readableBooks = new Array("Gen\350se","Exode","L\351vitique","Nombres","Deut\351ronome","Josu\351","Juges","Ruth","1 Samuel","2 Samuel",
                      "1 Rois","2 Rois","1 Chroniques","2 Chroniques","Esdras","N\351h\351mie","Esther","Job","Psaumes","Proverbes",
                      "Eccl\351siaste","Cantique des Cantiques","Esa\357e","J\351r\351mie","Lamentations","Ez\351chiel","Daniel","Os\351e","Jo\353l","Amos",
                      "Abdias","Jonas","Mich\351e","Nahum","Habacuc","Sophonie","Agg\351e","Zacharie","Malachie",  // The 39 books of the Old Testament (0-38)
                      "Matthieu","Marc","Luc","Jean","Actes","Romains","1 Corinthiens","2 Corinthiens","Galates","Eph\351siens",
                      "Philippiens","Colossiens","1 Thessaloniciens","2 Thessaloniciens","1 Timoth\351e","2 Timoth\351e","Tite","Phil\351mon","H\351breux","Jacques",
                      "1 Pierre","2 Pierre","1 Jean","2 Jean","3 Jean","Jude","Apocalypse",                       // The 27 books of the New Testament (39-65)
                      "1 N\351phi","2 N\351phi","Jacob","Enos","Jarom","Omni","Paroles de Mormon","Mos\355ah","Alma","H\351laman",
                      "3 N\351phi","4 N\351phi","Mormon","Ether","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "D&A","D\351claration Officielle &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Mo\357se","Abraham","Joseph Smith &#151; Matthieu","Joseph Smith &#151; Histoire","Articles de Foi"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "hu") {       // LANGUAGE BOOKS NOT COMPLETED: Bible books
readableBooks = new Array("Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua","Judges","Ruth","1 Samuel","2 Samuel",
                      "1 Kings","2 Kings","1 Chronicles","2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
                      "Ecclesiastes","Song of Solomon","Isaiah","Jeremiah","Lamentations","Ezekiel","Daniel","Hosea","Joel","Amos",
                      "Obadiah","Jonah","Micah","Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi",  // The 39 books of the Old Testament (0-38)
                      "Matthew","Mark","Luke","John","Acts","Romans","1 Corinthians","2 Corinthians","Galatians","Ephesians",
                      "Philippians","Colossians","1 Thessalonians","2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews","James",
                      "1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation",                       // The 27 books of the New Testament (39-65)
                      "Nefi els&#337;","Nefi m\341sodik","J\341k\363b","En\363s","J\341rom","Omni","Mormon szavai","Mózi\341s","Alma","H\351lam\341n",
                      "Harmadik Nefi","Negyedik Nefi","Mormon","Ether","Mor\363ni",      // The 15 books of the Book of Mormon (66-80)
                      "A Tan \351s a sz\366vets\351gek","Hivatalos nyilatkozat &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "M\363zes","Abrah\341m","Joseph Smith &#151; M\341t\351","Joseph Smith t\366rt\351nete","A Hitt\351telek"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "it") { 
readableBooks = new Array("Genesi","Esodo","Levitico","Numeri","Deuteronomio","Giosu\350","Giudici","Ruth","1 Samuele","2 Samuele",
                      "1 Re","2 Re","1 Cronache","2 Cronache","Esdra","Neemia","Ester","Giobbe","Salmi","Proverbi",
                      "Ecclesiaste","Cantico dei cantici","Isaia","Geremia","Lamentazioni","Ezechiele","Daniele","Osea","Gioele","Amos",
                      "Abdia","Giona","Michea","Nahum","Habacuc","Sofonia","Aggeo","Zaccaria","Malachia",  // The 39 books of the Old Testament (0-38)
                      "Matteo","Marco","Luca","Giovanni","Atti","Romani","1 Corinzi","2 Corinzi","Galati","Efesini",
                      "Filippesi","Colossesi","1 Tessalonicesi","2 Tessalonicesi","1 Timoteo","2 Timoteo","Tito","Filemone","Ebrei","Giacomo",
                      "1 Pietro","2 Pietro","1 Giovanni","2 Giovanni","3 Giovanni","Giuda","Apocalisse",                       // The 27 books of the New Testament (39-65)
                      "1 Nefi","2 Nefi","Giacobbe","Enos","Giarom","Omni","Parole di Mormon","Mosia","Alma","Helaman",
                      "3 Nefi","4 Nefi","Mormon","Ether","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "DeA","Dichiarazione Ufficiale &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Mos\350","Abrahamo","Joseph Smith &#151; Matteo","Joseph Smith &#151; Storia","Articoli di Fede"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "nl") {       // LANGUAGE BOOKS NOT COMPLETED: Bible books
readableBooks = new Array("Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua","Judges","Ruth","1 Samuel","2 Samuel",
                      "1 Kings","2 Kings","1 Chronicles","2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
                      "Ecclesiastes","Song of Solomon","Isaiah","Jeremiah","Lamentations","Ezekiel","Daniel","Hosea","Joel","Amos",
                      "Obadiah","Jonah","Micah","Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi",  // The 39 books of the Old Testament (0-38)
                      "Matthew","Mark","Luke","John","Acts","Romans","1 Corinthians","2 Corinthians","Galatians","Ephesians",
                      "Philippians","Colossians","1 Thessalonians","2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews","James",
                      "1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation",                       // The 27 books of the New Testament (39-65)
                      "1 Nephi","2 Nephi","Jakob","Enos","Jarom","Omni","Woorden van Mormon","Mosiah","Alma","Helaman",
                      "3 Nephi","4 Nephi","Mormon","Ether","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "L&V","Offici\353le Verklaring &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Mozes","Abraham","Matte\374s naar Joseph Smith","De Geschiedenis van Joseph Smith","De Geloofsartikelen"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "no") {       // LANGUAGE BOOKS NOT COMPLETED: Bible books
readableBooks = new Array("Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua","Judges","Ruth","1 Samuel","2 Samuel",
                      "1 Kings","2 Kings","1 Chronicles","2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
                      "Ecclesiastes","Song of Solomon","Isaiah","Jeremiah","Lamentations","Ezekiel","Daniel","Hosea","Joel","Amos",
                      "Obadiah","Jonah","Micah","Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi",  // The 39 books of the Old Testament (0-38)
                      "Matthew","Mark","Luke","John","Acts","Romans","1 Corinthians","2 Corinthians","Galatians","Ephesians",
                      "Philippians","Colossians","1 Thessalonians","2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews","James",
                      "1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation",                       // The 27 books of the New Testament (39-65)
                      "Nephis f\370rste bok","Nephis andre bok","Jakobs bok","Enos' bok","Jaroms bok","Omnis bok","Mormons ord","Mosiahs bok","Almas bok","Helamans bok",
                      "Tredje Nephi","Fjerde Nephi","Mormons bok","Ethers bok","Moronis bok",      // The 15 books of the Book of Mormon (66-80)
                      "L&P","Offisiell erkl\346ring &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Utdrag fra Mose bok","Abrahams bok","Joseph Smith &#151; Matteus","Joseph Smith &#151; Historie","Trosartiklene"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "pt") {       // LANGUAGE BOOKS NOT COMPLETED: Bible books
readableBooks = new Array("Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua","Judges","Ruth","1 Samuel","2 Samuel",
                      "1 Kings","2 Kings","1 Chronicles","2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
                      "Ecclesiastes","Song of Solomon","Isaiah","Jeremiah","Lamentations","Ezekiel","Daniel","Hosea","Joel","Amos",
                      "Obadiah","Jonah","Micah","Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi",  // The 39 books of the Old Testament (0-38)
                      "Matthew","Mark","Luke","John","Acts","Romans","1 Corinthians","2 Corinthians","Galatians","Ephesians",
                      "Philippians","Colossians","1 Thessalonians","2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews","James",
                      "1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation",                       // The 27 books of the New Testament (39-65)
                      "1 N\351fi","2 N\351fi","Jac\363","Enos","Jarom","Omni","Palavras de M\363rmon","Mosias","Alma","Helam\343",
                      "3 N\351fi","4 N\351fi","M\363rmon","Eter","Mor\364ni",      // The 15 books of the Book of Mormon (66-80)
                      "D&C","Declara\347\343o Oficial &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Mois\351s","Abra\343o","Joseph Smith &#151; Mateus","Joseph Smith &#151; Hist\363ria","Regras de F\351"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "sv") {       // LANGUAGE BOOKS NOT COMPLETED: Bible books
readableBooks = new Array("Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua","Judges","Ruth","1 Samuel","2 Samuel",
                      "1 Kings","2 Kings","1 Chronicles","2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
                      "Ecclesiastes","Song of Solomon","Isaiah","Jeremiah","Lamentations","Ezekiel","Daniel","Hosea","Joel","Amos",
                      "Obadiah","Jonah","Micah","Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi",  // The 39 books of the Old Testament (0-38)
                      "Matthew","Mark","Luke","John","Acts","Romans","1 Corinthians","2 Corinthians","Galatians","Ephesians",
                      "Philippians","Colossians","1 Thessalonians","2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews","James",
                      "1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation",                       // The 27 books of the New Testament (39-65)
                      "1 Nephi","2 Nephi","Jakob","Enos","Jarom","Omni","Mormons ord","Mosiah","Alma","Helaman",
                      "3 Nephi","4 Nephi","Mormon","Ether","Moroni",      // The 15 books of the Book of Mormon (66-80)
                      "L&F","Officiellt tillk\344nnagivande &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "Moses","Abrahams bok","Joseph Smith &#151; Matteus","Joseph Smith &#151; Historien","Trosartiklarna"); } // The 5 parts of the Pearl of Great Price (83-87)
else if (language == "to") {       // LANGUAGE BOOKS NOT COMPLETED: Bible books
readableBooks = new Array("Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua","Judges","Ruth","1 Samuel","2 Samuel",
                      "1 Kings","2 Kings","1 Chronicles","2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
                      "Ecclesiastes","Song of Solomon","Isaiah","Jeremiah","Lamentations","Ezekiel","Daniel","Hosea","Joel","Amos",
                      "Obadiah","Jonah","Micah","Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi",  // The 39 books of the Old Testament (0-38)
                      "Matthew","Mark","Luke","John","Acts","Romans","1 Corinthians","2 Corinthians","Galatians","Ephesians",
                      "Philippians","Colossians","1 Thessalonians","2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews","James",
                      "1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation",                       // The 27 books of the New Testament (39-65)
                      "1 N&#299;fai","2 N&#299;fai","S&#275;kop\351","&#8216;Inos\355","Seilom\355","&#8216;Amena\355","Ngaahi Lea &#8216;a Molomona","M&#333;sai\341","&#8216;Alam&#257;","Hilaman\355",
                      "3 N&#299;fai","4 N&#299;fai","Molomon\341","&#8216;Et\341","Molona\355",      // The 15 books of the Book of Mormon (66-80)
                      "Ko e Tok&#257;teline mo e Ngaahi Fuakava","Fanongonongo Fakamafai&#8216;i &#151; ",                 // The 2 parts of the Doctrine and Covenants (81-82)
                      "M&#333;sese","&#8216;Epalahame","Siosefa S&#257;mita &#151; M&#257;tiu","Siosefa S&#257;mita &#151; Hisit&#333;lia","Ko e Ngaahi Tefito &#8216;o e Tui"); } // The 5 parts of the Pearl of Great Price (83-87)

var Book = readableBooks[i];

// if (Book == "Psalm" && multiplechapters == "true") { Book = "Psalms"; }
if (Book == "Articles of Faith" && multipleverses == "false") { Book = "Article of Faith"; }

return Book;
}


// ===================================================================================================================

function changeBookLength(Book, length, language) {
     // Change format/length of given book title
     // Called from JavaScriptuReference()
     // - Book: readable book title in English, French, or Spanish
     // - length: "" (do nothing), "condensed" (JS-M, JS-H, OD),
     //           "extended" (Doctrine and Covenants), "full" (The Gospel of... etc.)
     // - language: language code as specified from select menu

if (length == "condensed") {
       if (Book == "Joseph Smith &#151; Matthew") { Book = "JS-M"; }
  else if (Book == "Joseph Smith &#151; History") { Book = "JS-H"; }
  else if (Book == "Official Declaration &#151; ") { Book = "OD-"; }
  else if (Book == "Joseph Smith &#151; Matthieu") { Book = "JS-M"; }
  else if (Book == "Joseph Smith &#151; Histoire") { Book = "JS-H"; }
  else if (Book == "D\351claration Officielle &#151; ") { Book = "DO-"; }
  else if (Book == "Jos\351 Smith &#151; Mateo") { Book = "JS-M"; }
  else if (Book == "Jos\351 Smith &#151; Historia") { Book = "JS-H"; }
  else if (Book == "Declaraci\363n Oficial &#151; ") { Book = "DO-"; }
  else { Book = Book; }
}
else if (length == "extended") { }  // not in use
else if (length == "full") { }  // not in use
else {
  Book = Book;
}

return Book;
}


// ===================================================================================================================

function standardWorks(i, language) {
     // Determine standard work and output in specified language
     // Called from JavaScriptuReference()
     // - i: location of book in array of abbreviations
     // - language: language code as specified from select menu

       if (i>=0  && i<=38) { var sw = "ot"; }                           // determine standard work from number in array
  else if (i>=39 && i<=65) { var sw = "nt"; }
  else if (i>=66 && i<=80) { var sw = "bm"; }
  else if (i>=81 && i<=82) { var sw = "dc"; }
  else if (i>=83 && i<=87) { var sw = "pgp"; }
  else { }

if (language == "da") { 
       if (sw == "ot") { stndrdwork = "Det Gamle Testamente"; }
  else if (sw == "nt") { stndrdwork = "Det Nye Testamente"; }
  else if (sw == "bm") { stndrdwork = "Mormons Bog"; }
  else if (sw == "dc") { stndrdwork = "L\346re og Pagter"; }
  else if (sw == "pgp") { stndrdwork = "Den Kostelige Perle"; }
}
else if (language == "de") { 
       if (sw == "ot") { stndrdwork = "Altes Testament"; }
  else if (sw == "nt") { stndrdwork = "Neues Testament"; }
  else if (sw == "bm") { stndrdwork = "Das Buch Mormon"; }
  else if (sw == "dc") { stndrdwork = "Lehre und B\374ndnisse"; }
  else if (sw == "pgp") { stndrdwork = "Die K\366stliche Perle"; }
}
else if (language == "en") { 
       if (sw == "ot") { stndrdwork = "The Old Testament"; }
  else if (sw == "nt") { stndrdwork = "The New Testament"; }
  else if (sw == "bm") { stndrdwork = "The Book of Mormon"; }
  else if (sw == "dc") { stndrdwork = "The Doctrine and Covenants"; }
  else if (sw == "pgp") { stndrdwork = "The Pearl of Great Price"; }
}
else if (language == "es") { 
       if (sw == "ot") { stndrdwork = "El Antiguo Testamento"; }
  else if (sw == "nt") { stndrdwork = "El Nuevo Testamento"; }
  else if (sw == "bm") { stndrdwork = "El Libro de Morm\363n"; }
  else if (sw == "dc") { stndrdwork = "Doctrina y Convenios"; }
  else if (sw == "pgp") { stndrdwork = "La Perla de Gran Precio"; }
}
else if (language == "fi") { 
       if (sw == "ot") { stndrdwork = "Vanha testamentti"; }
  else if (sw == "nt") { stndrdwork = "Uusi testamentti"; }
  else if (sw == "bm") { stndrdwork = "Mormonin kirja"; }
  else if (sw == "dc") { stndrdwork = "Oppi ja liitot"; }
  else if (sw == "pgp") { stndrdwork = "Kallisarvoinen helmi"; }
}
else if (language == "fr") { 
       if (sw == "ot") { stndrdwork = "L'Ancien Testament"; }
  else if (sw == "nt") { stndrdwork = "Le Nouveau Testament"; }
  else if (sw == "bm") { stndrdwork = "Le Livre de Mormon"; }
  else if (sw == "dc") { stndrdwork = "Les Doctrine et Alliances"; }
  else if (sw == "pgp") { stndrdwork = "La Perle de Grand Prix"; }
}
else if (language == "hu") { 
       if (sw == "ot") { stndrdwork = "Osz\366vets\351g"; }
  else if (sw == "nt") { stndrdwork = "Ujsz\366vets\351g"; }
  else if (sw == "bm") { stndrdwork = "A Mormon K\366nyve"; }
  else if (sw == "dc") { stndrdwork = "A Tan \351s a sz\366vets\351gek"; }
  else if (sw == "pgp") { stndrdwork = "A Nagy\351rt\351k\561 gy\366ngy"; }
}
else if (language == "it") { 
       if (sw == "ot") { stndrdwork = "L'Antico Testamento"; }
  else if (sw == "nt") { stndrdwork = "Il Nuovo Testamento"; }
  else if (sw == "bm") { stndrdwork = "Il Libro di Mormon"; }
  else if (sw == "dc") { stndrdwork = "Dottrina e Alleanze"; }
  else if (sw == "pgp") { stndrdwork = "Perla di Gran Prezzo"; }
}
else if (language == "nl") { 
       if (sw == "ot") { stndrdwork = "Oude Testament"; }
  else if (sw == "nt") { stndrdwork = "Nieuwe Testament"; }
  else if (sw == "bm") { stndrdwork = "Het Boek van Mormon"; }
  else if (sw == "dc") { stndrdwork = "De Leer en Verbonden"; }
  else if (sw == "pgp") { stndrdwork = "De Parel van grote waarde"; }
}
else if (language == "no") { 
       if (sw == "ot") { stndrdwork = "Det gamle testamentet"; }
  else if (sw == "nt") { stndrdwork = "Det nye testamentet"; }
  else if (sw == "bm") { stndrdwork = "Mormons bok"; }
  else if (sw == "dc") { stndrdwork = "L\346re og pakter"; }
  else if (sw == "pgp") { stndrdwork = "Den kostelige perle"; }
}
else if (language == "pt") { 
       if (sw == "ot") { stndrdwork = "O Velho Testamento"; }
  else if (sw == "nt") { stndrdwork = "O Novo Testamento"; }
  else if (sw == "bm") { stndrdwork = "O Livro de M\363rmon"; }
  else if (sw == "dc") { stndrdwork = "Doutrina e Conv\352nios"; }
  else if (sw == "pgp") { stndrdwork = "A P\351rola de Grande Valor"; }
}
else if (language == "sv") { 
       if (sw == "ot") { stndrdwork = "Gamla Testamentet"; }
  else if (sw == "nt") { stndrdwork = "Nya Testamentet"; }
  else if (sw == "bm") { stndrdwork = "Mormons bok"; }
  else if (sw == "dc") { stndrdwork = "L\344ran och f\366rbunden"; }
  else if (sw == "pgp") { stndrdwork = "Den kostbara p\344rlan"; }
}
else if (language == "to") { 
       if (sw == "ot") { stndrdwork = "Koe Tohi Tabu Katoa"; }    // "The Bible"
  else if (sw == "nt") { stndrdwork = "Koe Tohi Tabu Katoa"; }    // "The Bible"
  else if (sw == "bm") { stndrdwork = "Ko e Tohi &#8216;a Molomon\341"; }
  else if (sw == "dc") { stndrdwork = "Ko e Tok&#257;teline mo e Ngaahi Fuakava"; }
  else if (sw == "pgp") { stndrdwork = "Ko e Mata&#8216;itofe Mahu&#8216;ing\341"; }
}

return stndrdwork;
}
