var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var holidays = [["1/1","#CCCC00","Happy New Year","New Year's Day","",0,0],["2/14","#F96CF9","Happy Valentine's Day","Valentine's Day","",0,0],["3/17","#38B549","Happy St. Patrick's Day","St. Patrick's Day","leprechaun.gif",2,3],["7/4","#E81B23","Happy 4th of July","US Independence Day","",2,3],["10/31","#FF7D1E","Happy Halloween","Halloween","jack.gif",5,3],["12/25","#109A13","Merry Christmas","Christmas Day","tree_big.gif",10,10]];

var eday = "";
var emonth = "";
var cdate = new Date();
var ctime = cdate.getTime();
var year = cdate.getFullYear();
var month = cdate.getMonth();
var day = cdate.getDate();
var weekday = cdate.getDay();
var monthname = months[month];
var holarray = [];
cdate.setDate(1);

function setImage() {

	holarray = holidays;
	getEaster();
	holarray[holarray.length] = [((emonth+1)+"/"+eday),"#9900FF","","Easter Sunday","egg.gif",3,1];
	
	cdate.setMonth(4);
	var md = ((1 + (7 - cdate.getDay())) + 7);
	if(md > 14) {
		md = (md - 7);
	}
	holarray[holarray.length] = [("5/"+md),"#D41D9E","","Mother's Day","",0,0];

	cdate.setMonth(5);
	var fd = ((1 + (7 - cdate.getDay())) + 14);
	if(fd > 21) {
		fd = (fd - 7);
	}
	holarray[holarray.length] = [("6/"+fd),"#005B7F","","Father's Day","",0,0];

	cdate.setMonth(10);
	var fth = (5 + (7 - cdate.getDay()));
	if(fth > 7) {
		fth = (fth - 7);
	}
	td = (fth + 21);
	holarray[holarray.length] = [("11/"+td),"#8E5116","Happy Thanksgiving","Thanksgiving","tom_big.gif",7,4];
	
	for(x=0;x<holarray.length;x++) {
		var hdate = (holarray[x])[0];
		var numdays = (holarray[x])[5];
		var hdsplit = hdate.split("/");
		var htime = ((new Date(year,(hdsplit[0]-1),(1*hdsplit[1]),8,0,0)).getTime());
		var ddiff = (htime - ctime)/(24*60*60*1000);
		if (ddiff < 0) {
			ddiff = (-1*ddiff);
			numdays = (holarray[x])[6];
		}
		if (ddiff < (numdays+1)) {
			var theid = "holimage";
			var thesrc = "";
			if ((holarray[x])[4] != "") thesrc = ("..\/Images\/" + (holarray[x])[4]);
			if (document.images && document.layers) {
				img.obj = document.images[theid];
			}
			else if (document.getElementById) {
				imgobj = document.getElementById(theid);
			}
			if (imgobj != null && thesrc != "") {
				imgobj.src = thesrc;
			}
		}
	}
}

function sortDays(d1,d2) {
	return d1-d2;
}

function getEaster() {
	a = year % 19;
	b = div(year, 100);
	c = (b - div(b, 4) - div(8 * b + 13, 25) + 19 * a + 15) % 30;
	d = c - div(c, 28) * (1 - div(c, 28) * div(29, c + 1) * div(21 - a, 11));
	e = (year + div(year, 4) + d + 2 - b + div(b, 4)) % 7;
	f = d - e + 28;
	eday = Math.round(f);
	if(eday > 31) {
		eday = (eday - 31);
		emonth = 3;
	}
	else {
		emonth = 2;
	}
}

function div(nu,di) {
	if(di == 0) {
		return null;
	}
	else {
		if (nu < 0) nu = -nu;
		if (di < 0) di = -di;
		res = ((nu - (nu % di)) / di);
		if(nu * di < 0 ) {
			res = -res;
		}
	return res;
	}
}