	function dateIsSpecial(year, month, day) {
	 	var oMonths = SPECIAL_DAYS[year];
	 	if (!oMonths) return false;
	 		 	
	 	var aDays = oMonths[month];
		if (!aDays) return false;
		for (var i in aDays) 
			if (aDays[i] == day) 
				return true;
		return false;
	};

	function ourDateStatusFunc(date, y, m, d) {
		if (dateIsSpecial(y, m, d))
			return "special";
		else
			return false; // other dates are enabled
		//return true;  //if you want to disable other dates
	};

	function fixMonth(m)
	{
		m++;
		if (m < 10)
			m = '0' + m;			
		return m;
	}
	
	function fixDay(d)
	{
		if (d < 10)
      		d = '0' + d;      	
      	return d;
	}

	function hideEvent( eventID )
	{
      	var menu = document.getElementById(eventID);
      	if (!menu)
      		return;
		var display = menu.style.display;
		menu.style.display = "none";		
	}

	function hideAllEvents()
	{
	 	for (var k=yearFROM; k<=yearTO; k++)
	 	{
		 	for (var i=0; i<12; i++)
		 	{
		 		var oMonths = SPECIAL_DAYS[k];
			 	if (!oMonths) continue;
	 	
				var eventDays = oMonths[i];
				if (!eventDays)	continue;
	
				//alert("eventDays: "+eventDays);										
				for (var j in eventDays)
				{
		 			eDay = fixDay(eventDays[j]);
					eMonth = fixMonth(i);
		 			
		 			var eventID = 'event_'+k+eMonth+eDay; 			
		 			//alert("Nascondo evento: "+eventID);
		 			hideEvent(eventID);
				}				
			}		
		}
	}
		
	function showEvent( eventID )
	{
      	var menu = document.getElementById(eventID);
      	if (!menu)
      		return;
		var display = menu.style.display;
		menu.style.display = "block";		
	}

	function dateChanged(calendar) {
		// Beware that this function is called even if the end-user only
		// changed the month/year.  In order to determine if a date was
		// clicked you can use the dateClicked property of the calendar:
		if (calendar.dateClicked) {
			// OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
			var y = calendar.date.getFullYear();
			var m = calendar.date.getMonth();     // integer, 0..11
			var d = calendar.date.getDate();      // integer, 1..31
			
			m = fixMonth(m);
			d = fixDay(d);
			  
			hideAllEvents();
			
			var eventID = 'event_'+y+m+d;			

			showEvent(eventID);		
		}
	};

	Calendar.setup(
		{
			flat         	: "calendar-container", // ID of the parent element
			flatCallback 	: dateChanged,           // our callback function
			dateStatusFunc 	: ourDateStatusFunc,
			weekNumbers 	: false,
			range			: [yearFROM,yearTO]
		}
	);
