
otBookList=['genese','exode','levitique','nombres','deuteronome','josue','juges','ruth','1samuel','2samuel','1rois','2rois','1chroniques','2chroniques','esdras','nehemie','esther','job','psaumes','proverbes','ecclesiaste','cantique','esaie','jeremie','lamentations','ezechiel','daniel','osee','joel','amos','abdias','jonas','michee','nahum','habakuk','sophonie','aggee','zacharie','malachie'];
otJewishBookList=['genese','exode','levitique','nombres','deuteronome','josue','juges','1samuel','2samuel','1rois','2rois','esaie','jeremie','ezechiel','osee','joel','amos','abdias','jonas','michee','nahum','habakuk','sophonie','aggee','zacharie','malachie','psaumes','proverbes','job','cantique','ruth','lamentations','ecclesiaste','esther','daniel','esdras','nehemie','1chroniques','2chroniques'];
ntBookList=['matthieu','marc','luc','jean','actes','romains','1corinthiens','2corinthiens','galates','ephesiens','philippiens','colossiens','1thessaloniciens','2thessaloniciens','1timothee','2timothee','tite','philemon','hebreux','jacques','1pierre','2pierre','1jean','2jean','3jean','jude','apocalypse'];

bookData=[];
bookData['genese']=['Genèse',50];
bookData['exode']=['Exode',40];
bookData['levitique']=['Lévitique',27];
bookData['nombres']=['Nombres',36];
bookData['deuteronome']=['Deutéronome',34];
bookData['josue']=['Josué',24];
bookData['juges']=['Juges',21];
bookData['ruth']=['Ruth',4];
bookData['1samuel']=['1 Samuel',31];
bookData['2samuel']=['2 Samuel',24];
bookData['1rois']=['1 Rois',22];
bookData['2rois']=['2 Rois',25];
bookData['1chroniques']=['1 Chroniques',29];
bookData['2chroniques']=['2 Chroniques',36];
bookData['esdras']=['Esdras',10];
bookData['nehemie']=['Néhémie',13];
bookData['esther']=['Esther',10];
bookData['job']=['Job',42];
bookData['psaumes']=['Psaumes',150];
bookData['proverbes']=['Proverbes',31];
bookData['ecclesiaste']=['Ecclésiaste',12];
bookData['cantique']=['Cantique',8];
bookData['esaie']=['Esaïe',66];
bookData['jeremie']=['Jérémie',52];
bookData['lamentations']=['Lamentations',5];
bookData['ezechiel']=['Ezéchiel',48];
bookData['daniel']=['Daniel',12];
bookData['osee']=['Osée',14];
bookData['joel']=['Joël',3];
bookData['amos']=['Amos',9];
bookData['abdias']=['Abdias',1];
bookData['jonas']=['Jonas',4];
bookData['michee']=['Michée',7];
bookData['nahum']=['Nahum',3];
bookData['habakuk']=['Habakuk',3];
bookData['sophonie']=['Sophonie',3];
bookData['aggee']=['Aggée',2];
bookData['zacharie']=['Zacharie',14];
bookData['malachie']=['Malachie',4];
bookData['matthieu']=['Matthieu',28];
bookData['marc']=['Marc',16];
bookData['luc']=['Luc',24];
bookData['jean']=['Jean',21];
bookData['actes']=['Actes',28];
bookData['romains']=['Romains',16];
bookData['1corinthiens']=['1 Corinthiens',16];
bookData['2corinthiens']=['2 Corinthiens',13];
bookData['galates']=['Galates',6];
bookData['ephesiens']=['Ephésiens',6];
bookData['philippiens']=['Philippiens',4];
bookData['colossiens']=['Colossiens',4];
bookData['1thessaloniciens']=['1 Thessaloniciens',5];
bookData['2thessaloniciens']=['2 Thessaloniciens',3];
bookData['1timothee']=['1 Timothée',6];
bookData['2timothee']=['2 Timothée',4];
bookData['tite']=['Tite',3];
bookData['philemon']=['Philémon',1];
bookData['hebreux']=['Hébreux',13];
bookData['jacques']=['Jacques',5];
bookData['1pierre']=['1 Pierre',5];
bookData['2pierre']=['2 Pierre',3];
bookData['1jean']=['1 Jean',5];
bookData['2jean']=['2 Jean',1];
bookData['3jean']=['3 Jean',1];
bookData['jude']=['Jude',1];
bookData['apocalypse']=['Apocalypse',22];

otStdList=['labibledarby1885','labiblelouissegond1910', 'labiblemartin1744'];
otJewishList=[];
ntStdList=['labibledarby1885','labibledegeneve', 'labiblelouissegond1910', 'labiblemartin1744'];
partialList=[];
//calvinbible=[];
//calvinbible['ot']=['joshua'];
//calvinbible['nt']=['romans'];

// 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.net'){
	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='labibledegeneve';};
if(typeof(lastReferenceBook)=='undefined'){lastReferenceBook='matthieu';};
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+"biblesfrancais/pastrouve.html";
	var thisanchor=fetchAnchor();
	if(thisanchor!=''){thisanchor='#'+thisanchor;}
	var goodurl=baseURL+'biblesfrancais/'+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.net,'+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('biblesfrancais')!=-1){
	baseURL=docloc.substr(0,docloc.indexOf('biblesfrancais'));
	} 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.net/';}
}
giveBaseURL();

 // this function prints out the HTML for the banner
function printBanner(){
	if(screen.height>975) {
	document.write('<img src="'+baseURL+'biblesfrancais/images/bannerhistoriqueslarge.jpg" class="large" alt="Look Higher ! Bibles en français en ligne" title="">');
	} else {
	document.write('<img src="'+baseURL+'biblesfrancais/images/bannerhistoriquesmedium.jpg" class="medium" alt="Look Higher ! Bibles en français en ligne" title="">');
	};
	}

// this function prints out the search form
function printSearchForm(){
	document.write('<form style="display: none\;" action="http://lookhigher.net/biblesfrancais/resultatsdelarecherche.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();">Rechercher cette 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="labibledarby1885" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">La Bible Darby<br>1885 John Darby</a></li><li><a href="#" id="labibledegeneve" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">La Bible de Genève<br>1669 Samuel des Marets</a></li><li><a href="#" id="labiblelouissegond1910" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">La Bible Louis Segond<br>1910 comité</a></li><li><a href="#" id="labiblemartin1744" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">La Bible Martin<br>1744 Pierre Roques</a></li></ul>');
	}

// this function prints out the panel with the OT books available in the current version
function printOT(){
	var thishtml='<ul>';
	if(isInArray(versionName,partialList)){
		newarray=eval(versionName).ot;
		for(i=0;i<otBookList.length;i++){
			if(isInArray(otBookList[i],newarray)){
			//print normal button
			thishtml=thishtml+'<li><a href="'+baseURL+'biblesfrancais/'+versionName+'/'+otBookList[i]+'/1.html" id="b'+otBookList[i]+'">'+bookData[otBookList[i]][0]+'</a></li>';
			} else {
			//print grayed out button
			thishtml=thishtml+'<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++){
				thishtml=thishtml+'<li><a href="'+baseURL+'biblesfrancais/'+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++){
					thishtml=thishtml+'<li><a href="'+baseURL+'biblesfrancais/'+versionName+'/'+otJewishBookList[i]+'/1.html" id="b'+otJewishBookList[i]+'">'+bookData[otJewishBookList[i]][0]+'</a></li>';
					};
				} else {
				for(i=0;i<otBookList.length;i++){
				thishtml=thishtml+'<li><a href="#" id="b'+otBookList[i]+'" class="gray">'+bookData[otBookList[i]][0]+'</a></li>';
				};
				}
			};
		};
	thishtml=thishtml+'</ul>';
	document.write(thishtml);
	}

// this function prints out the panel with the NT books available in the current version
function printNT(){
	var thishtml='<ul>';
	if(isInArray(versionName,partialList)){
		newarray=eval(versionName).nt;
		for(i=0;i<ntBookList.length;i++){
			if(isInArray(ntBookList[i],newarray)){
			//print normal button
			thishtml=thishtml+'<li><a href="'+baseURL+'biblesfrancais/'+versionName+'/'+ntBookList[i]+'/1.html" id="b'+ntBookList[i]+'">'+bookData[ntBookList[i]][0]+'</a></li>';
			} else {
			//print grayed out button
			thishtml=thishtml+'<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++){
				thishtml=thishtml+'<li><a href="'+baseURL+'biblesfrancais/'+versionName+'/'+ntBookList[i]+'/1.html" id="b'+ntBookList[i]+'">'+bookData[ntBookList[i]][0]+'</a></li>';
				};
		} else {
		for(i=0;i<ntBookList.length;i++){
				thishtml=thishtml+'<li><a href="#" id="b'+ntBookList[i]+'" class="gray">'+bookData[ntBookList[i]][0]+'</a></li>';
				};
		};
	};
	for(k=0;k<12;k++){
		thishtml=thishtml+'<li><a href="#" class="blank">&nbsp;</a></li>';
		};
	thishtml=thishtml+'</ul>';
	document.write(thishtml);
	}


// 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+'biblesfrancais/'+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";
	}

function initialize(){
	if(typeof(dontscroll)=="undefined") {
		anchorsOffsetList=[];
		var anchor=1;
		while(document.getElementById('v'+anchor)!=null){anchorsOffsetList[anchor]=document.getElementById('v'+anchor).offsetTop; anchor++;};

		if(typeof(scrollVersion)=='undefined'){scrollVersion=document.getElementById(versionName).offsetTop-2;};
		if(typeof(scrollBook)=='undefined'){scrollBook=document.getElementById('b'+referenceBook).offsetTop-2;};
		if(typeof(scrollChapter)=='undefined'){scrollChapter=document.getElementById('c'+referenceChapter).offsetTop-2;};

		if(referenceChapter==1&&referenceBook!=lastReferenceBook){scrollChapter=0;}

		document.getElementById(versionName).className+=" selected";
		document.getElementById('b'+referenceBook).className+=" selected";
		document.getElementById('c'+referenceChapter).className+=" selected";

		var offset=document.getElementById('labiblelouissegond1910').offsetTop;
		offset=document.getElementById('bexode').offsetTop;

		document.getElementById('navbook').scrollTop=scrollBook;
		document.getElementById('navchapter').scrollTop=scrollChapter;
		document.getElementById('navversion').scrollTop=scrollVersion;
		};
	}

window.onload=initialize;
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>');
