;(function($) {
$(document).ready(function() {
	
function getMonthEvents(day){
	//alert(day);
//alert(makeup(day));
	
  return {11: "<h2>This is my first Event</h2><br/><h2>This is my second Event</h2><br/>", 23: "My anniversary" } ;
}

// Receives January->1
function addTipsys(year, month, calendarId){


		if(typeof specialDays  != "undefined"){

   var theEvents = results;
   var theDateLinks = $('#' + calendarId + ' .ui-datepicker-calendar a');
   for(eventDay in theEvents){
      // Minus one, because the date in the tipies are regular dates (1-31)
      // and the links are 0-based.
      theDateLinks.eq(eventDay-1)  // select the right link
         .attr('original-title', theEvents[eventDay])  // set the text
         .tipsy();   // init the tipsy, set your properties.
   }
}
// Because the the event `onChangeMonthYear` get's called before updating 
// the items, we'll add our code after the elements get rebuilt. We will hook 
// to the `_updateDatepicker` method in the `Datepicker`.
// Saves the original function.
var _updateDatepicker_o = $.datepicker._updateDatepicker;
// Replaces the function.
$.datepicker._updateDatepicker = function(inst){ 
   // First we call the original function from the appropiate context.
   _updateDatepicker_o.apply(this, [inst]); 
   // No we can update the Tipsys.
   addTipsys(inst.drawYear, inst.drawMonth+1, inst.id);
};

// find the speical date:
	}
							
    
// Finally the calendar initializer.
$(function(){
   // Creates the date picker, with your options.
   $("#datepicker").datepicker(

   	{beforeShowDay: function(date) {
      var d = date.getDate(),
        m = date.getMonth()+1,
        y = date.getFullYear();

		if(typeof specialDays  != "undefined"){

     if (specialDays[y] && specialDays[y][m] && specialDays[y][m][d]) {
      var s = specialDays[y][m][d];

   return [true, s.className,]; // selectable

  }
	}
      return [true,'']; // non-selectable
    }}

   );
   // Gets the date and initializes the first round of tipsies.
   var currentDate = $('#datepicker').datepicker('getDate');
   // month+1 because the event considers January->1
   // Last element is null, because, it doesn't actualy get used in the hanlder.

   addTipsys(currentDate.getYear(), currentDate.getMonth()+1, 'datepicker');
});
})
})(jQuery);
