$(document).ready(function()
{
	$('#dialog-events').dialog({
		modal:		true,
		draggable:	false,
		resizable:	false,
		autoOpen:	false,
		width:		550,
		height:		400,
		open:		function()
		{
			var dialog = $(this);
			dialog.load('calendar.php', { method: 'getEvents', date: dialog.data('date') });
		}
	});
});

function showajax( date )
{
	var	events	= $('#dialog-events');

	events.data('date', date);
	events.dialog('option', 'title', 'Events: ' + date);
	events.dialog('open');
}

function nav_back( Month, Year )
{
	var container = $('#calendar');

	if ( --Month <= 0 )
	{
		Month = 12;
		Year--;
	}

	container.load('calendar.php', { method: 'regenerate', month: Month, year: Year });
}

function nav_frwd( Month, Year )
{
	var container = $('#calendar');

	if ( ++Month > 12 )
	{
		Month = 1;
		Year++;
	}

	container.load('calendar.php', { method: 'regenerate', month: Month, year: Year });
}
