addLoadEvent(function(){
	(function($) {
		function rollover( src ) { return src.replace(/_off/,'_on'); }
		function rollout( src ) { return src.replace(/_on/,'_off'); }
		
		$('#printButtons, #btmArrows').find('img').hover(
			function(){ $(this).attr('src', rollover( $(this).attr('src') )); },
			function(){ $(this).attr('src', rollout( $(this).attr('src') ));
			}
		);		

		$(document.body)
			.append('<div id="calendarCallout"><div id="calendarCalloutPointy"><img src="/content/presentation/www/images/calCalloutPointy.gif" alt="" width="33" height="18" class="dBlock" /></div><img src="/content/presentation/www/images/calCalloutTop2.gif" alt="" width="348" height="10" class="dBlock" /><div id="calendarCalloutInner"></div><img src="/content/presentation/www/images/calCalloutBtm.gif" alt="" width="348" height="9" class="dBlock" /></div>');
		
		var calTimer;
		var CALLOUT;
		var DISAPPEARDELAY = 500;
		var DELAYHIDE, TIMER, LASTID, VISIBLE;
		
		$('#calendar .event a').bind('mouseover',function(){					
			if($(this).parents('td').find('.calCallout').length) {
				var that = $(this);
				clearTimeout(calTimer);
				calTimer = setTimeout(function(){
					var cal = $('#calendar');
					var callout = $('#calendarCallout');
					var pointy = $('#calendarCalloutPointy');
					var calOffset = cal.offset();
					var offset = that.offset(); 
					var lOffset = offset.left - 55;
					var pointyPadding = 55;
					if ( lOffset < calOffset.left ) 
					{
						lOffset = calOffset.left + 2;
						pointyPadding = 20;
					}
					else if ( (lOffset + callout.width()) > (calOffset.left + cal.width()) )
					{
						lOffset = calOffset.left + cal.width() - 350;
						pointyPadding = offset.left < 700 ? callout.width() - 245 : callout.width() - 115;
					}
					lOffset += "px";
					var tOffset = offset.top + that.height() + "px";
	
					$('#calendarCalloutInner').html(that.parents('td').find('.calCallout').html());
					pointy.css({'padding-left': pointyPadding + 'px'});
					callout.css({"left" : lOffset, "top" : tOffset}).show();
					VISIBLE  = true;
				
				}, 500);				
			}
		});
		$('#calendar .event a').bind('mouseout',function(){ 
			if (typeof calTimer != "undefined") clearTimeout(calTimer);
			
			if (VISIBLE) {
				DELAYHIDE=setTimeout(function() {
					$('#calendarCallout').hide();
				},DISAPPEARDELAY);
			}
			else {
				clearTimeout(calTimer);				
			}
			 
		});

		
		$('#calendarCallout').bind('mouseover',function(){
			if ( typeof DELAYHIDE != "undefined" ) clearTimeout(DELAYHIDE);		
		});
		$('#calendarCallout').bind('mouseout',function(){
			if (VISIBLE) {
				DELAYHIDE=setTimeout(function() {
					$('#calendarCallout').hide();
				},DISAPPEARDELAY);
			}
			else {
				clearTimeout(calTimer);				
			}		
		});
		

	})(jQuery);
});