var date, thisYear, thisMonth, thisDay, thisHour, thisTime, thisSeason, festival;

date = new Date();

thisYear = date.getFullYear();
thisMonth = date.getMonth() + 1;
thisDay = date.getDate();
thisHour = date.getHours();
festival = "";

//determine the season && the time of day
switch(thisMonth) {
case 12:
case 1:
case 2:
	thisSeason = "winter";
	if (thisHour >= 16 || thisHour < 8) {
		thisTime = "night";
	} else {
		thisTime = "day";
	}
	break;
case 3:
case 4:
case 5:
	thisSeason = "spring";
	if (thisHour >= 18 || thisHour < 7) {
		thisTime = "night";
	} else {
		thisTime = "day";
	}
	break;
case 6:
case 7:
case 8:
	thisSeason = "summer";
	if (thisHour >= 19 || thisHour < 6) {
		thisTime = "night";
	} else {
		thisTime = "day";
	}
	break;
case 9:
case 10:
case 11:
	thisSeason = "autumn";
	if (thisHour >= 20 || thisHour < 7) {
		thisTime = "night";
	} else {
		thisTime = "day";
	}
	break;
default:
	thisSeason = "summer";
	thisTime = "day";
}

//christmas and st davids day are the same every year 
if (thisDay == 1 && thisMonth == 3) {
	festival = "david";
}
//setting christmas period above other dates so hanukkah over-writes it
if ((thisDay >= 5 && thisMonth == 12) || (thisDay <= 2 && thisMonth == 1)) {
	festival = "christmas";
}

//determine the exact date to decide if (it is a special date to display a festival
switch(thisYear) {
case 2011:
	if (thisDay == 3 && thisMonth == 2) {
		festival = "chinesenewnear";
	} else if (thisDay == 19 && thisMonth == 3) {
		festival = "holi";
	} else if (thisDay == 17 && thisMonth == 3) {
		festival = "patrick";
	} else if (thisDay == 14 && thisMonth == 4) {
		festival = "vaisakhi";
	} else if ((thisDay == 24 || thisDay == 25) && thisMonth == 4) {
		festival = "easter";
	} else if (thisDay == 2 && thisMonth == 5) {
		festival = "george";
	} else if ((thisDay == 30 && thisMonth == 8) || (thisDay == 31 && thisMonth == 8) || (thisDay == 1 && thisMonth == 9)) {
		festival = "eidulfitr";
	} else if ((thisDay == 28 || thisDay == 29 || thisDay == 30) && thisMonth == 9) {
		festival = "roshhashanah";
	} else if (thisDay == 26 && thisMonth == 10) {
		festival = "diwali";
	} else if ((thisDay == 6 || thisDay == 7 || thisDay == 8) && thisMonth == 11) {
		festival = "eiduladha";
	} else if (thisDay == 30 && thisMonth == 11) {
		festival = "andrew";
	} else if (thisDay == 21 && thisMonth == 12) {
		festival = "hanukkah";
	}
	break;
	
case 2012:
	if (thisDay == 23 && thisMonth == 1) {
		festival = "chinesenewyear";
	} else if (thisDay == 8 && thisMonth == 3) {
		festival = "holi";
	} else if (thisDay == 19 && thisMonth == 3) {
		festival = "patrick";
	} else if (thisDay == 13 && thisMonth == 4) {
		festival = "vaisakhi";
	} else if ((thisDay == 8 || thisDay == 9) && thisMonth == 4) {
		festival = "easter";
	} else if (thisDay == 23 && thisMonth == 4) {
		festival = "george";
	} else if ((thisDay == 17 || thisDay == 18 || thisDay == 19) && thisMonth == 8) {
		festival = "eidulfitr";
	} else if ((thisDay == 16 || thisDay == 17 || thisDay == 18) && thisMonth == 9) {
		festival = "roshhashanah";
	} else if (thisDay == 13 && thisMonth == 11) {
		festival = "diwali";
	} else if ((thisDay == 25 || thisDay == 26 || thisDay == 27) && thisMonth == 10) {
		festival = "eiduladha";
	} else if (thisDay == 30 && thisMonth == 11) {
		festival = "andrew";
	} else if (thisDay == 9 && thisMonth == 12) {
		festival = "hanukkah";
	}
	break;
	
case 2013:
	if (thisDay == 10 && thisMonth == 2) {
		festival = "chinesenewyear";
	} else if (thisDay == 27 && thisMonth == 3) {
		festival = "holi";
	} else if (thisDay == 18 && thisMonth == 3) {
		festival = "patrick";
	} else if (thisDay == 14 && thisMonth == 4) {
		festival = "vaisakhi";
	} else if ((thisDay == 31 && thisMonth == 3) || (thisDay == 1 && thisMonth == 4)) {
		festival = "easter";
	} else if (thisDay == 23 && thisMonth == 4) {
		festival = "george";
	} else if ((thisDay == 7 || thisDay == 8 || thisDay == 9) && thisMonth == 8) {
		festival = "eidulfitr";
	} else if ((thisDay == 4 || thisDay == 5 || thisDay == 6) && thisMonth == 9) {
		festival = "roshhashanah";
	} else if (thisDay == 3 && thisMonth == 11) {
		festival = "diwali";
	} else if ((thisDay == 14 || thisDay == 15 || thisDay == 16) && thisMonth == 10) {
		festival = "eiduladha";
	} else if (thisDay == 28 && thisMonth == 11) {
		festival = "hanukkah";
	} else if (thisDay == 2 && thisMonth == 12) {
		festival = "andrew";
	}
	break;
	
case 2014:
	if (thisDay == 31 && thisMonth == 1) {
		festival = "chinesenewyear";
	} else if (thisDay == 18 && thisMonth == 3) {
		festival = "holi";
	} else if (thisDay == 17 && thisMonth == 3) {
		festival = "patrick";
	} else if (thisDay == 14 && thisMonth == 4) {
		festival = "vaisakhi";
	} else if ((thisDay == 20 || thisDay == 21) && thisMonth == 4) {
		festival = "easter";
	} else if (thisDay == 28 && thisMonth == 4) {
		festival = "george";
	} else if ((thisDay == 28 || thisDay == 29 || thisDay == 30) && thisMonth == 7) {
		festival = "eidulfitr";
	} else if ((thisDay == 24 || thisDay == 25 || thisDay == 26) && thisMonth == 9) {
		festival = "roshhashanah";
	} else if (thisDay == 23 && thisMonth == 10) {
		festival = "diwali";
	} else if ((thisDay == 4 || thisDay == 5 || thisDay == 6) && thisMonth == 10) {
		festival = "eiduladha";
	} else if (thisDay == 1 && thisMonth == 12) {
		festival = "andrew";
	} else if (thisDay == 17 && thisMonth == 12) {
		festival = "hanukkah";
	}
	break;
	
case 2015:
	if (thisDay == 19 && thisMonth == 2) {
		festival = "chinesenewyear";
	} else if (thisDay == 6 && thisMonth == 3) {
		festival = "holi";
	} else if (thisDay == 17 && thisMonth == 3) {
		festival = "patrick";
	} else if (thisDay == 14 && thisMonth == 4) {
		festival = "vaisakhi";
	} else if ((thisDay == 5 || thisDay == 6) && thisMonth == 4) {
		festival = "easter";
	} else if (thisDay == 23 && thisMonth == 4) {
		festival = "george";
	} else if ((thisDay == 17 || thisDay == 18 || thisDay == 19) && thisMonth == 7) {
		festival = "eidulfitr";
	} else if ((thisDay == 13 || thisDay == 14 || thisDay == 15) && thisMonth == 9) {
		festival = "roshhashanah";
	} else if (thisDay == 11 && thisMonth == 11) {
		festival = "diwali";
	} else if ((thisDay == 23 || thisDay == 24 || thisDay == 25) && thisMonth == 9) {
		festival = "eiduladha";
	} else if (thisDay == 30 && thisMonth == 11) {
		festival = "andrew";
	} else if (thisDay == 7 && thisMonth == 12) {
		festival = "hanukkah";
	}
	break;
}

//construct stylesheet string
if (festival != "") {
	festivalStyles = festival;
} else {
	festivalStyles = thisSeason + "_" + thisTime;
}

//write style sheet link
document.write('<link rel="stylesheet" type="text/css" href="../festivals/' + festivalStyles + '.css" />');

//alert("Date: " + date + " || This Year: " + thisYear + " || This Month: " + thisMonth + " || This Day: " + thisDay + " || This Hour: " + thisHour + " || This Time: " + thisTime + " || This Season: " + thisSeason + " || This Festival: " + festival);

