Code:
if (date.getDay() == 0 || date.getDay() == 6)
document.layers["idMenuContainer"].document.layers["idDate"+nDate].color = "red";
else
//......
That line determines whether the day is a saturday or a sunday. If it is, then it becomes red. You should be able to check if that date is a holiday like this:
Code:
if (date.getDay() == 0 || date.getDay() == 6 || isHoliday(date))
That will also check if the date is a holiday, if it's not a saturday or a sunday.
Now this means that you need to add a new Javascript function called "isHoliday()". The exact way that this will work depends on how you want to store your holidays, but here's a basic (non-working) example:
Code:
function isHoliday(date) {
if (date_is_in_list_of_holidays) {
return true;
}
else {
return false;
}
}
Does that help? Now if you want to fully implement this you'll need to decide how you will store the dates. An array (or object?) is probably best. You can store them in a format like this: "MM-DD" then use this: date.getMonth()+'-'+date.getDate() to find the equivalent string from the current date.
(Note that it's actually (M)M-(D)D because it would be 1-1 for January first, for example.)
So basically something like this:
Code:
function inArray(needle, haystack) {
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[i] == needle) return true;
}
return false;
}
function isHoliday(date) {
var holidays = new Array('1-1','11-27','12-25');
if (inArray(date.getMonth()+'-'+date.getDate(),holidays)) {
return true;
}
else {
return false;
}
}
Bookmarks