var today	= new Date();
var day		= today.getDate();
var month	= today.getMonth();
var year	= today.getFullYear();

function easterDate() {

	var a = year % 19,
		b = parseInt(year / 100),
		c = year % 100,
		d = parseInt(b / 4),
		e = b % 4,
		f = parseInt((b + 8) / 25),
		g = parseInt((b - f + 1) / 3),
		h = (19*a + b - d - g + 15) % 30,
		i = parseInt(c / 4),
		k = c % 4,
		L = (32 + 2*e + 2*i - h - k) % 7,
		m = parseInt((a + 11*h + 22*L) / 451),
		q = h + L - 7*m + 114,
		n = parseInt(q / 31),
		p = q % 31;

	//document.write(p+1 + '/' + n);
	return new Date(year, n-1, p+1);
}

/*
function toEaster() {

	//var today = new Date();
	var easter = easterDate();

	return (Math.ceil((easter - today) / 86400000));
}*/

switch(month) {
	case 0:		// January
		autoupdate('<p>Happy New Year!</p>', 16, 1, year, '');
		break;

	case 8:		// September
		if (day <= 24) {
			countdown(24, 9, year, '<p>', ' days to my birthday!</p>',
			  ' day to my birthday!</p>',
			  '<p>' + (year - 1979)
			    + ' today.&nbsp; I&#8217;m growing old!</p>');
		}
		break;

	case 11:	// December
		countdown(25, 12, year, '<p>',
			' days to Christmas!</p>', ' day to Christmas!</p>',
			'<p>Merry Christmas!</p>');
		break;

	default:	// Easter
		var easter = easterDate();
		var toEaster = Math.ceil((easter - today) / 86400000);

		if(-7 < toEaster && toEaster <= 46) {
			cdbody(easter, '<p>',
			' days to Easter!</p>', ' day to Easter!</p>',
			'<p>Happy Easter!</p>', '<p>Happy Easter!</p>');
		}
}
