
otBookList=['introduction','appendix'];
otJewishBookList=['genesis','exodus','leviticus','numbers','deuteronomy','joshua','judges','1samuel','2samuel','1kings','2kings','isaiah','jeremiah','ezekiel','hosea','joel','amos','obadiah','jonah','micah','nahum','habakkuk','zephaniah','haggai','zechariah','malachi','psalms','proverbs','job','songofsolomon','ruth','lamentations','ecclesiastes','esther','daniel','ezra','nehemiah','1chronicles','2chronicles'];
ntBookList=['matthew','mark','luke','john','acts','romans','1corinthians','2corinthians','galatians','ephesians','philippians','colossians','1thessalonians','2thessalonians','1timothy','2timothy','titus','philemon','hebrews','james','1peter','2peter','1john','2john','3john','jude','revelation'];

bookData=[];
bookData['introduction']=['Introduction',1];
bookData['appendix']=['Appendix',1];

bookData['matthew']=['Matthew',28];
bookData['mark']=['Mark',16];
bookData['luke']=['Luke',24];
bookData['john']=['John',21];
bookData['acts']=['Acts',28];
bookData['romans']=['Romans',16];
bookData['1corinthians']=['1 Corinthians',16];
bookData['2corinthians']=['2 Corinthians',13];
bookData['galatians']=['Galatians',6];
bookData['ephesians']=['Ephesians',6];
bookData['philippians']=['Philippians',4];
bookData['colossians']=['Colossians',4];
bookData['1thessalonians']=['1 Thessalonians',5];
bookData['2thessalonians']=['2 Thessalonians',3];
bookData['1timothy']=['1 Timothy',6];
bookData['2timothy']=['2 Timothy',4];
bookData['titus']=['Titus',3];
bookData['philemon']=['Philemon',1];
bookData['hebrews']=['Hebrews',13];
bookData['james']=['James',5];
bookData['1peter']=['1 Peter',5];
bookData['2peter']=['2 Peter',3];
bookData['1john']=['1 John',5];
bookData['2john']=['2 John',1];
bookData['3john']=['3 John',1];
bookData['jude']=['Jude',1];
bookData['revelation']=['Revelation',22];

otStdList=['accuratenewtestamentfirstedition','accuratenewtestamentsecondedition'];
otJewishList=[];
ntStdList=['accuratenewtestamentfirstedition','accuratenewtestamentsecondedition'];
partialList=[];

// the code here loads up the variables lastVersionName, lastReferenceBook, lastReferenceChapter, scrollVersion, scrollBook, scrollChapter, and referenceVerse from window.name if it exists
if(window.name.substr(0,14)=='lookhigher.com'){
	var chopstring=window.name.substr(15);
	var nextcut=chopstring.indexOf(',');
	lastVersionName=chopstring.substr(0,nextcut);
		chopstring=chopstring.slice(nextcut-(-1));
	nextcut=chopstring.indexOf(',');
	lastReferenceBook=chopstring.substr(0,nextcut);
		chopstring=chopstring.slice(nextcut-(-1));
	nextcut=chopstring.indexOf(',');
	lastReferenceChapter=chopstring.substr(0,nextcut);
		chopstring=chopstring.slice(nextcut-(-1));
	nextcut=chopstring.indexOf(',');
	scrollVersion=chopstring.substr(0,nextcut);
		chopstring=chopstring.slice(nextcut-(-1));
	nextcut=chopstring.indexOf(',');
	scrollBook=chopstring.substr(0,nextcut);
		chopstring=chopstring.slice(nextcut-(-1));
	nextcut=chopstring.indexOf(',');
	scrollChapter=chopstring.substr(0,nextcut);
		chopstring=chopstring.slice(nextcut-(-1));
	nextcut=chopstring.indexOf(',');
	referenceVerse=chopstring.substr(0,nextcut);
	lastSearch=chopstring.slice(nextcut-(-1));
	};

// put in stand-in values for last known version, book, and chapter if none is known
if(typeof(lastVersionName)=='undefined'){lastVersionName='accuratenewtestamentfirstedition';};
if(typeof(lastReferenceBook)=='undefined'){lastReferenceBook='introduction';};
if(typeof(lastReferenceChapter)=='undefined'){lastReferenceChapter=1;};

// use last known values if no current values are given in this document
if(typeof(versionName)=='undefined'){versionName=lastVersionName;};
if(typeof(referenceBook)=='undefined'){referenceBook=lastReferenceBook;};
if(typeof(referenceChapter)=='undefined'){referenceChapter=lastReferenceChapter;};
if(typeof(referenceVerse)=='undefined'){referenceVerse='';};
if(typeof(lastSearch)=='undefined'){lastSearch='';};

function isInArray(lookfor, arrayname){
	for(j=0;j<arrayname.length;j++){
		if(lookfor==arrayname[j]){
			return true;
			};
		};
	return false;
	}

function fetchAnchor(){
	if(document.getElementById('v1')==null){ return referenceVerse; };
	var scrollNumber=document.getElementById("contentdiv").scrollTop;
	var currentAnchorNumber=0;
	while(anchorsOffsetList[currentAnchorNumber-(-1)]<=scrollNumber){
		currentAnchorNumber++;
		};
	if(anchorsOffsetList[currentAnchorNumber-(-1)]-scrollNumber<scrollNumber-anchorsOffsetList[currentAnchorNumber]){currentAnchorNumber++;};
	if(currentAnchorNumber==0){return '';} else {return 'v'+currentAnchorNumber;}
	}

// this function sends the document to a URL reflecting the current book, chapter, and verse (used when the user clicks on a version button)
function getNewUrl(newVersion){
	var notfoundurl=baseURL+"bibles/notfound.html";
	var thisanchor=fetchAnchor();
	if(thisanchor!=''){thisanchor='#'+thisanchor;}
	var goodurl=baseURL+'bibles/'+newVersion+'/'+referenceBook+'/'+referenceChapter+'.html'+thisanchor;
	if(isInArray(newVersion,partialList)){
		if(isInArray(referenceBook,eval(newVersion)['ot'])||isInArray(referenceBook,eval(newVersion)['nt'])){return goodurl;};
		} else {
		if(isInArray(referenceBook,otBookList)){if(isInArray(newVersion,otStdList)||isInArray(newVersion,otJewishList)){return goodurl;}};
		if(isInArray(referenceBook,ntBookList)){if(isInArray(newVersion,ntStdList)){return goodurl;};};
		}
	return notfoundurl+'?'+newVersion;
	}

// this function takes this page's info (versionName, referenceBook, referenceChapter, result of fetchAnchor(), scroll points of nav divs) and stores it in window.name
function storePageData(){
	window.name='lookhigher.com,'+versionName+','+referenceBook+','+referenceChapter+','+document.getElementById('navversion').scrollTop+','+document.getElementById('navbook').scrollTop+','+document.getElementById('navchapter').scrollTop+','+fetchAnchor()+','+document.forms[0].elements['q'].value;
	}

// calculate the base URL for the site
function giveBaseURL(){
baseURL='';
var docloc=document.location+' ';
if(docloc.indexOf('bibles')!=-1){
	baseURL=docloc.substr(0,docloc.indexOf('bibles'));
	} else {
	if(docloc.indexOf('index')!=-1){baseURL=docloc.substr(0,docloc.indexOf('index'));}
	if(docloc.indexOf('error')!=-1){baseURL=docloc.substr(0,docloc.indexOf('error'));}
	}
if(baseURL==''){baseURL='http://lookhigher.com/';}
}
giveBaseURL();

 // this function prints out the HTML for the banner
function printBanner(){
	if(screen.height>975) {
		if(versionName=="accuratenewtestamentsecondedition") {
			document.write('<img src="'+baseURL+'bibles/images/bannersecondlarge.jpg" class="large" alt="Look Higher ! - Accurate New Testament, Second Edition" title="">');
		} else {
			document.write('<img src="'+baseURL+'bibles/images/bannerfirstlarge.jpg" class="large" alt="Look Higher ! - Accurate New Testament, First Edition" title="">');
		};
	} else {
		if(versionName=="accuratenewtestamentsecondedition") {
			document.write('<img src="'+baseURL+'bibles/images/bannersecondmedium.jpg" class="medium" alt="Look Higher ! - Accurate New Testament, Second Edition" title="">');
		} else {
			document.write('<img src="'+baseURL+'bibles/images/bannerfirstmedium.jpg" class="medium" alt="Look Higher ! - Accurate New Testament, First Edition" title="">');
		};
	};
};

// this function prints out the search form
function printSearchForm(){
	document.write('<form style="display: none\;" action="http://lookhigher.com/bibles/searchresults.php" method="get" autocomplete="off" onsubmit="storePageData()\; if(document.forms[0].elements[\'q\'].value==\'\'){return false}\;"><table><tr><td class="searchtablecell1"><input type="text" name="q" value="" maxlength="255" size="40"></td><td class="searchtablecell2"><ul><li><a href="#" onclick="document.forms[0].submit();">Search this version</a></li></ul><input type="hidden" name="p" value="1"><input type="hidden" name="v" value=""></td></tr></table></form>');
	document.forms[0].elements['q'].value=lastSearch;
	document.forms[0].elements['v'].value=versionName;
	}

// this function prints out the navigation panel
function printVersions(){
	document.write('<ul><li><a href="#" id="accuratenewtestamentfirstedition" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">Accurate New Testament<br>First Edition</a></li><li><a href="#" id="accuratenewtestamentsecondedition" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">Accurate New Testament<br>Second Edition</a></li></ul>');
	}

// this function prints out the panel with the OT books available in the current version
function printOT(){
	document.write('<ul>');
	if(isInArray(versionName,partialList)){
		newarray=eval(versionName).ot;
		for(i=0;i<otBookList.length;i++){
			if(isInArray(otBookList[i],newarray)){
			//print normal button
			document.write('<li><a href="'+baseURL+'bibles/'+versionName+'/'+otBookList[i]+'/1.html" id="b'+otBookList[i]+'">'+bookData[otBookList[i]][0]+'</a></li>');
			} else {
			//print grayed out button
			document.write('<li><a href="#" id="b'+otBookList[i]+'" class="gray">'+bookData[otBookList[i]][0]+'</a></li>');
			};
			}
		} else { // not partial
		if(isInArray(versionName,otStdList)){
			for(i=0;i<otBookList.length;i++){
				document.write('<li><a href="'+baseURL+'bibles/'+versionName+'/'+otBookList[i]+'/1.html" id="b'+otBookList[i]+'">'+bookData[otBookList[i]][0]+'</a></li>');
				};
			} else {
				if(isInArray(versionName,otJewishList)){
					for(i=0;i<otJewishBookList.length;i++){
					document.write('<li><a href="'+baseURL+'bibles/'+versionName+'/'+otJewishBookList[i]+'/1.html" id="b'+otJewishBookList[i]+'">'+bookData[otJewishBookList[i]][0]+'</a></li>');
					};
				} else {
				for(i=0;i<otBookList.length;i++){
				document.write('<li><a href="#" id="b'+otBookList[i]+'" class="gray">'+bookData[otBookList[i]][0]+'</a></li>');
				};
				}
			};
		};
	for(k=0;k<25;k++){
		document.write('<li><a href="#" class="blank">&nbsp;</a></li>');
		};
	document.write('</ul>');
	}

// this function prints out the panel with the NT books available in the current version
function printNT(){
	document.write('<ul>');
	if(isInArray(versionName,partialList)){
		newarray=eval(versionName).nt;
		for(i=0;i<ntBookList.length;i++){
			if(isInArray(ntBookList[i],newarray)){
			//print normal button
			document.write('<li><a href="'+baseURL+'bibles/'+versionName+'/'+ntBookList[i]+'/1.html" id="b'+ntBookList[i]+'">'+bookData[ntBookList[i]][0]+'</a></li>');
			} else {
			//print grayed out button
			document.write('<li><a href="#" id="b'+ntBookList[i]+'" class="gray">'+bookData[ntBookList[i]][0]+'</a></li>');
			};
			}
		} else {
		if(isInArray(versionName,ntStdList)){
			for(i=0;i<ntBookList.length;i++){
				document.write('<li><a href="'+baseURL+'bibles/'+versionName+'/'+ntBookList[i]+'/1.html" id="b'+ntBookList[i]+'">'+bookData[ntBookList[i]][0]+'</a></li>');
				};
		} else {
		for(i=0;i<ntBookList.length;i++){
				document.write('<li><a href="#" id="b'+ntBookList[i]+'" class="gray">'+bookData[ntBookList[i]][0]+'</a></li>');
				};
		};
	};
//	for(k=0;k<12;k++){
//		document.write('<li><a href="#" class="blank">&nbsp;</a></li>');
//		};
	document.write('</ul>');
	}


// this function prints out the panel with the chapters available in the current book
function printChapters(){
document.write('<ul>');
	if(typeof(sitemap)=='undefined'){
		if(document.getElementById('b'+referenceBook).className!='gray'){
			for(i=1;i<=bookData[referenceBook][1];i++){
				document.write('<li><a href="'+baseURL+'bibles/'+versionName+'/'+referenceBook+'/'+i+'.html" id="c'+i+'">'+i+'</a></li>');
				};
			} else {
			for(i=1;i<=bookData[referenceBook][1];i++){
				document.write('<li><a href="#" id="c'+i+'" class="gray">'+i+'</a></li>');
				};
			};
		};
	document.write('</ul>');
	}

function getWindowHeight(){
	var winHeight=window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
	return winHeight;
	}

// function that adjusts the height of the divs if the user resizes the window
function doLayout(){
	newheight=getWindowHeight()-48-document.images[0].height;
	if(newheight<325){newheight=325;};
	if(newheight>742){newheight=742;};
	document.getElementById('navversion').style.height=newheight + "px";
	document.getElementById('navbook').style.height=newheight + "px";
	document.getElementById('navchapter').style.height=newheight + "px";
	document.getElementById('contentdiv').style.height=newheight + "px";
	}

var windowHeight=getWindowHeight();
var picheight;
if(screen.height>975){ picheight=363;} else {picheight=182;}
divheight=windowHeight-48-picheight;
if(divheight<325){divheight=325;};
if(divheight>742){divheight=742;};
document.write('<style type="text/css">#navversion, #navbook, #navchapter, #contentdiv { height: '+divheight+'px\; }</style>');