/*
	To add more closed days, add items to the list below using the pattern [month, day, year]
	Separate each item with a comma.
	Feel free to delete days in the past, as they will be disabled automatically anyway.
*/
var closedDays = [
	[3, 13, 2010],
	[3, 20, 2010],
	[3, 27, 2010],
	[4, 2, 2010],
	[4, 3, 2010],
	[5, 15, 2010],
	[5, 22, 2010],
	[5, 29, 2010],
	[5, 31, 2010],
	[9, 6, 2010],
	[11, 25, 2010],
	[11, 26, 2010],
	[12, 24, 2010],
	[12, 27, 2010],
	[12, 28, 2010],
	[12, 29, 2010],
	[12, 30, 2010],
	[12, 31, 2010],
	[1, 17, 2011],
	[5, 30, 2011],
	[7, 4, 2011]
	//The last item in the list can NOT have a trailing comma
]; 

var nonPresidentialFridays = [
	[2, 11, 2011],
	[2, 25, 2011],
	[3, 18, 2011],
	[4, 1, 2011]
	//The last item in the list can NOT have a trailing comma
];




/*--------------- Don't edit anything below here ---------------*/



jQuery(document).ready(function(){
	var blackoutDates = [];
	jQuery('#blackoutDates li').each(function() {
		blackoutDates.push(jQuery(this).text().split(", "))
	});
	console.log(blackoutDates);
	jQuery(".datepicker").datepicker({
		minDate: 0,		//disables dates in the past
		showOn: 'both',
		buttonImage: '/images/icons/datepicker.png',
		buttonImageOnly: true,
		buttonText: 'Choose a date',
		beforeShowDay: function(date) {
			var isClosed = false;
			if (blackoutDates != null) {
				for (i = 0; i < blackoutDates.length; i++) {
					if (date.getMonth() == blackoutDates[i][0] - 1 && date.getDate() == blackoutDates[i][1] && date.getFullYear() == blackoutDates[i][2]) {
						isClosed = true;
					}
				}
			}
			if (date.getDay() == 6) {  //closes all Saturdays
				isClosed = true;
			}
			if (date.getDay() == 0) {  //closes all Sundays
				isClosed = true;
			}
			if (isClosed) {
				return [false, 'closed', 'Closed'];  //disables all Closed Days
			}
			if (date.getMonth() < 3 && date.getFullYear() <= 2011) {  // no presidential tour dates after March 2011
				if (date.getDay() == 5) {  //checks all Fridays
					if (nonPresidentialFridays != null) {
						for (i = 0; i < nonPresidentialFridays.length; i++) {
							if (date.getMonth() == nonPresidentialFridays[i][0] - 1 && date.getDate() == nonPresidentialFridays[i][1] && date.getFullYear() == nonPresidentialFridays[i][2]) {
								return [true, '', ''];	//ignore if they are a regular tour day 
							}
						}
					}
					return [true, 'presidential', 'Presidential Tour Date'];		//highlight if they are a presidential tour day
				}
			};
			return [true, '', ''];
		}
	});
	jQuery("#birthDate").datepicker({
		showOn: 'both',
		buttonImage: '/images/icons/datepicker.png',
		buttonImageOnly: true,
		buttonText: 'Choose a date',
		changeMonth: true,
		changeYear: true,
		yearRange: '1910:2010'
	});
});

