var Interval=2000;
var currentImage;
var SlowButtonLabel = " Slower ";
var FastButtonLabel = " Faster ";
var PreviousButtonLabel = "Previous";
var NextButtonLabel = "  Next  ";
var timePtr;
// for next and [previous do wrap around
var maxNext;   
var maxPrevious;
var previousImage;
var nextImage;
var step;
var explain;
var imageExplanation;
var imageStep;
function DefineScripture()
{
	var today_obj=new Date();
	var today_date=today_obj.getDate();
	var tips=new Array();
	var tiptitle='';
	tips[1]=' Psalm 51:4 Against you, you only, have I sinned and done what is evil in your sight, so that you are proved right when you speak and justified when you judge. ';	
	tips[2]=' Luke 18:14 "I tell you that this man, rather than the other, went home justified before God. For everyone who exalts himself will be humbled, and he who humbles himself will be exalted."  ';
	tips[3]=' Acts 13:38-39 "Therefore, my brothers, I want you to know that through Jesus the forgiveness of sins is proclaimed to you. Through him everyone who believes is justified from everyting you could not be justified from by the law of Moses. ' ;
	tips[4]=' Romans 3:22-24 This righteousness from God comes through faith in Jesus Christ to all who believe. There is no difference, for all have sinned and fall short of the glory of God, and are justified freely by his grace through the redemption that came by Christ Jesus.   ';
	tips[5]=' Romans 3:28 For we maintain that a man is justified by faith apart from observing the law. ';
	tips[6]=' Romans 5:8-9 But God demonstrates his own love for us in this: While we were still sinners, Christ died for us. Since we have now been justified by his blood, how much more shall we be saved from God`s wrath through him! ';
	tips[7]=' Romans 10:10 For it is with your heart that you believe and are justified, and it is with your mouth that you confess and are saved.  ';
	tips[8]=' Galatians 2:16 know that a man is not justified by observing the law, but by faith in Jesus Christ. So we, too, have put our faith in Christ Jesus that we may be justified by faith in Christ and not by observing the law, because by observing the law no one will be justified.  ';
	tips[9]=' Galatians 2:17 "If, while we seek to be justified in Christ, it becomes evident that we ourselves are sinners, does that mean that Christ promotes sin? Absolutely not!  ';
	tips[10]='Galatians 3:24 So the law was put in charge to lead us to Christ that we might be justified by faith. ';
	tips[11]='Luke 16:15 He said to them, "You are the ones who justify yourselves in the eyes of men, but God knows your hearts. What is highly valued among men is detestable in God`s sight. ';
	tips[12]='Romans 3:29-30 Is God the God of Jews only? Is he not the God of Gentiles too? Yes, of Gentiles too, since there is only one God, who will justify the circumcised by faith and the uncircumcised through that same faith. ';
	tips[13]='Exodus 23:1-2 "Do not spread false reports. Do not help a wicked man by being a malicious witness.  "Do not follow the crowd in doing wrong. When you give testimony in a lawsuit, do not pervert justice by siding with the crowd,  ';
	tips[14]='Leviticus 19:15 " `Do not pervert justice; do not show partiality to the poor or favoritism to the great, but judge your neighbor fairly. ';
	tips[15]='Deuteronomy 16:19 Do not pervert justice or show partiality. Do not accept a bribe, for a bribe blinds the eyes of the wise and twists the words of the righteous.  ';
	tips[16]='Deuteronomy 16:20 Follow justice and justice alone, so that you may live and possess the land the LORD your God is giving you. ';
	tips[17]='2 Chronicles 19:7 Now let the fear of the LORD be upon you. Judge carefully, for with the LORD our God there is no injustice or partiality or bribery."  ';
	tips[18]='Job 29:14 I put on righteousness as my clothing; justice was my robe and my turban.  ';
	tips[19]='Job 37:23 The Almighty is beyond our reach and exalted in power; in his justice and great righteousness, he does not oppress. ';
	tips[20]='Psalm 9:8 He will judge the world in righteousness; he will govern the peoples with justice. ';
	tips[21]='Psalm 11:7 For the LORD is righteous, he loves justice; upright men will see his face.  ';
	tips[22]='Psalm 33:5 The LORD loves righteousness and justice; the earth is full of his unfailing love.  ';
	tips[23]='Psalm 36:6 Your righteousness is like the mighty mountains, your justice like the great deep. O LORD , you preserve both man and beast. ';
	tips[24]='Psalm 45:6 Your throne, O God, will last for ever and ever; a scepter of justice will be the scepter of your kingdom.  ';
	tips[25]='Psalm 101:1 I will sing of your love and justice; to you, O LORD , I will sing praise.  ';
	tips[26]='Psalm 106:3 Blessed are they who maintain justice, who constantly do what is right. ';
	tips[27]='Psalm 112:5 Good will come to him who is generous and lends freely, who conducts his affairs with justice. ';
	tips[28]='Proverbs 28:5 Evil men do not understand justice, but those who seek the LORD understand it fully. ';
	tips[29]='Isaiah 5:16 But the LORD Almighty will be exalted by his justice, and the holy God will show himself holy by his righteousness. ';
	tips[30]='Isaiah 9:7 Of the increase of his government and peace there will be no end. He will reign on David`s throne and over his kingdom, establishing and upholding it with justice and righteousness from that time on and forever. The zeal of the LORD Almighty will accomplish this.  ';
	tips[31]='Isaiah 30:18 Yet the LORD longs to be gracious to you; he rises to show you compassion. For the LORD is a God of justice. Blessed are all who wait for him!  ';
	scripture = document.getElementById("x");
	newNode = document.createTextNode("Hello");
	scripture.appendChild(newNode);
	//newNode.data = 'Go and make disciples of all the nations baptizing them in the name of the Father and of the Son and of the Holy Spirit and teaching them to obey everything I have commanded of you and surely I am with you always to the very end of age';
	//newNode.data = tips[30];
	newNode.data = tips[today_date];
	//document.write(tips[today_date]);
}
function PreloadImages(imagesToLoad, baseFileName, imageExtension)
{
	
	// window.alert("I got " + imagesToLoad);
	images = new Array(imagesToLoad);	
	for (var i=0; i< imagesToLoad; i++)
	{
		images[i] = new Image();
		images[i].src = baseFileName+i+"."+imageExtension;
	//	window.alert("image loaded is:"+images[i].src);
	}
	
	currentImage = 0;
	maxPrevious = 0;
	maxNext = imagesToLoad - 1;
	previousImage = new Image();
	nextImage = new Image();	
	previousImage.src = "globalgraphics/previous.gif";
	nextImage.src = "globalgraphics/next.gif";
	
	SetTextOn(currentImage);
	currentImage = 2;
	timePtr = window.setTimeout("SwapManager(1)",Interval);
	radioButtons = document.getElementsByName("navmethod");
	if (radioButtons[0].value == "manual")
	{
		manualButton = radioButtons[0];
		autoButton = radioButtons[1];
	} else if (radioButtons[1].value == "manual")
	{
		manualButton = radioButtons[1];
		autoButton = radioButtons[0];
	}
	autoButton.checked = 1;
	
}
function SetTextOff(myCurrent)
{
	var a=0;
//	window.alert("maxNext is "+maxNext);
//	for (var i=1; i<= maxNext+1; i++)
//	{
//		something = document.getElementById("explain"+i);
//		something.style.display = "none";		
//		something = document.getElementById("step"+i);
//		something.style.display = "none";		
//		
//	}
	a = myCurrent+1;
//	window.alert(" a is "+a);
	something = document.getElementById("step"+a);
	something.style.display = "none";			
	something = document.getElementById("explain"+a);
	something.style.display = "none";		
}

function SetTextOn(myCurrent)
{
	var a=0;
//	window.alert("maxNext is "+maxNext);
//	for (var i=1; i<= maxNext+1; i++)
//	{
//		something = document.getElementById("explain"+i);
//		something.style.display = "none";		
//		something = document.getElementById("step"+i);
//		something.style.display = "none";		
//		
//	}
	a = myCurrent+1;
//	window.alert(" a is "+a);
	something = document.getElementById("step"+a);
	something.style.display = "";			
	something = document.getElementById("explain"+a);
	something.style.display = "";		
}

function LeftButtonClick(myForm)
{
	if (document.images)
		{
			if (document["leftNavButton"].src != previousImage.src)
			{
				// Slower
				Interval += 1000;
				if (Interval > 5000)
				{
					Interval = 5000;
				}
				window.clearTimeout(timePtr);
				timePtr = window.setTimeout("SwapManager(1)",Interval); 
			}
			else
			{
				// Previous
				DirectionManager(-1);
			}
	}
}
function RightButtonClick(myForm)
{
	if (document.images)
		{
			if (document["rightNavButton"].src != nextImage.src)
			{
				// Faster
				Interval -= 1000;
				if (Interval < 500)
				{
					Interval = 0;
				}
				window.clearTimeout(timePtr);
				timePtr = window.setTimeout("SwapManager(1)",Interval); 
			}
			else
			{
				// Next
				DirectionManager(1);
	
			}
	}
}
function SwapManager(j)
{
	if (document.images)
	{
		// this presupposes that the images always get swapped going in 1 direction
		DirectionManager(1);
	}
	if (j == 1)
	{
		timePtr = window.setTimeout("SwapManager(1)",Interval); 
	}
	else
	{
		window.clearTimeout(timePtr);

	}
}
function MakeAuto(myForm)
{
	if (document.images)
	{
		//document["leftNavButton"].src = "http://localhost/cbcvoices/mysite.030/globalgraphics/slower.gif";
		document["leftNavButton"].src = "http://j5services.netfirms.com/cbcvoices/globalgraphics/slower.gif";
		//document["rightNavButton"].src = "http://localhost/cbcvoices/mysite.030/globalgraphics/faster.gif";
		document["rightNavButton"].src = "http://j5services.netfirms.com/cbcvoices/globalgraphics/faster.gif";
		Interval=5000;
        	timePtr = window.setTimeout("SwapManager(1)",Interval); 
	}
}
function MakeManual(myForm)
{
	if (document.images)
	{
		document["leftNavButton"].src = previousImage.src;
		document["rightNavButton"].src = nextImage.src
		SwapManager(0);
	}
}

function SwabManager(noSwabImage)
{
	var manualButton, autoButton;
	if (document.images)
	{
				radioButtons = document.getElementsByName("navmethod");
				if (radioButtons[0].value == "manual")
				{
					manualButton = radioButtons[0];
					autoButton = radioButtons[1];
				} else if (radioButtons[1].value == "manual")
				{
					manualButton = radioButtons[1];
					autoButton = radioButtons[0];
			
				}
				window.clearTimeout(timePtr);
				if (manualButton.checked == 1)
				{
					// default to auto that is 
					// change selection back to Auto
					manualButton.checked = 0;
					autoButton.checked = 1;
				}
	}

	
}
function DirectionManager(direction)
{
	var text;
	SetTextOff(currentImage);
	if (direction == 1)
	{
		 //window.alert("Going Next");
		currentImage += 1;
	}
	else if (direction == -1)
	{
		//window.alert("Going Previous");
		currentImage -=1; 
	}
	if (currentImage > maxNext)
	{
		currentImage = maxPrevious;
	}
	else if (currentImage < maxPrevious)
	{
		currentImage = maxNext;
	}
//	window.alert("current image is " + currentImage);
	if (document.images)
	{
	SetTextOn(currentImage);
	document["galleryImage"].src =images[currentImage].src;	
	}
	
		
	

}


