var arrVerses;
var arrReferences;

arrVerses = new Array();
arrReferences = new Array();

var iArr=0;

arrVerses[iArr]		="For all have sinned and fall short of the glory of God.";
arrReferences[iArr++]	="Romans 3, 23 (NIV)";

arrVerses[iArr]		="Behold, the Lamb of God, who takes away the sin of the world!";
arrReferences[iArr++]	="John 1, 29 (RSV)";

arrVerses[iArr]		="There is therefore now no condemnation for those who are in Christ Jesus.";
arrReferences[iArr++]	="Romans 8, 1 (RSV)";

arrVerses[iArr]		= "For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.";
arrReferences[iArr++]	= "John 3, 16 (NIV)";

arrVerses[iArr]		= "The life I live in the body, I live by faith in the Son of God, who loved me and gave himself for me.";
arrReferences[iArr++]	= "Galatians 2, 20 (NIV)";

arrVerses[iArr]		= "My grace is sufficient for you, for my power is made perfect in weakness.";
arrReferences[iArr++]	= "2 Corinthians 12, 9 (NIV)";

arrVerses[iArr]		= "Yet to all who received him, to those who believed in his name, he gave the right to become children of God.";
arrReferences[iArr++]	= "John 1, 12 (NIV)";

arrVerses[iArr]		= "But God demonstrates his own love for us in this: while we were still sinners Christ died for us.";
arrReferences[iArr++]	= "Romans 5, 8 (NIV)";

arrVerses[iArr]		= "I write these things to you who believe in the name of the Son of God so that you may know that you have eternal life.";
arrReferences[iArr++]	= "1 John 5, 13 (NIV)";

arrVerses[iArr]		="You will seek me and find me when you seek me with all your heart.";
arrReferences[iArr++]	="Jeremiah 29, 13 (NIV)";

arrVerses[iArr]		="In the same way, count yourselves dead to sin but alive to God in Christ Jesus.";
arrReferences[iArr++]	="Romans 6, 11 (NIV)";

arrVerses[iArr]		="You, however, are controlled not by the sinful nature but by the Spirit.";
arrReferences[iArr++]	="Romans 8, 9 (NIV)";

arrVerses[iArr]		="My son, do not forget my teaching, but keep my commands in your heart.";
arrReferences[iArr++]	="Proverbs 3, 1 (NIV)";

arrVerses[iArr]		="Trust in the Lord with all your heart and lean not on your own understanding.";
arrReferences[iArr++]	="Proverbs 3, 5 (NIV)";

arrVerses[iArr]		="But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness and self-control.";
arrReferences[iArr++]	="Galatians 5, 22 (NIV)";

arrVerses[iArr]		="I consider that our present sufferings are not worth comparing with the glory that will be revealed in us.";
arrReferences[iArr++]	="Romans 8, 18 (NIV)";

//arrVerses[iArr]		="xxxxx";
//arrReferences[iArr++]	="xxxxxxxxxxxx";


var currentVerse=0;
var currentLetter=0;

function pickVerse()
{
	var i = Math.round(Math.random() * 1000) % arrReferences.length;
	if (i == currentVerse)
		i = (currentVerse + 1) % arrReferences.length;

	currentVerse=i;
}

function doAnimText()
{
	var browserName=navigator.appName; 
	var browserVersion=parseInt(navigator.appVersion); 

//	if (browserName=="Microsoft Internet Explorer" && browserVersion>=4)
	if (raoIsIE())
		doAnimText_IE();
	else
		doAnimText_Other();
}

function doAnimText_Other()
{
	pickVerse();

	var strVerse=new String(arrVerses[currentVerse]);
	document.getElementById('animText').innerHTML=strVerse;

	var strReference=new String(arrReferences[currentVerse]);
	document.getElementById('reference').innerHTML=strReference.toString();

	setTimeout("doAnimText()", 8000);
}

function doAnimText_IE()
{
	if (currentLetter==0)
	{
		pickVerse();
		document.getElementById('animText').innerHTML="";
	}
	
	var strVerse=new String(arrVerses[currentVerse]);

	if (currentLetter <= strVerse.length)
		document.getElementById('animText').innerHTML+=strVerse.charAt(currentLetter);

	var delay;
	
	if (currentLetter==strVerse.length)
	{
		//the verse is visible - pause before displaying the reference
		currentLetter++;
		delay=1500;
	}
	else if (currentLetter==strVerse.length+1)
	{
		//the verse and reference are visible - pause before going to the next verse
		currentLetter=0;
		delay=5000;

		var strReference=new String(arrReferences[currentVerse]);
		document.getElementById('reference').innerHTML=strReference.toString();
	}
	else
	{
		//continue displaying the current verse a letter at a time
		currentLetter++;
		delay=100;
		document.getElementById('reference').innerHTML="";
	}

	setTimeout("doAnimText()", delay);
}
