/* Event calendar loader
 * 
 */
Portalfw.EventCalendar = {
	
	debug: false,
	
	// get gallery data via ajax
	getCalendarAjax: function (year, month) {
		$.ajax({
			data: {
				action: "get_events_for_month",
				year: year,
				month: month
			},
			url: '/event_calendar_ajax/',
			dataType: "json",
			type: "POST",
			cache: false,
			timeout: 10000,
			success: function(data, textStatus, XMLHttpRequest) {
				if ( Portalfw.EventCalendar.debug ) {
					console.log('EventCalendar data recieved:');
					console.log(data);
				}
				
				Portalfw.EventCalendar.changeCalendar(data);
			},
			error: function(data, textStatus, XMLHttpRequest) {
				if ( Portalfw.EventCalendar.debug ) {
					console.log('EventCalendar data recieving failed: ' + textStatus);
				}
				return;
			}
		});
	},
	
	
	// change calendar innerHtml
	changeCalendar: function (data) {
		if ( Portalfw.EventCalendar.debug ) {
			console.log('Inserting calendar HTML code...');
		}

		$('div.event_calendar_outer').html(data.html);

		if ( Portalfw.EventCalendar.debug ) {
			console.log('Calendar loaded.');
		}
	}
};

