function calendar_list(page)
{
	if (!document.sending) {
		document.sending = true;
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/calendar_list.php",
			data: { p: page },
			success: function(response) {
				document.sending = false;
				$('#calendar_content_list').html(response);
			},
			error: function(obj, what_happen, other_obj) {
				document.sending = false;
			}
		});
	}
}
function calendar_month_update()
{
	if (!document.sending) {
		document.sending = true;
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/calendar_month_update.php",
			data: { year: $('#calendar_select_year').val(), month: $('#calendar_select_month').val() },
			success: function(response) {
				document.sending = false;
				$('#calendar_contenedor').html(response);
				// Actualizar titulo:
				$('#calendar_title_date').html(months_names[$('#calendar_select_month').val() - 1] + ' ' + $('#calendar_select_year').val());
			},
			error: function(obj, what_happen, other_obj) {
				document.sending = false;
			}
		});
	}
}

/* ****************** TOOLTIP ******************************************* */
function calendar_tooltip_show(date)
{
	if (!document.sending) {
		document.sending = true;
		calendar_tooltip_hide();
		config.Fix = ['cal_div_date_'+date, 20, -20]; // en wztooltip.js
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/calendar_tooltip.php",
			data: { date: date },
			success: function(response) {
				document.sending = false;
				$('#calendar_tooltip').html(response);
				TagToTip('calendar_tooltip');
			},
			error: function(obj, what_happen, other_obj) {
				document.sending = false;
				UnTip();
			}
		});
	}
}
function calendar_tooltip_hide()
{
	//$('#calendar_tooltip').html('');
	UnTip();
	calendario_div_actual = '';
}
/* ****************** END TOOLTIP ******************************************* */

/* ****************** HEADER MODULE ******************************************* */
var calendar_header_module_event_index = 0;
var calendar_header_module_total_events = 1;
var calendar_header_module_event_sending = false;
function calendar_header_module_event(direction)
{
	if (!calendar_header_module_event_sending)
	{
		calendar_header_module_event_sending = true;
		calendar_header_module_event_index += direction; // values of direction: -1=left, 1=right
		if (calendar_header_module_event_index < 0)
			calendar_header_module_event_index = calendar_header_module_total_events - 1;
		else if (calendar_header_module_event_index >= calendar_header_module_total_events)
			calendar_header_module_event_index = 0;
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/calendar_home_event.php",
			data: { index: calendar_header_module_event_index },
			success: function(response) {
				calendar_header_module_event_sending = false;
				$('#home_event').html(response);
				calendar_header_module_total_events = $('#calendar_header_module_total_events').val();
			},
			error: function(obj, what_happen, other_obj) {
				calendar_header_module_event_sending = false;
				//calendar_dates_collections = new Array();
			}
		});
	}
}
// Calendario de las pestañas del encabezado:
function calendar_home_header_update(date)
{
	if (!document.sending) {
		document.sending = true;
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/calendar_home_header_update_events.php",
			data: { date: date },
			success: function(response) {
				document.sending = false;
				$('#calendar_home_header_events').html(response);
			},
			error: function(obj, what_happen, other_obj) {
				document.sending = false;
			}
		});
	}
}
/* ****************** END HEADER MODULE ******************************************* */
