otBookList=['genesis','exodo','levitico','numeros','deuteronomio','josue','jueces','rut','1samuel','2samuel','1reyes','2reyes','1cronicas','2cronicas','esdras','nehemias','ester','job','salmos','proverbios','eclesiastes','cantares','isaias','jeremias','lamentaciones','ezequiel','daniel','oseas','joel','amos','abdias','jonas','miqueas','nahum','habacuc','sofonias','hageo','zacarias','malaquias'];
otJewishBookList=['genesis','exodo','levitico','numeros','deuteronomio','josue','jueces','1samuel','2samuel','1reyes','2reyes','isaias','jeremias','ezequiel','oseas','joel','amos','abdias','jonas','miqueas','nahum','habacuc','sofonias','hageo','zacarias','malaquias','salmos','proverbios','job','cantares','rut','lamentaciones','eclesiastes','ester','daniel','esdras','nehemias','1cronicas','2cronicas'];
ntBookList=['mateo','marcos','lucas','juan','hechos','romanos','1corintios','2corintios','galatas','efesios','filipenses','colosenses','1tesalonicenses','2tesalonicenses','1timoteo','2timoteo','tito','filemon','hebreos','santiago','1pedro','2pedro','1juan','2juan','3juan','judas','apocalipsis'];

bookData=[];
bookData['genesis']=['Génesis',50];
bookData['exodo']=['Éxodo',40];
bookData['levitico']=['Levítico',27];
bookData['numeros']=['Números',36];
bookData['deuteronomio']=['Deuteronomio',34];
bookData['josue']=['Josué',24];
bookData['jueces']=['Jueces',21];
bookData['rut']=['Rut',4];
bookData['1samuel']=['1 Samuel',31];
bookData['2samuel']=['2 Samuel',24];
bookData['1reyes']=['1 Reyes',22];
bookData['2reyes']=['2 Reyes',25];
bookData['1cronicas']=['1 Crónicas',29];
bookData['2cronicas']=['2 Crónicas',36];
bookData['esdras']=['Esdras',10];
bookData['nehemias']=['Nehemías',13];
bookData['ester']=['Ester',10];
bookData['job']=['Job',42];
bookData['salmos']=['Salmos',150];
bookData['proverbios']=['Proverbios',31];
bookData['eclesiastes']=['Eclesiastés',12];
bookData['cantares']=['Cantares',8];
bookData['isaias']=['Isaías',66];
bookData['jeremias']=['Jeremías',52];
bookData['lamentaciones']=['Lamentaciones',5];
bookData['ezequiel']=['Ezequiel',48];
bookData['daniel']=['Daniel',12];
bookData['oseas']=['Oseas',14];
bookData['joel']=['Joel',3];
bookData['amos']=['Amós',9];
bookData['abdias']=['Abdías',1];
bookData['jonas']=['Jonás',4];
bookData['miqueas']=['Miqueas',7];
bookData['nahum']=['Nahúm',3];
bookData['habacuc']=['Habacuc',3];
bookData['sofonias']=['Sofonías',3];
bookData['hageo']=['Hageo',2];
bookData['zacarias']=['Zacarías',14];
bookData['malaquias']=['Malaquías',4];
bookData['mateo']=['Mateo',28];
bookData['marcos']=['Marcos',16];
bookData['lucas']=['Lucas',24];
bookData['juan']=['Juan',21];
bookData['hechos']=['Hechos',28];
bookData['romanos']=['Romanos',16];
bookData['1corintios']=['1 Corintios',16];
bookData['2corintios']=['2 Corintios',13];
bookData['galatas']=['Gálatas',6];
bookData['efesios']=['Efesios',6];
bookData['filipenses']=['Filipenses',4];
bookData['colosenses']=['Colosenses',4];
bookData['1tesalonicenses']=['1 Tesalonicenses',5];
bookData['2tesalonicenses']=['2 Tesalonicenses',3];
bookData['1timoteo']=['1 Timoteo',6];
bookData['2timoteo']=['2 Timoteo',4];
bookData['tito']=['Tito',3];
bookData['filemon']=['Filemón',1];
bookData['hebreos']=['Hebreos',13];
bookData['santiago']=['Santiago',5];
bookData['1pedro']=['1 Pedro',5];
bookData['2pedro']=['2 Pedro',3];
bookData['1juan']=['1 Juan',5];
bookData['2juan']=['2 Juan',1];
bookData['3juan']=['3 Juan',1];
bookData['judas']=['Judas',1];
bookData['apocalipsis']=['Apocalipsis',22];

otStdList=['reinavalera1909','reinavalera1865','versionmoderna'];
otJewishList=[];
ntStdList=['reinavalera1909','reinavalera1865','reinavalera1858','versionmoderna'];
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.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='reinavalera1858';};
if(typeof(lastReferenceBook)=='undefined'){lastReferenceBook='mateo';};
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+"bibliasespanol/noencontrada.html";
	var thisanchor=fetchAnchor();
	if(thisanchor!=''){thisanchor='#'+thisanchor;}
	var goodurl=baseURL+'bibliasespanol/'+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('bibliasespanol')!=-1){
	baseURL=docloc.substr(0,docloc.indexOf('bibliasespanol'));
	} 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+'bibliasespanol/images/bannerhistoricaslarge.jpg" class="large" alt="Look Higher ! - Biblias en español en línea" title="">');
	} else {
	document.write('<img src="'+baseURL+'bibliasespanol/images/bannerhistoricasmedium.jpg" class="medium" alt="Look Higher ! - Biblias en español en línea" title="">');
	};
	}

// this function prints out the search form
function printSearchForm(){
	document.write('<form style="display: none\;" action="http://lookhigher.net/bibliasespanol/resultadosdebusqueda.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();">Buscar en este versión</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="reinavalera1858" onmouseover="this.href=getNewUrl(this.id)\;" class="v3">Reina-Valera<br>1858 Sociedad Bíblica<br>Británica y Extranjera</a></li><li><a href="#" id="reinavalera1865" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">Reina-Valera<br>1865 Ángel de Mora</a></li><li><a href="#" id="reinavalera1909" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">Reina-Valera<br>1909 Victoriano Baez</a></li><li><a href="#" id="versionmoderna" onmouseover="this.href=getNewUrl(this.id)\;" class="v2">Versión Moderna<br>1929 Enrique Pratt</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+'bibliasespanol/'+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+'bibliasespanol/'+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+'bibliasespanol/'+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+'bibliasespanol/'+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+'bibliasespanol/'+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+'bibliasespanol/'+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;};

		// make sure buttons will be in view, otherwise change the scroll points
		//if(document.getElementById('b'+referenceBook).offsetTop<scrollBook||document.getElementById('b'+referenceBook).offsetTop>scrollBook-(-divheight)){ scrollBook=document.getElementById('b'+referenceBook).offsetTop; }
		//if(document.getElementById('c'+referenceChapter).offsetTop<scrollChapter||document.getElementById('c'+referenceChapter).offsetTop>scrollChapter-(-divheight)){ scrollChapter=document.getElementById('c'+referenceChapter).offsetTop; }

		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('reinavalera1865').offsetTop;
		offset=document.getElementById('bexodo').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>');