$(function () {
	$('.date_has_event').each(function () {
		var distance = 10;
		var time = 250;
		var hideDelay = 5000;


		var trigger = $(this);
		var popup = $('.events ul', this).css('opacity', 0);
		var day = $('.day', this);
		var close = $('.close',popup)
		
		$([trigger.get(0), popup.get(0)]).click(function () {
				//close other tooltips
				$('.events ul').css('display', 'none');
				popup.css({
					top:  0,
					left: -60,
					display: 'block'
				})
				.animate({
					left: '+=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
				});
		});
		$(day).hover( function(){
						$(this).css('cursor','pointer');
					},function(){
						$(this).css('cursor','default');
		});
		$(close).click(function () {
				popup.animate({
					left: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					popup.css('display', 'none');
				});
		}).hover(function(){
					$(this).css('cursor','pointer');
				},function(){
					$(this).css('cursor','default');
		});
	});
	$('.prevMonth,.nextMonth').hover( function(){
			$(this).css('cursor','pointer');
		},function(){
			$(this).css('cursor','default');
	});
});
