$(document).ready(function() {

	$('a.confirmdelete').click(function(){
		return confirm('Are you sure you want to delete?');
	});

	$('a.confirmhide').click(function(){
		return confirm('Are you sure you want to hide?');
	});
	
});

function build_calendar()
{
	$.ajax({
		url: "/calendar-dates.php",
		data: "action=showdates",
		dataType: "json",
		cache: false,
		error: function(xh, error, errThrown) { console.log(error); },
		success: function(calendarEvents){
			$("#events-calendar").datepicker({
				// [rows, columns] if you want to display multiple calendars.
				numberOfMonths: [1, 1],
				showCurrentAtPos: 0,
				dayNamesMin: ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'],
				beforeShowDay: function (date){
					//change the date into ISO format
					var thisDate = date.getFullYear() + '-' + (parseInt(date.getMonth()) + 1) + '-' + date.getDate();
					for (i = 0; i < calendarEvents.length; i++) {
						if (thisDate == calendarEvents[i]) {
							//[disable/enable, class for styling appearance, tool tip]
							return [true,"","Event Name"]; //ui-state-active
						}
					}
					return [false, ""];//disable all other days
				},
				onSelect: function(dateText, inst){
					get_calendar_info(dateText);
				}
			});
		}
	});
}

function get_calendar_info(dateText)
{
	$.ajax({
		url: "/calendar-dates.php",
		data: "action=getcalendarinfo&date=" + dateText,
		dataType: "html",
		cache: false,
		error: function(xh, error, errThrown) { console.log(error); },
		success: function(data, status){
			$("div#events-info").html(data);
		}
	});
}

