function comCell_click(a,b,c,d){switch(a){case"chapter":build_com_reference(a,b,c);break;case"verse":build_com_reference(a,b,c,d);break;case"link":document.location.href="view.cgi?bk="+b+"&ch="+c+"&vs="+d;break}}function showAlt_list(a){document.getElementById("cOT_div").style.display=a=="ot"?"block":"none";document.getElementById("cOT_title").style.color=a=="ot"?"black":"gray";document.getElementById("cNT_div").style.display=a=="nt"?"block":"none";document.getElementById("cNT_title").style.color=a=="nt"?"black":"gray"}function build_com_reference(a,b,c,d){_createTitles=function(a,b,d){cDiv=$("<div>",{"class":"standard bold",css:{paddingBottom:10+"px"}});if(b==0){$(cDiv).html("")}else if(b==1){$("<span>",{id:"cOT_title",css:{cursor:"pointer"},html:"Old Testament",click:function(){showAlt_list("ot")}}).appendTo($(cDiv));$("<span>",{html:" / "}).appendTo($(cDiv));$("<span>",{id:"cNT_title",css:{cursor:"pointer",color:"gray"},html:"New Testament",click:function(){showAlt_list("nt")}}).appendTo($(cDiv))}else if(b==2){$(cDiv).html("Old Testament")}else if(b==3){$(cDiv).html("New Testament")}else if(b==4){$("<span>",{id:"cNT_title",css:{cursor:"pointer"},html:"book:",click:function(){build_com_reference()}}).appendTo($(cDiv));$("<span>",{css:{color:"gray"},html:"&nbsp; "+book_namesLong[d]+"&nbsp; ",click:function(){build_com_reference()}}).appendTo($(cDiv))}else if(b==5){$("<span>",{id:"cNT_title",css:{cursor:"pointer"},html:"book:",click:function(){build_com_reference()}}).appendTo($(cDiv));$("<span>",{css:{color:"gray"},html:"&nbsp; "+book_namesLong[d]+"&nbsp; "}).appendTo($(cDiv));$("<span>",{id:"cNT_title",css:{cursor:"pointer"},html:" &nbsp; &nbsp;chapter:",click:function(){build_com_reference("chapter",curCom_bn)}}).appendTo($(cDiv));$("<span>",{css:{color:"gray"},html:"&nbsp; "+c+"&nbsp; "}).appendTo($(cDiv))}cDiv.appendTo($(a))};_createBook_lists=function(a,b,c,d,e,f,g){curCh=curVs=1;bCount=0;tdisplay=b==1&&g=="y"?"block":b==2||b==3?"block":"none";cDiv1=$("<div>",{id:c,css:{display:tdisplay}});cTbl=$("<table>",{css:{width:"100%",font:"400 9px arial,helvetica,sans-serif",cursor:"pointer"}});for(i=1;i<e;i++){cTr=$("<tr>");for(j=0;j<f;j++){if(bCount==d.length){break}$("<td>",{id:"com_cell"+bCount,css:{padding:1+"px "+4+"px",onmouseover:"javascript:this.style.backgroundColor='#E7E3EF';",onmouseout:"javascript:this.style.backgroundColor='#FFFFFF';"},num:d[bCount],html:book_namesLong[d[bCount++]]}).click(function(){comCell_click("chapter",$(this).attr("num"))}).appendTo($(cTr))}$(cTbl).last().append(cTr)}cTbl.appendTo(cDiv1);cDiv1.appendTo($(a))};_createChapter_list=function(a,b,c){cDiv1=$("<div>",{id:"cCH_div"});cTbl=$("<table>",{css:{width:"100%",font:"400 9px arial,helvetica,sans-serif",cursor:"pointer"}});bCount=curCh>1?curCh:1;rtype=com_type=="ch"?"link":"verse";$.get("/cgi-bin/default/verse_range_builder.cgi?a="+com_abb+"&b="+b,function(d){verses=$(d).find("data").text().split(",");var e=verses.length-1;var f=verses.length/8+2;var g=0;for(i=1;i<f;i++){oTr=$("<tr>");for(j=0;j<9;j++){var h=verses[g++];oTd=c!=h?$("<td>",{css:{padding:1+"px "+4+"px",onmouseover:"javascript:this.style.backgroundColor='#E7E3EF';",onmouseout:"javascript:this.style.backgroundColor='#FFFFFF';"},html:h}).click(function(){comCell_click(rtype,b,$(this).text())}):$("<td>",{css:{padding:1+"px "+4+"px"},"class":"alt_foreground_dark bold",html:"["+h+"]"});oTd.appendTo($(oTr));if(g>e){break}}oTr.appendTo($(cTbl));if(g>e){break}}cTbl.appendTo(cDiv1);cDiv1.appendTo($(a))},"xml")};_createVerse_list=function(a,b,c,d){cDiv1=$("<div>",{id:"cVS_div"});cTbl=$("<table>",{css:{width:"100%",font:"400 9px arial,helvetica,sans-serif",cursor:"pointer"}});$.get("/cgi-bin/default/verse_range_builder.cgi?a="+com_abb+"&b="+b+"&c="+c,function(e){verses=$(e).find("data").text().split(",");var f=verses.length-1;var g=verses.length/8+2;var h=0;for(i=1;i<g;i++){oTr=$("<tr>");for(j=0;j<9;j++){var k=verses[h++];oTd=d!=k?$("<td>",{css:{padding:1+"px "+4+"px",onmouseover:"javascript:this.style.backgroundColor='#E7E3EF';",onmouseout:"javascript:this.style.backgroundColor='#FFFFFF';"},html:k}).click(function(){comCell_click("link",b,c,$(this).text())}):$("<td>",{css:{padding:1+"px "+4+"px"},"class":"alt_foreground_dark bold",html:"["+k+"]"});oTd.appendTo($(oTr));if(h>f){break}}oTr.appendTo($(cTbl));if(h>f){break}}cTbl.appendTo(cDiv1);cDiv1.appendTo($(a))},"xml")};var e=window.location.href.indexOf("?")>-1?window.location.href.substring(window.location.href.indexOf("?")):"";var f=document.getElementById("com_container");while(f.childNodes[0]){f.removeChild(f.childNodes[0])}switch(a){case"chapter":curCom_bn=b;_createTitles(f,4,b);_createChapter_list(f,b,c);break;case"verse":curCom_bn=b;curCom_cn=c;_createTitles(f,5,b,c,d);_createVerse_list(f,b,c,d);break;default:_createTitles(f,book_list_type);var g=book_list.split("/");var h=g[0].split(",");var k=g[1].split(",");if(book_list_type==1||book_list_type==2){_createBook_lists(f,book_list_type,"cOT_div",h,14,3,"y")}if(book_list_type==1||book_list_type==3){_createBook_lists(f,book_list_type,"cNT_div",k,10,3,"n")}break}}var curCh=0;var book_namesLong = 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','Psalms','Proverbs','Ecclesiastes','Song of Solomon','Isaiah','Jeremiah','Lamentations','Ezekiel','Daniel','Hosea','Joel','Amos','Obadiah','Jonah','Micah','Nahum','Habakkuk','Zephaniah','Haggai','Zechariah','Malachi','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');

