
// This program displays a text in the  From the Bible  page.
// Texts are for Year B and, from Advent, Year C.


function seteaster()
{
	// You must set date and month of Easter before use, currently 2012.
	
	easter = new Date;	// 
	easter.setMonth(3);	// 2 = March, 3 = April
	easter.setDate(8);
	return easter;
}



function setepiphany()
{
	epiphany = new Date;
	epiphany.setMonth (0);
	epiphany.setDate (6);
	return epiphany;
}


function setnextepiphany()
{
	nextepiphany = new Date;
	var yr = nextepiphany.getYear();
	var yr = ++yr; // year = next year
	nextepiphany.setYear (yr);
	nextepiphany.setMonth(0);
	nextepiphany.setDate (6);
	return nextepiphany;
}


function setepiphany1(epiphany)
{
	epiphany1 = new Date;
	epiphany1.setMonth(0);
	var dy = epiphany.getDay();
	var dt = epiphany.getDate();
	dy = 7 - dy;
	dt = dy + dt;
	epiphany1.setDate(dt);
	return epiphany1;
}


function setchristtheking()
{
	var christtheking = new Date;
	var nov20 = new Date;
	nov20.setMonth (10);
	nov20.setDate (20);
	christtheking = nextsunday(nov20);
	return christtheking;
}





function setchristmasday()
{
	var christmasday = new Date;
	christmasday.setMonth (11);
	christmasday.setDate (25);
	return christmasday;
}





function setnameofjesus()
{
	var nameofjesus = new Date;
	nameofjesus.setMonth (0);
	nameofjesus.setDate (1);
	return nameofjesus;
}



function setnextnameofjesus()
{
	var nextnameofjesus = new Date;
	var yr = nextnameofjesus.getYear();
	var yr = ++yr; // year = next year
	nextnameofjesus.setYear  (yr);
	nextnameofjesus.setMonth  (0);
	nextnameofjesus.setDate  (1);
	return nextnameofjesus;
}



function oneweek()
{
	var week = 7*24*60*60*1000;
	return week;
}



function nextsunday(adate)
{
  	var dy = adate.getDay();
	var dt = adate.getDate();
	var sunday1 = new Date;
	sunday1.setMonth(adate.getMonth());
	sunday1.setDate(adate.getDate());
	if (dy != 0)
	{
		dy = 7 - dy;
		dt = dy + dt;
		sunday1.setDate(dt);
	}
	return sunday1;
}




function select_quotation(nameofjesus, epiphany, easter, christmasday, nextnameofjesus, nextepiphany)
{
	var quotation;

	if (sunday.current.getTime() == nameofjesus.getTime() )num = 1;
	else if (sunday.current.getTime() < epiphany.getTime() )num = 2;
	else if (sunday.current.getTime() == epiphany.getTime() )num = 3;
	else if (sunday.current.getTime() > epiphany.getTime() && sunday.current.getTime() < easter.getTime() - 7*oneweek() )num = 4;
	else if (sunday.current.getTime() >= easter.getTime() - 7*oneweek() && sunday.current.getTime() <= easter.getTime() + 8*oneweek() )num = 5;
	else if (sunday.current.getTime() > easter.getTime() + 8*oneweek() && sunday.current.getTime() < christmasday.getTime() ) num=6;
	else if (sunday.current.getTime() == christmasday.getTime() ) num = 7;
	else if (sunday.current.getTime() > christmasday.getTime() && sunday.current.getTime() <= nextnameofjesus.getTime() ) num = 8;
	else if (sunday.current.getTime() > nextnameofjesus.getTime() && sunday.current.getTime() < nextepiphany.getTime() ) num = 9;
	else if (sunday.current.getTime() == nextepiphany.getTime() ) num = 10;
	else if (sunday.current.getTime() > nextepiphany.getTime() ) num = 11;



	switch(num)
	{
		//"Name of Jesus" 
		case 1 : quotation = christmas[1];
		break;
		// "Between Name of Jesus and Epiphany"
		case 2: quotation = christmas[2];
		break;
		// "Epiphany"
		case 3: quotation = christmas[3];
		break;
		// "Between Epiphany and Sunday before Lent")
		case 4: quotation = proper[sunday.afterepiphany];
 		break;
		// "Sunday before Lent to Trinity"
		case 5: quotation = moveable[sunday.aftereaster + 7];
		break;
		// "Sunday after Trinity to 4th in Advent"
		case 6: quotation = proper[sunday.afterchristtheking + 34];
		break;
		// "Christmas Day"
		case 7: quotation = christmas[0];
		break;
		// "After Christmas to Naming of Jesus next year"
		case 8: quotation = christmas[1];
		break;
		// "Next year after Naming of Jesus but before Epiphany"
		case 9: quotation = christmas[2];
		break;
		// "Epiphany next year"
		case 10: quotation = christmas[3];
		break;
		// "Next year after Epiphany"
		case 11: quotation = proper[sunday.afterepiphany];
		break;
		default : alert ("This is default.");
	}
	return quotation;
}




function create_sunday_object(today, epiphany1, easter, christtheking)
{
	sunday = new Object;
	sunday.current = nextsunday(today);
	sunday.aftereaster = Math.round( ( sunday.current.getTime() - easter.getTime() )/oneweek() );
	sunday.afterepiphany = Math.round( ( sunday.current.getTime() - epiphany1.getTime() )/oneweek() + 1 );
	sunday.afterchristtheking = Math.round( ( sunday.current.getTime() - christtheking.getTime() )/oneweek() );
}




function settings()
{
	var today = new Date();
	var nameofjesus = setnameofjesus();
	var epiphany = setepiphany();
	var epiphany1 = setepiphany1(epiphany);
	var easter = seteaster();
	var christtheking = setchristtheking();
	var christmasday = setchristmasday();
	var nextnameofjesus = setnextnameofjesus();
	var nextepiphany = setnextepiphany();
	var quotation;
	create_sunday_object(today, epiphany1, easter, christtheking);
//	document.forms.form1.inword.value = today;
//	document.forms.form1.outword1.value = sunday.current;
//	document.forms.form1.outword1a.value = nameofjesus;
//	document.forms.form1.outword2.value = epiphany1;
//	document.forms.form1.outword3.value = easter;
//	document.forms.form1.outword4.value = christtheking;
//	document.forms.form1.outword5.value = sunday.afterepiphany;
//	document.forms.form1.outword6.value = sunday.aftereaster;
//	document.forms.form1.outword7.value = sunday.afterchristtheking;
//	document.forms.form1.outword8.value = christmasday;
//	document.forms.form1.outword9.value = nextnameofjesus;
//	document.forms.form1.outword10.value = nextepiphany;
	quotation = select_quotation(nameofjesus, epiphany, easter, christmasday, nextnameofjesus, nextepiphany);
	return quotation;
}



function versespeaker()
{
	var quotation;
	christmas=new Array();
	proper=new Array();
	moveable=new Array();
	christmas[2]="John said ..."   // Christmas 2
	christmas[3]="Herod said ..."  // Epiphany
	proper[1]="John the Baptist said ..." // Proper 1
	proper[2]="Jesus said ..." // Proper 2
	proper[3]="Jesus said ..." // Proper 3
	proper[4]="Jesus said ..." // Proper 4
	proper[5]="Jesus said ..." // Proper 5
	proper[6]="Jesus said ..." // Proper 6
	proper[7]="Jesus said ..." // Proper 7
	proper[8]="Jesus said ..." // Proper 8
	proper[9]="Jesus said ..." // Proper 9
	moveable[0]="Jesus said ..." // Sunday before Lent
	moveable[1]="Jesus said ..." // 1 Lent
	moveable[2]="Jesus said ..." // 2 Lent
	moveable[3]="Jesus said ..." // 3 Lent
	moveable[4]="Jesus said ..." // 4 Lent
	moveable[5]="Jesus said ..." // 5 Lent
	moveable[6]="Jesus said ..." // 6 Lent
	moveable[7]="Jesus said ..." // Easter
	moveable[8]="Jesus said ..." // 2 Easter
	moveable[9]="Jesus said ..." // 3 Easter
	moveable[10]="Jesus said ..." // 4 Easter
	moveable[11]="Jesus said ..." // 5 Easter
	moveable[12]="Jesus said ..." // 6 Easter
	moveable[13]="Jesus said ..." // 7 Easter
	moveable[14]="Jesus said ..." // Pentecost
	moveable[15]="Jesus said ..." // Trinity
	proper[10]="Jesus said ..." // Proper 10
	proper[11]="Jesus said ..." // Proper 11
	proper[12]="Jesus said ..." // Proper 12
	proper[13]="Jesus said ..." // Proper 13
	proper[14]="Jesus said ..." // Proper 14
	proper[15]="Herod said ..." // Proper 15
	proper[16]="Jesus said ..." // Proper 16
	proper[17]="Jesus said ..." // Proper 17
	proper[18]="Jesus said ..." // Proper 18
	proper[19]="Jesus said ..." // Proper 19
	proper[20]="Jesus said ..." // Proper 20
	proper[21]="Jesus said ..." // Proper 21
	proper[22]="Jesus said ..." // Proper 22
	proper[23]="Jesus said ..." // Proper 23
	proper[24]="Jesus said ..." // Proper 24
	proper[25]="Jesus said ..." // Proper 25
	proper[26]="Jesus said ..." // Proper 26
	proper[27]="Jesus said ..." // Proper 27
	proper[28]="Jesus said ..." // Proper 28
	proper[29]="Jesus said ..." // Proper 29
	proper[30]="Jesus said ..." // Proper 30
	proper[31]="Jesus said ..." // Proper 31
	proper[32]="Jesus said ..." // Proper 32
	proper[33]="Jesus said ..." // Proper 33
	proper[34]="Jesus said ..." // Proper 34
	proper[35]="Jesus said ..."            // 1 Advent
	proper[36]="John the Baptist said ..." // 2 Advent
	proper[37]="John the Baptist said ..." // 3 Advent
	proper[38]="Elizabeth said ..."        // 4 Advent
	christmas[0]="An angel said ..."       // Christmas
	christmas[1]="Jesus said ..."          // Christmas 1

	quotation = settings();
	document.write(quotation);
}
	

function verses()
{
	var quotation;
	christmas=new Array();
	proper=new Array();
	moveable=new Array();
	christmas[2]="This is the one I was talking about ... " // Christmas 2
// Epiphany
	christmas[3]="When you find him, let me know, so that I too may go and worship him." // Epiphany
	proper[1]="Turn away from your sins and be baptised." // Proper 1
	proper[2]="Come with me." // Proper 2
	proper[3]="Turn away from your sins and believe the good news." // Proper 3
	proper[4]="Be quiet and come out of the man." // Proper 4
	proper[5]="We must go to other villages round here." // Proper 5
	proper[6]="Be clean." // Proper 6
	proper[7]="Get up, pick up your mat, and go home\!" // Proper 7
	proper[8]="People who are well do not need a doctor, but only those who are sick." // Proper 8
	proper[9]="The Sabbath was made for the good of man\; man was not made for the Sabbath." // Proper 9
	moveable[0]="Don\'t tell anyone what you have seen, until the Son of Man has risen from death." // Sunday before Lent
// Lent
	moveable[1]="Turn away from your sins and believe the Good News." // 1 Lent
	moveable[2]="Get away from me Satan." // 2 Lent
	moveable[3]="Tear down this temple, and in three days I will build it again." // 3 Lent
	moveable[4]="Whoever does what is true comes to the light in order that the light may show that what he did was in obedience to God." // 4 Lent
	moveable[5]="Whoever loves his own life will loose it." // 5 Lent
	moveable[6]="My God, my God, why did you abandon me\?" // 6 Lent
// Easter
	moveable[7]="Woman, why are you crying\? Who is it that you are looking for\?" // Easter
	moveable[8]="Peace be with you." // 2 Easter
	moveable[9]="Why are you alarmed\? Why are these doubts coming up in your minds\?" // 3 Easter
	moveable[10]="I am the good shepherd, who is willing to die for the sheep." // 4 Easter
	moveable[11]="I am the real vine, and my father is the gardener." // 5 Easter
	moveable[12]="I love you just as the father loves me\; remain in my love." // 6 Easter
// Ascension
	moveable[13]="Holy Father\! Keep them safe by the power of your name, the name you gave me, so that they may be one just as you and I are one." // 7 Easter
// Pentecost
	moveable[14]="The Helper will come \- the Spirit, who reveals the truth about God and who comes from the Father." // Pentecost
// Trinity
	moveable[15]="For God loved the World so much that he gave his only Son, so that everyone who believes in him may not die but have eternal life." // Trinity
	proper[10]="How can Satan drive out Satan\?" // Proper 10
	proper[11]="What shall we say the Kingdom of God is like\?" // Proper 11
	proper[12]="Be still." // Proper 12
	proper[13]="Do not be afraid, only believe." // Proper 13
	proper[14]="A prophet is respected everywhere except in his own home town and by his relatives and his family." // Proper 14
	proper[15]="What would you like to have\?" // Proper 15
	proper[16]="Let\'s go off by ourselves to some place where we will be alone and you can rest for a while." // Proper 16
	proper[17]="Where can we find enough food to feed all these people\?" // Proper 17
	proper[18]="I am the bread of life." // Proper 18
	proper[19]="I am the living bread that came down from heaven." // Proper 19
	proper[20]="Whoever eats my flesh and drinks my blood has eternal life and I will raise him to life on the last day." // Proper 20
	proper[21]="What gives life is God\'s Spirit; man\'s power is no use at all." // Proper 21
	proper[22]="Listen to me, all of you, and understand." // Proper 22
	proper[23]="Let us first feed the children." // Proper 23
	proper[24]="Do not tell anyone about me." // Proper 24
	proper[25]="Whoever wants to be first must place himself last of all and be the servant of all." // Proper 25
	proper[26]="Salt is good; but if it loses its saltiness, how can you make it salty again\?" // Proper 26
	proper[27]="Let the children come to me, and do not stop them, because the Kingdom of God belongs to such as these." // Proper 27
	proper[28]="It is much harder for a rich person to enter the Kingdom of God than for a camel to go through the eye of a needle." // Proper 28
	proper[29]="For even the Son of Man did not come to be served; he came to serve and to give his life to redeem many people." // Proper 29
	proper[30]="What do you want me to do for you\?" // Proper 30
	proper[31]="The most important commandment is this: \'Listen Israel\! The Lord our God is the only Lord. ...\'. The second most important commandment is this: \'Love your neighbour as you love yourself.\'" // Proper 31
	proper[32]="They take advantage of widows and rob them of their homes, and then make a show of saying long prayers." // Proper 32
	proper[33]="You see these great buildings\? Not a single stone here will be left in its place; every one ot them will be thrown down." // Proper 33
	proper[34]="You say that I am a king." // Proper 34
// Start of Year C Advent
	proper[35]="Heaven and Earth will pass away, but my words will never pass away." // 1 Advent
	proper[36]="Turn away from your sins and be baptized." // 2 Advent
	proper[37]="I baptize you with water, but someone is coming who is much greater than I am. ... He will baptize you with the Holy Spirit and fire." // 3 Advent
	proper[38]="You are the most blessed of all women, and blessed is the child you will bear." // 4 Advent
// Christmas Season
	christmas[0]="Don\'t be afraid\! I am here with good news for you, which will bring great joy to all people." // Christmas
	christmas[1]="Why did you have to look for me?" // Christmas 1
	
	quotation = settings();
	document.write("\""+quotation+"\"");
}

function verselocation()
{
	var quotation;
	christmas=new Array();
	proper=new Array();
	moveable=new Array();
	christmas[2]="John 1:15 GNB" // Christmas 2
	christmas[3]="Matthew 1:8 GNB" // Epiphany
	proper[1]="Mk 1.4 GNB"    // Proper 1
	proper[2]="Jn 1.43 GNB"   // Proper 2
	proper[3]="Mark 1:15 GNB" // Proper 3
	proper[4]="Mark 1:25 GNB" // Proper 4
	proper[5]="Mark 1:38 GNB" // Proper 5
	proper[6]="Mark 1:41 GNB" // Proper 6
	proper[7]="Mark 1:11 GNB" // Proper 7
	proper[8]="Mark 2:17 GNB" // Proper 8
	proper[9]="Mark 2:27 GNB" // Proper 9
	moveable[0]="Mark 9:9 GNB"  // Sunday before Lent
	moveable[1]="Mark 1:15 GNB" // 1 Lent
	moveable[2]="Mark 8:33 GNB" // 2 Lent
	moveable[3]="John 2:19 GNB" // 3 Lent
	moveable[4]="John 3:21 GNB" // 4 Lent
	moveable[5]="John 12:25 GNB" // 5 Lent
	moveable[6]="Mark 15:34 GNB" // 6 Lent
	moveable[7]="John 20:15 GNB" // Easter
	moveable[8]="John 20:19 GNB" // 2 Easter
	moveable[9]="Luke 24:38 GNB" // 3 Easter
	moveable[10]="John 10:11 GNB" // 4 Easter
	moveable[11]="John 15:1 GNB"  // 5 Easter
	moveable[12]="John 15:9 GNB"  // 6 Easter
	moveable[13]="John 17:11 GNB" // 7 Easter
	moveable[14]="John 15:26 GNB" // Pentecost
	moveable[15]="John 3:16 GNB"  // Trinty
	proper[10]="Mark 3:23 GNB"  // Proper 10
	proper[11]="Mark 4:30 GNB" // Proper 11
	proper[12]="Mark 4:39 GNB" // Proper 12
	proper[13]="Mark 5:36 GNB" // Proper 13
	proper[14]="Mark 6:4 GNB" // Proper 14
	proper[15]="Mark 6:22 GNB" // Proper 15
	proper[16]="Mark 6:31 GNB" // Proper 16
	proper[17]="John 6:5 GNB" // Proper 17
	proper[18]="John 6:35 GNB" // Proper 18
	proper[19]="John 6:51 GNB" // Proper 19
	proper[20]="John 6:54 GNB" // Proper 20
	proper[21]="John 6:63 GNB" // Proper 21
	proper[22]="Mark 7:14 GNB" // Proper 22
	proper[23]="Mark 7:27 GNB" // Proper 23
	proper[24]="Mark 8:30 GNB" // Proper 24
	proper[25]="Mark 9:35 GNB" // Proper 25
	proper[26]="Mark 9:50 GNB" // Proper 26
	proper[27]="Mark 10:14 GNB" // Proper 26
	proper[28]="Mark 10:25 GNB" // Proper 28
	proper[29]="Mark 10:45 GNB" // Proper 29
	proper[30]="Mark 10:51 GNB" // Proper 30
	proper[31]="Mark 12:29 GNB" // Proper 31
	proper[32]="Mark 12:40 GNB" // Proper 32
	proper[33]="Mark 13:2 GNB" // Proper 33
	proper[34]="John 18:37 GNB" // Proper 34
// Start of Year C Advent
	proper[35]="Luke 22:33 GNB" // 1 Advent
	proper[36]="Luke 3:3 GNB"   // 2 Advent
	proper[37]="Luke 3:16 GNB"  // 3 Advent
	proper[38]="Luke 1:42 GNB"  // 4 Advent
// Christmas Season
	christmas[0]="Luke 2:10 GNB"     // Christmas
	christmas[1]="Luke 2:49 GNB"     // Christmas 1
	
	quotation = settings();
	document.write(quotation);
}



