

function styleLitColor()
{

	today = new Date();
	todayLitColor = getLitColor(today);
	document.writeln('<style>');
	document.writeln('<!--');

	if (todayLitColor == "#ffd700") {
		document.writeln('.litcolor { margin:30px 0px 0px;width:400px;height:1px;border-top:3px double ' + todayLitColor + ';}');
	}
	else {
		document.writeln('.litcolor { margin:30px 0px 0px;width:400px;height:1px;border-top:3px double ' + todayLitColor + ';}');
	}

	document.writeln('-->');
	document.writeln('</style>');

}

function getLitColor(today)
{
	jToday = cnv2JulianDate(today);
	mToday = today.getMonth();

	if (mToday == 0) {
		lColor = janColor(today,jToday);
	}
	else if ((mToday >= 6) && (mToday <= 9)) {
		lColor = "#3cb371";
	}
	else if (mToday >= 10) {
		lColor = adventColor(today,jToday);
	}
	else {
		lColor = easterColor(today,jToday);
	}

	return lColor;

}

function janColor(today,jToday) {

	Jan7 = new Date();
        Jan7.setMonth(0);
	Jan7.setDate(7);
	Jan7.setYear(today.getFullYear());

	if (today.getTime() < Jan7.getTime()) {
		return "#ffd700";
	}
	nextSunday = cnv2JulianDate(Jan7);
	if (Jan7.getDay() > 0) {
		nextSunday += (7 - Jan7.getDay());
	}

	if (jToday == nextSunday) {
		return "#ffd700";
	}
	else {
		return "#3cb371";
	}

}

function adventColor(today,jToday) {

	if ((today.getDate() == 1) && (today.getMonth() == 10)) {
		return "#ffd700";
	}
	firstAdvent = getFirstAdvent(today);

	if (jToday == (firstAdvent - 7)) {
		return "#ffd700";
	}
	if (jToday < firstAdvent) {
		return "#3cb371";
	}
	Dec24 = new Date();
        Dec24.setMonth(11);
	Dec24.setDate(24);
	Dec24.setYear(today.getFullYear());

	if (today.getTime() > Dec24.getTime()) {
		return "#ffd700";
	}
	return "#ba55d3";

}

function easterColor(today,jToday) {

	Easter = getEaster(today.getFullYear());

	if (jToday == (Easter - 7)) {
		return "red"
	}
	else if (jToday == (Easter - 49)) {
		return "#ffd700"
	}

	AshWednesday = Easter - 46;
	if (jToday < AshWednesday) {
		return "#3cb371"
	}
	else if (jToday <= (Easter - 3)) {
		return "#ba55d3"
	}

	Pentecost = Easter + 49;
	if ((jToday >= Pentecost) && (jToday <= (Pentecost + 6))) {
		return "red";
	}
	else if (jToday > (Pentecost + 7)) {
		return "#3cb371";
	}
	return "#ffd700";

}

function cnv2JulianDate(d) {

	if (Math.floor(d.getFullYear() % 4) > 0) {
		var numDayz = new Array(0,31,59,90,120,151,181,212,243,273,304,334);
	}
	else {
		var numDayz = new Array(0,31,60,91,121,152,182,213,244,274,305,335);
	}

	jd = Math.round(numDayz[d.getMonth()]) + Math.round(d.getDate());
	return jd;

}

function getFirstAdvent(d) {

	Dec25 = new Date();
        Dec25.setMonth(11);
	Dec25.setDate(25);
	Dec25.setYear(today.getFullYear());

	advent1st = cnv2JulianDate(Dec25);
	if (Dec25.getDay() > 0) {
		advent1st -= (21 + Dec25.getDay());
	}
	return advent1st;

}

function getEaster(year) {

	a = Math.round(year%19);
	b = Math.floor(year/100);
	c = Math.round(year%100);
	d = Math.floor(b/4);
	e = Math.round(b%4);
	f = Math.floor((b+8)/25);
	g = Math.floor((b-f+1)/3);
	h = Math.round((19*a+b-d-g+15)%30);
	i = Math.floor(c/4);
	k = Math.round(c%4);
	l = Math.round((32+2*e+2*i-h-k)%7);
	m = Math.floor((a+11*h+22*l)/451);
	easterMonth = Math.floor((h+l-7*m+114)/31);
	p = Math.round((h+l-7*m+114)%31);
	easterDate = p+1;

	easter = new Date();
        easter.setMonth(easterMonth-1);
	easter.setDate(easterDate);
        easter.setYear(year);

	jEaster = cnv2JulianDate(easter);

	return jEaster;
}
