var microCalendar = {
	update : function(mc_month, mc_year, any_all) {
		if(typeof mc_month == 'undefined') {
		  var mc_month = document.getElementById('microCalendarMonth').firstChild.data;
		}
		if(typeof mc_year == 'undefined') {
		  var mc_year = document.getElementById('microCalendarYear').firstChild.data;
		}
		if(typeof any_all == 'undefined') {
			var any_all = document.getElementById('microCalendarAnyAll').firstChild.data;
		}
		var category_selector = document.getElementById('eventType');
		var events_target = document.getElementById('microCalendarEventsTarget').firstChild.data;
		var url = MODULES_URL + '/events/controllers/microCalendar.php';
		var params = 'month=' + mc_month + '&year=' + mc_year;
		this.get_categories();
		if (this.categories && this.categories.length > 0) {
		  params += '&cats=' + this.categoriesString;
		}
		params += '&any_all=' + any_all;
		params += '&cat_select=';
		if (category_selector) {
			params += '1';
		} else {
			params += '0';
		}
		params += '&events_target=' + events_target;
		base_ajax('microCalendarData', url, params);
	},
	update_categories : function(podID) {
	  this.get_categories();
		var newCookie = 'eventcategories_'+podID+'='+this.categoriesString+';';
		document.cookie = newCookie;
		this.update();
	},
	get_categories : function() {
		var selectList = document.getElementById('MSL_typeselectSelect');
		this.categories = [];
		this.categoriesString = '';
		var glue = '';
		if ($defined(selectList)) {
			for (var i = 0; i < selectList.options.length; i++) {
				if (selectList.options[i].selected) {
					this.categoriesString += (glue + selectList.options[i].value);
					glue = ',';
					this.categories.push(selectList.options[i].value);
				}
			}
		}
	}
}

