var calendarCellPadding = 0
var calendarCellSpacing = 0
var calendarCellHeight = '14'
var calendarHeaderHeight = '14'

/*************** FORMAT MONTH YEAR MENU ***************/
formatMonthYearMenu = function (year, month){
	var text = ''
	text += '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="' + ((ProjectID == 2)?0:4) + '" CELLPADDING="0"><TR>'
	text += '<TD CLASS="calendarMove">' + formatMonthYearMenu_LastMonth(year, month) + '</TD>'
	text += '<TD WIDTH="100%" ALIGN="center" CLASS="calendarTitle">'
	text += formatMonthYearMenu_CurrentMonth(year, month)
	text += '</TD>'
	text += '<TD CLASS="calendarMove">' + formatMonthYearMenu_NextMonth(year, month) + '</TD>'
	text += '</TR></TABLE>'
	return text
}


formatMonthYearMenu_CurrentMonth = function(year, month){
	var text = ''
	text += '<A HREF="javascript:moveCalendar(' + year + ', ' + month + ')">' + ((ProjectID==2)?Months[month].toUpperCase():Months[month]) + '</A>'// + ' ' +  year
	if(ProjectID == 2)
		text += ' <A HREF="javascript:moveCalendar(' + year + ', ' + month + ')">' + year + '</A>'
	return text
}

formatMonthYearMenu_LastMonth = function(year, month){
	if(month == 0){
		month= 11
		year--
	} else {
		month--
	}	

	if(ProjectID == 2)
		return '<A HREF="javascript:moveCalendar(' + year + ', ' + month + ')" TITLE="' + Months[month] + ' ' + year + '" STYLE="color:#333333;text-decoration:none"><IMG SRC="/mskcc_resources/images/calendar/previous.gif" WIDTH="13" HEIGHT="13" BORDER="0" ALT="' + Months[month] + ' ' + year + '"></A>'
	else if(ProjectID == 4 || ProjectID == 11)
		return '<A HREF="javascript:moveCalendar(' + year + ', ' + month + ')"><IMG SRC="/template_resources/images/arrows/double/left/' + window.ButtonColor + '.gif" ALT="' + Months[month] + ' ' + year + '" WIDTH="13" HEIGHT="9" BORDER="0"></A>'
	else
		return '<A HREF="javascript:moveCalendar(' + year + ', ' + month + ')" TITLE="' + Months[month] + ' ' + year + '" STYLE="color:#333333;text-decoration:none"><B>&lt;&lt;</B></A>'
}

formatMonthYearMenu_NextMonth = function(year, month){
	if(month == 11){
		month = 0
		year++
	} else {
		month++
	}	
	if(ProjectID == 2)
		return '<A HREF="javascript:moveCalendar(' + year + ', ' + month + ')" TITLE="' + Months[month] + ' ' + year + '"  STYLE="color:#333333;text-decoration:none"><IMG SRC="/mskcc_resources/images/calendar/next.gif" WIDTH="13" HEIGHT="13" BORDER="0" ALT="' + Months[month] + ' ' + year + '"></A>'
	else if(ProjectID == 4 || ProjectID == 11)
		return '<A HREF="javascript:moveCalendar(' + year + ', ' + month + ')"><IMG SRC="/template_resources/images/arrows/double/right/' + window.ButtonColor + '.gif" ALT="' + Months[month] + ' ' + year + '" WIDTH="13" HEIGHT="9" BORDER="0"></A>'
	else
		return '<A HREF="javascript:moveCalendar(' + year + ', ' + month + ')" TITLE="' + Months[month] + ' ' + year + '"  STYLE="color:#333333;text-decoration:none"><B>&gt;&gt;</B></A>'
}

/*************** FORMAT DAY OF WEEK ***************/
formatDayOfWeek = function (text){
	return text.substring(0,1)
}

/*************** FORMAT WEEK DIVIDER ***************/
formatWeekDivider = function (){
	return '<TR><TD COLSPAN="7"><IMG SRC="/_javascript/_images/spacer.gif" WIDTH="1" HEIGHT="2"></TD></TR>'
}

/*************** SET CALENDAR ***************/
setCalendar = function(year, month, date){
	var selectedDate = (month+1) + "/" + date + "/" + year
	if(self.location.href.indexOf("/_temp/") != -1 && !view_onepage)
		location = view_byday + "&Query=" + escape("SelectedDate=" + selectedDate)
	else
		location = view_byday + ((view_byday.indexOf("?") == -1)?"?":"&") + "SelectedDate=" + escape(selectedDate)
}

/*************** MOVE CALENDAR ***************/
moveCalendar = function(year, month){
	var daysInMonth = getDaysInMonth(year)[month]

	var _date = (month+1) + "/" + ((daysInMonth < selectedDate)?daysInMonth:selectedDate) + "/" + year
	
	if(self.location.href.indexOf("/_temp/") != -1 && !view_onepage)
		location = view_bymonth + "&Query=" + escape("SelectedDate=" + _date)
	else
		location = view_bymonth + ((view_bymonth.indexOf("?") == -1)?"?":"&") + "SelectedDate=" + escape(_date)

}

