﻿
function SetupEventCalendar(eventCalendarID) 
{
	// get the width of the calendar date cells
	calendarCellWidth = $j("#" + eventCalendarID + " tbody td").width();
	
	// get the height of the display date divs
	displayDateHeight = $j("#" + eventCalendarID + " tbody td div.display_date").innerHeight();
	
	// get the height of the edit controls
	editControlsHeight = $j("#" + eventCalendarID + " tbody td div.edit_controls").innerHeight();
	editControlsHeight = editControlsHeight ? editControlsHeight : 0; // default to "0" if height is "null"
		
	// get the padding on the event info anchor
	eventInfoAnchorMarginTop = $j("#" + eventCalendarID + " tbody td div.event_info a").css("margin-top");
	eventInfoAnchorMarginLeft = $j("#" + eventCalendarID + " tbody td div.event_info a").css("margin-left");
	
	// remove the "px" characters
	eventInfoAnchorMarginTop = eventInfoAnchorMarginTop ? eventInfoAnchorMarginTop.replace("px", "") : "0";
	eventInfoAnchorMarginLeft = eventInfoAnchorMarginLeft ? eventInfoAnchorMarginLeft.replace("px", "") : "0";
	
	// setup the width and height for the date container
	dateWidth = calendarCellWidth;
	dateHeight = calendarCellWidth;

	// setup the width and height of the event info container (overflow is hidden to prevent event info from changing calendar date cell width or height)
	eventInfoWidth = dateWidth - eventInfoAnchorMarginLeft;
	eventInfoHeight = dateHeight - displayDateHeight - editControlsHeight - eventInfoAnchorMarginTop;

	// set the height of the calendar date cells to be equal to the width of the cell (so they appear square in shape)
	$j("#" + eventCalendarID + " tbody td").height(calendarCellWidth);

	// set the dimensions of the date container
	$j("#" + eventCalendarID + " tbody td div.date").width(dateWidth);
	$j("#" + eventCalendarID + " tbody td div.date").height(dateHeight);

	// set the dimensions of the event info container
	$j("#" + eventCalendarID + " tbody td div.event_info").width(eventInfoWidth);
	$j("#" + eventCalendarID + " tbody td div.event_info").height(eventInfoHeight);
	
	// for dates that contain two or events, set the height to be 1/2 of the normal height
	$j("#" + eventCalendarID + " tbody td div.halfheight").height(eventInfoHeight / 2);
	
	// set the dimensions of the event info anchors
	$j("#" + eventCalendarID + " tbody td div.event_info a").width(eventInfoWidth - eventInfoAnchorMarginLeft);
	$j("#" + eventCalendarID + " tbody td div.event_info a").height(eventInfoHeight - eventInfoAnchorMarginTop);
	$j("#" + eventCalendarID + " tbody td div.halfheight a").height((eventInfoHeight / 2) - eventInfoAnchorMarginTop);

	// setup event info tool tips	
	$j("#" + eventCalendarID + " tbody td div.event_info a.tool_tip_right_bottom").qtip({
		show: "mouseover",
		hide: "mouseout",
		position: {
			corner: {
			target: "rightMiddle",
			tooltip: "leftTop"
			}
		},
		style: {
			border: {
				width: 7,
				radius: 5,
				color: eval("__RHEventsToolTipBorderColor_" + eventCalendarID)
			},
			background: eval("__RHEventsToolTipBackgroundColor_" + eventCalendarID),
			color: eval("__RHEventsToolTipColor_" + eventCalendarID),
			tip: "leftTop",
			name: "light" 
		}
	});	
	$j("#" + eventCalendarID + " tbody td div.event_info a.tool_tip_left_bottom").qtip({
		show: "mouseover",
		hide: "mouseout",
		position: {
			corner: {
			target: "leftMiddle",
			tooltip: "rightTop"
			}
		},
		style: {
			border: {
				width: 7,
				radius: 5,
				color: eval("__RHEventsToolTipBorderColor_" + eventCalendarID)
			},
			background: eval("__RHEventsToolTipBackgroundColor_" + eventCalendarID),
			color: eval("__RHEventsToolTipColor_" + eventCalendarID),
			tip: "rightTop",
			name: "light" 
		}
	});	
	$j("#" + eventCalendarID + " tbody td div.event_info a.tool_tip_right_top").qtip({
		show: "mouseover",
		hide: "mouseout",
		position: {
			corner: {
			target: "rightMiddle",
			tooltip: "leftBottom"
			}
		},
		style: {
			border: {
				width: 7,
				radius: 5,
				color: eval("__RHEventsToolTipBorderColor_" + eventCalendarID)
			},
			background: eval("__RHEventsToolTipBackgroundColor_" + eventCalendarID),
			color: eval("__RHEventsToolTipColor_" + eventCalendarID),
			tip: "leftBottom",
			name: "light" 
		}
	});	
	$j("#" + eventCalendarID + " tbody td div.event_info a.tool_tip_left_top").qtip({
		show: "mouseover",
		hide: "mouseout",
		position: {
			corner: {
			target: "leftMiddle",
			tooltip: "rightBottom"
			}
		},
		style: {
			border: {
				width: 7,
				radius: 5,
				color: eval("__RHEventsToolTipBorderColor_" + eventCalendarID)
			},
			background: eval("__RHEventsToolTipBackgroundColor_" + eventCalendarID),
			color: eval("__RHEventsToolTipColor_" + eventCalendarID),
			tip: "rightBottom",
			name: "light" 
		}
	});	
}
