/**
 *
 * JQuery for calendar
 *
 */
 
$(document).ready(function(){
	
	var tipday;
	var linkday;
	
	$('.tooltip').each(
		function() {
			// extract the only number from the class which is the tip day matching the tipjar ID
			tipday = $(this).attr('class').replace(/[^0-9]/g, '');
			// append the tipday to the tipjar with the same id
			$('#tipjar-'+tipday).append($('.tipday-'+tipday));
		});
		
	// show tooltips on hover of days with events
	$('#calendar td.event-day').hover(function(){
			// get the td day id so matchng tooltip list can be shown
			tipday = $(this).attr('id').replace(/[^0-9]/g, '');
			$('#tipjar-'+tipday).fadeIn(100);
		}, function() {
			$('#tipjar-'+tipday).fadeOut(100);
		});
		
	$('a.event-link').each(
		function() {
			// extract the only number from the class which is the tip day matching the tipjar ID
			linkday = $(this).attr('class').replace(/[^0-9]/g, '');
			// append the linkday to the tipjar with the same id
			$('td#day-'+linkday+' .day-content').append($('.link-day-'+linkday));
		});
			
});
