// JavaScript Document

/* Javascrippt file to handle the loading and scrolling of scriptures

The scroller displays the scriptures for the number of miliseconds defined in the DISPLAY_TIME constant, defined at the start
of the code section of this file. When the scroller gets to the last scripture, the scroller rolls over to start
with the first image again.

The very first imgae that is displayed when the scroller starts is random. Subsequent scriptures are in order as defined in the
scriptures array.
*/

var DISPLAY_TIME = 10000;		//In milliseconds

var SMALL_FONT = "120%";
var LARGE_FONT = "160%";


/*scriptures is an array of arrays. Each index consists of a sub-array with 2 indexes as follows:
	index0: The text of the scripture
	index1: The reference to the scripture, that is the Bible book, chapter, verse and Bible version
	
*/
var scriptures = new Array();
var indexVal = 0;

scriptures[indexVal++] = new Array("Hear, O Israel: The LORD our God is one LORD.", 
						 "Deut 6:4 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("And all these blessings shall come on thee, and overtake thee, if thou shalt hearken unto the voice of the LORD thy God.", 
						 "Deut 28:2 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("Even if I go through the deepest darkness, I will not be afraid, LORD, for you are with me. Your shepherd\'s rod and staff protect me.", 
						 "Ps 23:4 (GNB)", LARGE_FONT);
scriptures[indexVal++] = new Array("<sup>2</sup>Bless the LORD, O my soul, and forget not all his benefits: <sup>3</sup>Who forgiveth all thine iniquities; who healeth all thy diseases; <sup>4</sup>Who redeemeth thy life from destruction; who crowneth thee with lovingkindness and tender mercies; <sup>5</sup>Who satisfieth thy mouth with good things; so that thy youth is renewed like the eagle's.", 
						 "Ps 103:2-5 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("He sent his word, and healed them, and delivered them from their destructions.", 
						 "Ps 107:20 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("<sup>1</sup>Praise ye the LORD. Blessed is the man that feareth the LORD, that delighteth greatly in his commandments. <sup>2</sup>His seed shall be mighty upon earth: the generation of the upright shall be blessed.  <sup>3</sup>Wealth and riches shall be in his house: and his righteousness endureth for ever.", 
						 "Ps 112:1-3 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("<sup>23</sup>When thou liest down, thou shalt not be afraid: yea, thou shalt lie down, and thy sleep shall be sweet. <sup>24</sup>Be not afraid of sudden fear, neither of the desolation of the wicked, when it cometh. <sup>25</sup>For the LORD shall be thy confidence, and shall keep thy foot from being taken.", 
						 "Prov 3:24-26 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("But he was wounded for our transgressions, he was bruised for our iniquities: the chastisement of our peace was upon him; and with his stripes we are healed.", 
						 "Isa 53:5 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("And Jesus said unto them, Because of your unbelief: for verily I say unto you, If ye have faith as a grain of mustard seed, ye shall say unto this mountain, Remove hence to yonder place; and it shall remove; and nothing shall be impossible unto you.", 
						 "Matt 17:20 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("For verily I say unto you, That whosoever shall say unto this mountain, Be thou removed, and be thou cast into the sea; and shall not doubt in his heart, but shall believe that those things which he saith shall come to pass; he shall have whatsoever he saith.", "Mark 11:23 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("Therefore I say unto you, What things soever ye desire, when ye pray, believe that ye receive them, and ye shall have them.", 
						 "Mark 11:24 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("Jesus saith unto him, I am the way, the truth, and the life: no man cometh unto the Father, but by me.", 
						 "John 14:6 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("I am the true vine, and my Father is the vinedresser.", 
						 "John 15:1 (ESV)", LARGE_FONT);
scriptures[indexVal++] = new Array("I am the vine; you are the branches. Whoever abides in me and I in him, he it is that bears much fruit, for apart from me you can do nothing.", 
						 "John 15:5 (ESV)", LARGE_FONT);
scriptures[indexVal++] = new Array("This is my commandment, That ye love one another, as I have loved you. ", 
						 "John 15:12 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("These things I have spoken unto you, that in me ye might have peace. In the world ye shall have tribulation: but be of good cheer; I have overcome the world.", 
						 "John 16:33 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("And this is life eternal, that they might know thee the only true God, and Jesus Christ, whom thou hast sent.", 
						 "John 17:3 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("Let all the house of Israel therefore know for certain that God has made him both Lord and Christ, this Jesus whom you crucified.", 
						 "Acts 2:36 (ESV)", LARGE_FONT);
scriptures[indexVal++] = new Array("And Peter said to them, Repent and be baptized every one of you in the name of Jesus Christ for the forgiveness of your sins, and you will receive the gift of the Holy Spirit.", 
						 "Acts 2:38 (ESV)", LARGE_FONT);
scriptures[indexVal++] = new Array("And there is salvation in no one else, for there is no other name under heaven given among men by which we must be saved.", 
						  "Acts 4:12 (ESV)", LARGE_FONT);
scriptures[indexVal++] = new Array("But if the Spirit of him that raised up Jesus from the dead dwell in you, he that raised up Christ from the dead shall also quicken your mortal bodies by his Spirit that dwelleth in you.", 
						  "Rom 8:11 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("<sup>37</sup>Nay, in all these things we are more than conquerors through him that loved us. <sup>38</sup>For I am persuaded, that neither death, nor life, nor angels, nor principalities, nor powers, nor things present, nor things to come, <sup>39</sup>Nor height, nor depth, nor any other creature, shall be able to separate us from the love of God, which is in Christ Jesus our Lord.", 
						 "Rom 8:37-39 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("But to us there is but one God, the Father, of whom are all things, and we in him; and one Lord Jesus Christ, by whom are all things, and we by him.", 
						 "1 Cor 8:6 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("Finally, brethren, whatsoever things are true, whatsoever things are honest, whatsoever things are just, whatsoever things are pure, whatsoever things are lovely, whatsoever things are of good report; if there be any virtue, and if there be any praise, think on these things.", 
						 "Phil 4:8 (KJV)", SMALL_FONT);
scriptures[indexVal++] = new Array("But my God shall supply all your need according to his riches in glory by Christ Jesus.", 
						 "Phil 4:19 (KJV)", LARGE_FONT);
scriptures[indexVal++] = new Array("Who his own self bare our sins in his own body on the tree, that we, being dead to sins, should live unto righteousness: by whose stripes ye were healed.", 
						 "1 Pet 2:24 (KJV)", LARGE_FONT);


var currentScripture = 0;

var contentComponentId = null;
var referenceComponentId = null;

function startScroller(scriptureContentComponentId, scriptureReferenceComponentId){
	contentComponentId = document.getElementById(scriptureContentComponentId);
	referenceComponentId = document.getElementById(scriptureReferenceComponentId);
	
	currentScripture = Math.floor(Math.random()*scriptures.length);
	loadNextScripture();
	window.setInterval("loadNextScripture()", DISPLAY_TIME);
}

function loadNextScripture(){
	
	if (++currentScripture >= scriptures.length){
		currentScripture = 0;
	}
	//currentScripture = Math.floor(Math.random()*scriptures.length);
	
	if(contentComponentId != null){
		contentComponentId.innerHTML = scriptures[currentScripture][0];
		contentComponentId.style.fontSize = scriptures[currentScripture][2];
	}
	
	if(referenceComponentId != null){
		referenceComponentId.innerHTML = scriptures[currentScripture][1];
	}
}
