    var rezult;
    var currentTestament;
    var currentChapter;
    var currentDiv;
    var range;

    
    function highlighter(div,str) {
      var strs = str.split(" ");
      for (var i=0;i<strs.length;i++) {
        $(div).innerHTML = $(div).innerHTML.replace(strs[i],"<span class=\"highlighted\">"+strs[i].escapeHTML()+"</span>","gi");
      }
    }

    function getBookList(div) {
      new XMLHTTP({url:"./pages/books.xml",callback:showBookList,ctype:"text/plain",method:"get",div:div});
    }
    
    function getChapter(div,cn,rng) {
      cn = parseInt(cn);
      if (rng) {
        var temp1 = new Array();
        temp1[0] = 9999;
        var temp2 = 1;
        for (var i=rng[0];i<rng[1];i++) {
          temp1[temp2] = i;
          temp2++;
        }
        if (cn != 1) {
          var url_ = "./chapters/"+(temp1[(cn-1)]+1)+".xml";
          new XMLHTTP({url:url_,callback:showChapter,ctype:"text/plain",method:"post",div:div});
        } else if ((rng[0]-rng[1]) == 0) {
          var url_ = "./chapters/"+rng[0]+".xml";
          new XMLHTTP({url:url_,callback:showChapter,ctype:"text/plain",method:"post",div:div});
        } else {
          var url_ = "./chapters/"+temp1[1]+".xml";
          new XMLHTTP({url:url_,callback:showChapter,ctype:"text/plain",method:"post",div:div});
        }
      } else {
        while (cn > 1189) {
          cn = (cn-1189);
        }
        var url_ = "./chapters/"+cn+".xml";
        new XMLHTTP({url:url_,callback:showChapter,ctype:"text/plain",method:"post",div:div});
      }
    }
    
    function getOldChapter(div,cn) {
      cn = parseInt(cn);
      while (cn > 929) {
        cn = (cn-929);
      }
      new XMLHTTP({url:"./chapters/"+cn+".xml",callback:showChapter,ctype:"text/plain",method:"post",div:div});
    }

    function getNewChapter(div,cn) {
      cn = parseInt(cn);
      while (cn > 260) {
        cn = (cn-260);
      }
      cn = eval(cn+929);
      new XMLHTTP({url:"./chapters/"+cn+".xml",callback:showChapter,ctype:"text/plain",method:"post",div:div});
    }
    
    function showChapter(x) {
      result = xml2json.parser(x.xhr.responseText);
      var newDiv = document.createElement("div");
      //newDiv.style.height = "300px";
      newDiv.style.overflow = "auto";
      var anotherThing = document.createElement("h1");
      anotherThing.innerHTML = result.chapter.book+" "+result.chapter.number;
      newDiv.appendChild(anotherThing);
      var anotherThing2 = document.createElement("p");
      var co = result.chapter.numberold;
      var cn = result.chapter.numbernew;
      if (result.chapter.testament == "1") {
        anotherThing2.innerHTML  = '<u>Chapter Number:</u> <b>[Old: <u>'+co+'</u>], [Bible: <u>'+result.chapter.numberbible+'</u>]</b>';
        anotherThing2.innerHTML += '<br /><u>Hebrew Letters:</u> <b>[Bible: <u>'+IBCExtra.getLetter(result.chapter.numberbible)+'</u>], [Book: <u>'+IBCExtra.getLetter(result.chapter.number)+'</u>]</b>';
        anotherThing2.innerHTML += '<br /><u>Colors:</u> <b>[Bible: <u><span class="'+IBCExtra.getColor(result.chapter.numberbible)+'">'+IBCExtra.getColor(result.chapter.numberbible)+'</span></u>], [Book: <u><span class="'+IBCExtra.getColor(result.chapter.number)+'">'+IBCExtra.getColor(result.chapter.number)+'</span></u>]</b>';
        anotherThing2.innerHTML += '<br /><u>Elements:</u> <b>[Bible: <u><a href="http://www.google.com/search?q='+IBCExtra.getElement(result.chapter.numberbible).stripTags()+'" target="_new">'+IBCExtra.getElement(result.chapter.numberbible)+'</a></u>], [Book: <u><a href="http://www.google.com/search?q='+IBCExtra.getElement(result.chapter.number).stripTags()+'" target="_new">'+IBCExtra.getElement(result.chapter.number)+'</a></u>]</b>';
      } else {
        anotherThing2.innerHTML = '<u>Chapter Number:</u> <b>[New: <u>'+cn+'</u>], [Bible: <u>'+result.chapter.numberbible+'</u>]</b>';
        anotherThing2.innerHTML += '<br /><u>Hebrew Letters:</u> <b>[Bible: <u>'+IBCExtra.getLetter(result.chapter.numberbible)+'</u>], [Testament: <u>'+IBCExtra.getLetter(cn)+'</u>], [Book: <u>'+IBCExtra.getLetter(result.chapter.number)+'</u>]</b>';
        anotherThing2.innerHTML += '<br /><u>Colors:</u> <b>[Bible: <u><span class="'+IBCExtra.getColor(result.chapter.numberbible)+'">'+IBCExtra.getColor(result.chapter.numberbible)+'</span></u>], [Testament: <u><span class="'+IBCExtra.getColor(cn)+'">'+IBCExtra.getColor(cn)+'</span></u>], [Book: <u><span class="'+IBCExtra.getColor(result.chapter.number)+'">'+IBCExtra.getColor(result.chapter.number)+'</span></u>]</b>';
        anotherThing2.innerHTML += '<br /><u>Elements:</u> <b>[Bible: <u><a href="http://www.google.com/search?q='+IBCExtra.getElement(result.chapter.numberbible).stripTags()+'" target="_new">'+IBCExtra.getElement(result.chapter.numberbible)+'</a></u>], [Testament: <u><a href="http://www.google.com/search?q='+IBCExtra.getElement(cn).stripTags()+'" target="_new">'+IBCExtra.getElement(cn)+'</a></u>], [Book: <u><a href="http://www.google.com/search?q='+IBCExtra.getElement(result.chapter.number).stripTags()+'" target="_new">'+IBCExtra.getElement(result.chapter.number)+'</a></u>]</b>';
      }
      var newHR = document.createElement("hr");
      var newerDiv = document.createElement("div");
      newerDiv.id = "verses_";
      anotherThing2.appendChild(newHR);
      newDiv.appendChild(anotherThing2);
      for (var i=0;i<result.chapter.verse.length;i++) {
        var newSpan = document.createElement("span")
        var verseText = result.chapter.verse[i].text;
        newSpan.innerHTML = "<span style=\"color: #A0A0A0;\"><b><u>"+result.chapter.verse[i].number+"</u></b></span>: "+verseText.unescapeHTML()+"<br />";
        newSpan.innerHTML = newSpan.innerHTML.replace(/__GOD/gi,"<span class=\"WORDS\">");
        newSpan.innerHTML = newSpan.innerHTML.replace(/GOD__/gi,"</span>");
        newSpan.innerHTML = newSpan.innerHTML.replace(/__JESUS/gi,"<span class=\"WORDS\">");
        newSpan.innerHTML = newSpan.innerHTML.replace(/JESUS__/gi,"</span>");
        newSpan.onmouseover = function() { this.style.backgroundColor= "#202020"; }
        newSpan.onmouseout = function() { this.style.backgroundColor= ""; }
        newSpan.style.color = "white";
        newerDiv.appendChild(newSpan);
      }
      $(x.div).innerHTML = "";
      $(x.div).appendChild(newDiv);
      $(x.div).appendChild(newerDiv);
      currentTestament = result.chapter.testament;
      currentChapter = result.chapter.numberbible;
      currentDiv = x.div;
    }
    
    function showBookList(x) {
      result = xml2json.parser(x.xhr.responseText);
      rezult = result;
      var newSelect = document.createElement("select");
      for (var i=0;i<result.books.book.length;i++) {
        var newOption = document.createElement("option");
        newOption.setAttribute("value",result.books.book[i].number);
        newOption.setAttribute("onclick","updateNumChapters('bibleSelection2',"+result.books.book[i].numchapters+","+result.books.book[i].number+",["+result.books.book[i].start+","+result.books.book[i].end+"]);");
        newOption.innerHTML = result.books.book[i].number+" - "+result.books.book[i].title;
        newSelect.appendChild(newOption);
      }
      if (window.ActiveXObject) {
        newSelect.onchange = function() {
          var i = this.selectedIndex;
          updateNumChapters('bibleSelection2',rezult.books.book[i].numchapters,rezult.books.book[i].number,[rezult.books.book[i].start,rezult.books.book[i].end]);
        }
      }
      $(x.div).innerHTML = "";
      $(x.div).appendChild(newSelect);
    }

    function updateNumChapters(div,num,booknumber,range) {
      var newSelect2 = document.createElement("select");
      for (var i=1;i<(num+1);i++) {
        var newOption2 = document.createElement("option");
        newOption2.setAttribute("value",i);
        newOption2.setAttribute("onclick","getChapter('bibleView',"+i+",["+range[0]+","+range[1]+"]);");
        newOption2.innerHTML = i;
        newSelect2.appendChild(newOption2);

      }
      $(div).innerHTML = "";
      $(div).appendChild(newSelect2);
      if (window.ActiveXObject) {
        newSelect2.onchange = function() {
          var range2 = range;
          var r1 = range2[0];
          var r2 = range2[1];
          var i = this.selectedIndex+1;
          getChapter('bibleView',i,([r1,r2]));
        }
      }
      window.setTimeout("getChapter('bibleView',1,["+range[0]+","+range[1]+"])",250);
    }

    function doWrap(direction) {
      if (direction == "backward") {
        if (currentTestament == "1") {
          if ((currentChapter-260) > 0) {
            var newChapter = (currentChapter-260);
            new XMLHTTP({url:"./chapters/"+newChapter+".xml",callback:showChapter,ctype:"text/plain",method:"get",div:currentDiv});
          }
        } else {
          if ((currentChapter-929) < 150) {
            var newChapter = (currentChapter-149);
          } else {
            var newChapter = ((currentChapter-149)-260);
          }
          new XMLHTTP({url:"./chapters/"+newChapter+".xml",callback:showChapter,ctype:"text/plain",method:"get",div:currentDiv});
        }
      } else {
        if (currentTestament == "1") {
          var newChapter = currentChapter+260;
          if (newChapter > 929) {
            newChapter = newChapter+149;
            while (newChapter > 1189) {
              newChapter = newChapter-260;
            }
          }
          new XMLHTTP({url:"./chapters/"+newChapter+".xml",callback:showChapter,ctype:"text/plain",method:"get",div:currentDiv});
        }
      }
    }
    
    function startBible() {
      var delayAmount = 200;                                                              // Amount to delay execution
      getBookList("bibleSelection");                                                      // Get list of books
      //window.setTimeout("updateNumChapters('bibleSelection2',50,1,[1,50])",delayAmount);  // Show chapter list for Genesis
      updateNumChapters('bibleSelection2',50,1,[1,50]);  // Show chapter list for Genesis
    }
