<!--
//////////////////////////////////////////////////////////////
//	Author:		Mark Noseworthy (?2005 Triton Data Inc.)	//
//	Created:	June 8/05									//
//															//
//	Purpose:	Calendar of Events							//
//////////////////////////////////////////////////////////////

var arrMonths = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" );
var arrDays = new Array( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" );

//
// blnMini - draw a mini calendar
// iDaySize is the number of letters in the weekday to display
// iDayHdrHeight is the size of the weekday header
// blnDisplayData tells whether or not to display event data
// blnShowHeaderNav tells whether or not to display a short version of the header nav (e.g. next or previous month)
var blnMini = false;
var iDaySize = 0; // 3 = Sun, Mon, etc. ; 0 = Sunday, Monday, etc.
var iDayHdrHeight = 20;
var blnDisplayData = true;
var blnShowSmallHeaderNav = false;



/////// STYLES and/or COLORS ///////

var coeMainBlockBg = "#ffffff";		// background for dated blocks
var coeUnusedBlockBg = "#d9d9d9";	// background for undated blocks

var coeBlockBorderStyle = "solid 1px black"; // border surrounding main blocks
var coeBlockDayHdrBorderStyle = "solid 1px white"; // border surrounding day header blocks
var coeBlockDayHdrBorderStyleSm = "solid 1px black"; // border surrounding day header blocks for small calendar
var coeBlockBorderStyleSm = "solid 1px rgb(100,100,100)";

var coeRoomsColor = "rgb(249,237,213)"; //	#F9EDD5

//var coeRmsColor = "rgb(220,144,0)";		//	#DC9000 - these four are somewhat different shades than the bullets at top of cal.
//var coeArcColor = "rgb(239,47,36)";		//	#EF2F24
//var coeMusColor = "rgb(0,146,180)";		//	#0092B4
//var coeArtColor = "rgb(107,160,60)";		//	#6BA03C

// taken from footer menu hovers
var coeRmsColor = "#FFAE00";
var coeArcColor = "#DE2D21";
var coeMusColor = "#00A5E4";
var coeArtColor = "#7AC142";

// darker than the above
/*var coeArchivesColor = "rgb(200,24,15)";//"rgb(239,47,36)"
var coeMuseumColor = "rgb(0,100,125)";	//"rgb(0,146,180)"
var coeArtGalColor = "rgb(81,120,46)";	//"rgb(107,160,60)"*/
///// END STYLES /////



var dtCurrent = new Date();
var ie4, ns4, ns6;

//var arrEvents = new Array();

var blnFillEvents = true;

// Filter Types: ///////////////////////
//		allFilterBullet -> Show All
//		arcFilterBullet -> Archives
//		musFilterBullet -> Museum
//		artFilterBullet -> Art Gallery
//
//## These are also the image file names for the filter bullets

var arrFilters = new Array(5);/*@@*/
arrFilters['allFilterBullet'] = 0;
arrFilters['rmsFilterBullet'] = 1;/*@@*/
arrFilters['arcFilterBullet'] = 2;
arrFilters['musFilterBullet'] = 3;
arrFilters['artFilterBullet'] = 4;
//arrFilters['rmsFilterBullet'] = 4;/*@@*/

////////////////////////////////////////


/////// FUNCTIONS ///////
function checkBrowser() {
	ns4 = (document.layers) ? 1 : 0;
	ie4 = (document.all) ? 1 : 0;
	ns6 = document.getElementById && (!document.all ? 1 : 0);
	
	
	return (ie4 || ns6);
}

function coeInit( iY, iM, iD, iFltr, blnMiniCal ) {
	if( checkBrowser() ) {
		
		setCurrentDate( new Date(iY, iM, iD, 0, 0, 1) );
		
		setHolidays();
		
			
		setEventArray(); // has to be set first to populate data
			
		// set cursor here for IE5 bug -- don't recognize 'pointer'...rather, use 'hand'
		getObject("rmsFilterBullet").style.cursor = getCursor();
		getObject("tdrmsFilterBullet").style.cursor = getCursor();
		
		getObject("arcFilterBullet").style.cursor = getCursor();
		getObject("tdarcFilterBullet").style.cursor = getCursor();
		
		getObject("musFilterBullet").style.cursor = getCursor();
		getObject("tdmusFilterBullet").style.cursor = getCursor();
		
		getObject("artFilterBullet").style.cursor = getCursor();
		getObject("tdartFilterBullet").style.cursor = getCursor();
		
		getObject("allFilterBullet").style.cursor = getCursor();
		getObject("tdallFilterBullet").style.cursor = getCursor();
		
		
		if( iFltr != null ) {
			switch(iFltr) {
				case 0:
					strFilter = "allFilterBullet";
					break;
				case 1:/*@@*/
					strFilter = "rmsFilterBullet";
					break;
				case 2:
					strFilter = "arcFilterBullet";
					break;
				case 3:
					strFilter = "musFilterBullet";
					break;
				case 4:
					strFilter = "artFilterBullet";
					break;
				
			}
			
			setFilter( strFilter, true );
			
			// createCalendarMonth(); //***** being called in the setFilter function call
		} else {
			createCalendarMonth();
		}
			
	}
}


function createCalendarMonth() {
	if( !ns4 ) {
		var dtStart = new Date(dtCurrent);

		var objTbl, objMonthText;
		
		var iMonth, iDate, iYear, iDay, iMonthDays;
		
		var iDayCount = 1;
		
		
		
		iMonth = dtStart.getMonth();	// 0 - Jan through 11 - Dec
		iYear = dtStart.getFullYear();
		iDay = dtStart.getDay();		// 0 for Sun through 6 for Sat
		iDate = dtStart.getDate();		// 1 - 30/31
		
		iFirstDay = new Date( iYear, iMonth, 1 ).getDay();
		iMonthDays = new Date( iYear, iMonth+1, 0 ).getDate();
		
		//var iRows = iMonthDays;
		
		
		objTbl = (ie4) ? document.all["tblCOE"] : document.getElementById("tblCOE");
		
		
		// set next and prev months
		var objNext, objPrev;
		objPrev = (ie4) ? document.all["coePrev"] : document.getElementById("coePrev");
		objNext = (ie4) ? document.all["coeNext"] : document.getElementById("coeNext");
		
		objPrev.style.cursor = getCursor();
		objNext.style.cursor = getCursor();
		
		objPrev.innerHTML = arrMonths[(iMonth==0)?11:(iMonth-1)];// + "&nbsp;";
		objNext.innerHTML = arrMonths[(iMonth==11)?0:(iMonth+1)];// + "&nbsp;";
		objPrev = null;
		objNext = null;
		
		// update the jump to info
		var selMonth = (ie4) ? document.all["selMonth"] : document.getElementById("selMonth");
		var selYear = (ie4) ? document.all["selYear"] : document.getElementById("selYear");
		
		selMonth.value = iMonth;
		selYear.value = iYear;
		
		selMonth = null;
		selYear = null;
		
		
		objMonthText = (ie4) ? document.all["calMonthText"] : document.getElementById("calMonthText");
		// set months' name
		objMonthText.innerHTML = arrMonths[iMonth] + " " + iYear;
		
		
		var iFilter = arrFilters[getLastFilter()];
		var strInnerTbl = new String("");
		strInnerTbl = '<tr height="25" class="coeListHeader"><th width="70" align="left">&nbsp;</th><th width="200" align="left">Event or Exhibit</th><th align="left" width="190">Date and Time</th><th width="120" align="left">Level</th></tr>';
		
		
		var arrInfo = new Array();
		
		
		//alert( "rms = " + arrEvents[1].length + "\r\narc = " + arrEvents[2].length + "\r\nmus = " + arrEvents[3].length + "\r\nart = " + arrEvents[4].length );
		
		//objTbl.style.visibility = "hidden";
		
		// create calendar days
		for( var r = 1; r <= iMonthDays; r++ ) {
			
			//var tblRow = objTbl.insertRow(r)
			//tblRow.innerHTML = fillEvents(r, iFilter, iMonth)
			
			if( blnFillEvents && blnDisplayData ) {
				var strIsHoliday = iMonth+1 + "/" + r + "/" + iYear;
				
				// isHoliday called from coe_holidays... returns a 2 dimensional array of each holiday with room and description if holiday matchs date
				arrInfo = isHoliday(new Date(strIsHoliday));
				
				strInnerTbl += fillEvents( r, iFilter, arrInfo );
			}
			
		}
		
		
		objTbl.innerHTML = '<table width="587" cellpadding="2" cellspacing="0" border="0" class="coeTableList">' + strInnerTbl + '</table>';
		
		getObject("tblMonthNav").style.visibility = "visible";
		getObject("tblJumpToNav").style.visibility = "visible";
		getObject("tblFilterNav").style.visibility = "visible";
		
		objTbl.style.visibility = "visible";
		
		
	} // End if( !ns4 )...
}


// fill the calendar with events from the db
//
// iDay is the value from iDay in the createCalBlock function 
// which is called from the createCalendar function that passes iDayCount
//
// arrRoomsToHide => index 0 = the room id; index 1 = desc
function fillEvents( iDay, iFilter, arrRoomsToHide ) {
	
	var dtIDay = new Date( dtCurrent.getFullYear(), dtCurrent.getMonth(), iDay, 0, 0, 1 );
	
	
	//var obj = (ie4) ? document.all["coeInfo"] : document.getElementById("coeInfo");
	var strRet = new String("");
	var strTooltipDay = "";
	
	
	// max length of title to show
	var iMaxLen = 35;
	
	var x;
	var iArcCount = 0, iMusCount = 0, iArtCount = 0, iRmsCount = 0;
	
	
	var blnHideArc = false, blnHideMus = false, blnHideArt = false, blnHideRms = false;
	
	for(var a = 0; a < arrRoomsToHide.length; a++ ) {
		if( arrRoomsToHide[a] ) {
			if( parseInt(arrRoomsToHide[a][0]) == arrFilters['rmsFilterBullet'] ) {
				blnHideRms = true;	
			}
			else if( parseInt(arrRoomsToHide[a][0]) == arrFilters['arcFilterBullet'] ) {
				blnHideArc = true;
			}
			else if( parseInt(arrRoomsToHide[a][0]) == arrFilters['musFilterBullet'] ) {
				blnHideMus = true;
			}
			else if( parseInt(arrRoomsToHide[a][0]) == arrFilters['artFilterBullet'] ) {
				blnHideArt = true;
			}
		}
	}
	
	
	if( !blnHideRms ) {
		//for( x=1; x < arrEvents.length; x++ ) {
		for( x=iFilter; x < ((iFilter != 0) ? iFilter+1 : arrEvents.length); x++ ) {
			
			if( (arrEvents[x] != null) || (arrEvents[x]) ) {
				
				for( var i=0; i < arrEvents[x].length; i++ ) {
					var iArrFltrLen = arrFilters.length-1;
					
					var blnOngoing = new String(arrEvents[x][i][EVT_TBL_Ongoing]).toLowerCase();
					blnOngoing = (blnOngoing == "true") ? true : false;
					
					var dtEvtBegin = new Date(arrEvents[x][i][EVT_TBL_BeginDate]);
					var dtEvtEnd = new Date(arrEvents[x][i][EVT_TBL_EndDate]);
					
					
					var iMonthDays = new Date( dtIDay.getFullYear(), dtIDay.getMonth()+1, 0 ).getDate();
					var dtEndOfMonth = new Date( dtIDay.getFullYear(), dtIDay.getMonth(), iMonthDays, 0, 0, 1 );
					
					
					var strEvtBeginTime, strEvtEndTime;
					strEvtBeginTime = new String(getFormattedTime(dtEvtBegin));
					//strEvtBeginTime += (dtEvtBeging.getHours() > 12) ? dtEvtBeging.getHours()-12 : dtEvtBeging.getHours()
					
					strEvtEndTime = new String(getFormattedTime(dtEvtEnd));
					
					
					
					dtEvtBegin.setHours(0, 0, 1);
					dtEvtEnd.setHours(0, 0, 1);
					
					
					var blnNoRange = ( dtEvtBegin == dtIDay );
					
					
					if( ( ((dtIDay >= dtEvtBegin) && (dtIDay <= dtEvtEnd)) || blnNoRange ) || blnOngoing ) {
						strTooltipDay = 'name="'+ arrMonths[dtIDay.getMonth()]+dtIDay.getDate()+dtIDay.getFullYear() + '" onclick="location.href = \'CoE_EventView.asp?eid=all&date=' + arrMonths[dtIDay.getMonth()] + ' ' + dtIDay.getDate() + ', ' + dtIDay.getFullYear() + '\';" onmouseout="showToolTip(event, \'\', this, \'\');" onmouseover="showToolTip(event, \'Click to view All events.\', this, \'\');"';
					
						var strLevel = new String(arrEvents[x][i][EVT_TBL_Level]);
						var strFullTitle = new String(arrEvents[x][i][EVT_TBL_Title]);
						var strTitle = strFullTitle;
						var intEvtId = parseInt(arrEvents[x][i][EVT_TBL_Id]);
						
						var strEvt = "", strEvtStrCls = "";
						var iSpc = -1, iNewLine = -1;
						
						//iMaxLen is at the start of this function
						strTitle = (strTitle.length > iMaxLen) ? strTitle.substring(0,iMaxLen+1) : strTitle;
						iNewLine = strTitle.indexOf("<br>");
						
						if( iNewLine > 0 ) {
							strTitle = strTitle.substring(0,strTitle.indexOf("<br>"));
						}
						
						iSpc = strTitle.lastIndexOf(" ");
						
						if( (iSpc > 0) && (strTitle.length > iMaxLen) ) {
							strTitle = strTitle.substring(0,strTitle.lastIndexOf(" "));
						}
						
						var strTooltip = "";
						
						if( strTitle != "" ) {
							if( strTitle.length != strFullTitle.length ) {
								strTitle = strTitle.concat( "..." );
								strTooltip = 'onmouseout="showToolTip(event, \'\', this, \'\');" onmouseover="showToolTip(event, \'' + strFullTitle + '\', this, this.style.color);"';
							}
							strEvtStrCls = 'class="coeEvent"';
						} else {
							strEvtStrCls = 'class="coeEventNone"';
						}
						
						
						var strFromTo = new String("");
						
						strFromTo = (!blnOngoing) ? arrMonths[dtEvtBegin.getMonth()] + ' ' + dtEvtBegin.getDate() + ' - ' + arrMonths[dtEvtEnd.getMonth()] + ' ' + dtEvtEnd.getDate() : 'Ongoing';
						
						strFromTo = (!blnOngoing && (Date.parse(dtEvtBegin) == Date.parse(dtEvtEnd))) ? strEvtBeginTime + " - " + strEvtEndTime : strFromTo;
						
						
						
						//// if changing anything inside the cases below, check below in the ifs before the return statement so they match...this is messy yes!!! need fixing... I hate fixing on the fly... cowboy coding?
						if( iFilter == x || !iFilter ) {
							switch( x ) {
								case arrFilters['rmsFilterBullet']:
									strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeRmsColor + ';">&nbsp;The Rooms&nbsp;</div></td><td nowrap ' + strEvtStrCls + '><a ' + strTooltip + ' style="color: ' + coeRmsColor + '" class="coeEvent" href="CoE_EventView.asp?eid=' + intEvtId + '&date=' + arrMonths[dtIDay.getMonth()] + ' ' + dtIDay.getDate() + ', ' + dtIDay.getFullYear() + '" alt="' + strTitle + '">' + strTitle + '</a></td>';
								strEvt = strEvt.concat('<td class="coeMainBlock" style="color: ' + coeRmsColor + '">' + strFromTo + '</td><td class="coeMainBlock" style="color: ' + coeRmsColor + '">' + strLevel + '</td>');
									
									strEvt = strEvt.concat('</tr>\r\n');
									strRet += strEvt;
									
									if( strEvt != "" )
										iRmsCount++;
									break;
								
								case arrFilters['arcFilterBullet']:
									if( blnHideArc ) {
										strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeArcColor + ';">&nbsp;&nbsp;archives&nbsp;&nbsp;</div></td><td colspan="3" nowrap ' + strEvtStrCls + '><span style="color: ' + coeArcColor + '" class="coeEvent">' + arrRoomsToHide[x][1] + '</span></td>';
									
										i = arrEvents[x].length;
									}
									else {
										strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeArcColor + ';">&nbsp;&nbsp;archives&nbsp;&nbsp;</div></td><td nowrap ' + strEvtStrCls + '><a ' + strTooltip + ' style="color: ' + coeArcColor + '" class="coeEvent" href="CoE_EventView.asp?eid=' + intEvtId + '&date=' + arrMonths[dtIDay.getMonth()] + ' ' + dtIDay.getDate() + ', ' + dtIDay.getFullYear() + '">' + strTitle + '</a></td>';
									strEvt = strEvt.concat('<td class="coeMainBlock" style="color: ' + coeArcColor + '">' + strFromTo + '</td><td class="coeMainBlock" style="color: ' + coeArcColor + '">' + strLevel + '</td>');
									}
									
									strEvt = strEvt.concat('</tr>\r\n');
									strRet += strEvt;
									
									if( strEvt != "" )
										iArcCount++;
											
									break;
									
								case arrFilters['musFilterBullet']:
									if( blnHideMus ) {
										strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeMusColor + ';">&nbsp;&nbsp;museum&nbsp;&nbsp;</div></td><td colspan="3" nowrap ' + strEvtStrCls + '><span style="color: ' + coeMusColor + '" class="coeEvent">' + arrRoomsToHide[x][1] + '</span></td>';
									
										i = arrEvents[x].length;
									}
									else {
										strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeMusColor + ';">&nbsp;&nbsp;museum&nbsp;&nbsp;</div></td><td nowrap ' + strEvtStrCls + '><a ' + strTooltip + ' style="color: ' + coeMusColor + '" class="coeEvent" href="CoE_EventView.asp?eid=' + intEvtId + '&date=' + arrMonths[dtIDay.getMonth()] + ' ' + dtIDay.getDate() + ', ' + dtIDay.getFullYear() + '" alt="' + strTitle + '">' + strTitle + '</a></td>';
										strEvt = strEvt.concat('<td class="coeMainBlock" style="color: ' + coeMusColor + '">' + strFromTo + '</td><td class="coeMainBlock" style="color: ' + coeMusColor + '">' + strLevel + '</td>');
									}
									
									strEvt = strEvt.concat('</tr>\r\n');
									strRet += strEvt;
									
									if( strEvt != "" )
										iMusCount++;
									
									break;
									
								case arrFilters['artFilterBullet']:
									if( blnHideArt ) {
										strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeArtColor + ';">&nbsp;&nbsp;art gallery&nbsp;&nbsp;</div></td><td colspan="3" nowrap ' + strEvtStrCls + '><span style="color: ' + coeArtColor + '" class="coeEvent">' + arrRoomsToHide[x][1] + '</span></td>';
									
										i = arrEvents[x].length;
									}
									else {
										strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeArtColor + ';">&nbsp;&nbsp;art gallery&nbsp;&nbsp;</div></td><td nowrap ' + strEvtStrCls + '><a ' + strTooltip + ' style="color: ' + coeArtColor + '" class="coeEvent" href="CoE_EventView.asp?eid=' + intEvtId + '&date=' + arrMonths[dtIDay.getMonth()] + ' ' + dtIDay.getDate() + ', ' + dtIDay.getFullYear() + '" alt="' + strTitle + '">' + strTitle + '</a></td>';
									strEvt = strEvt.concat('<td class="coeMainBlock" style="color: ' + coeArtColor + '">' + strFromTo + '</td><td class="coeMainBlock" style="color: ' + coeArtColor + '">' + strLevel + '</td>');
									}
									
									strEvt = strEvt.concat('</tr>\r\n');
									strRet += strEvt;
										
									if( strEvt != "" )
										iArtCount++;
											
									break;
							} // end switch
						}
						
					}
						
				} // End for arrEvents[x].length
				
				
				
			} // End if( (arrEvents[x] != null) || (arrEvents[x]) )
		}
		
		strRet = '<tr><td colspan="4" height="31" class="coeMainBlockListTitle" style="padding-bottom: 6px;"><span ' + strTooltipDay + '><a name="'+ arrMonths[dtIDay.getMonth()]+dtIDay.getDate()+dtIDay.getFullYear() + '"></a><b>' + arrDays[new Date(dtCurrent.getFullYear(), dtCurrent.getMonth(), iDay).getDay()] + ', ' + arrMonths[dtCurrent.getMonth()] + ' ' + iDay + '</b></span></td></tr>\r\n' + strRet;
		//strRet += '<tr><td height="25" colspan="4" class="coeListDayFooter"></td></tr>';	
		
	} // End if
	else {
		strRet = '<tr><td colspan="4" height="31" class="coeMainBlockListTitle" style="padding-bottom: 6px;"><a name="'+ arrMonths[dtIDay.getMonth()]+dtIDay.getDate()+dtIDay.getFullYear() + '"></a><b>' + arrDays[new Date(dtCurrent.getFullYear(), dtCurrent.getMonth(), iDay).getDay()] + ', ' + arrMonths[dtCurrent.getMonth()] + ' ' + iDay + '</b></td></tr>\r\n';
		strRet += '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeRmsColor + ';">&nbsp;The Rooms&nbsp;</div></td><td colspan="3" class="coeMainBlock"><span style="color: ' + coeRmsColor + '" class="coeEventNone">' + arrRoomsToHide[1][1] + '</span></td></tr>';
		//strRet += '<tr><td height="25" colspan="4" class="coeListDayFooter"></td></tr>';
	}
	
	
	//// Display holiday/closed message if there are no events but a holiday for a specific room ////////
	//// if changing anything inside the ifs below check above in the switch so they match.
	if( iArcCount <= 0 && blnHideArc ) {
		strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeArcColor + ';">&nbsp;&nbsp;archives&nbsp;&nbsp;</div></td><td colspan="3" nowrap ' + strEvtStrCls + '><span style="color: ' + coeArcColor + '" class="coeEvent">' + arrRoomsToHide[arrFilters['arcFilterBullet']][1] + '</span></td>';
		//strEvt = strEvt.concat('<td class="coeMainBlock" style="color: ' + coeArcColor + '">Closed</td><td class="coeMainBlock" style="color: ' + coeArcColor + '">-</td>');
		strEvt = strEvt.concat('</tr>\r\n');
		strRet += strEvt;
	}
	else if( iMusCount <= 0 && blnHideMus ) {
		strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeMusColor + ';">&nbsp;&nbsp;museum&nbsp;&nbsp;</div></td><td colspan="3" nowrap ' + strEvtStrCls + '><span style="color: ' + coeMusColor + '" class="coeEvent">' + arrRoomsToHide[arrFilters['musFilterBullet']][1] + '</span></td>';
		//strEvt = strEvt.concat('<td class="coeMainBlock" style="color: ' + coeMusColor + '">Closed</td><td class="coeMainBlock" style="color: ' + coeMusColor + '">-</td>');
		strEvt = strEvt.concat('</tr>\r\n');
		strRet += strEvt;
	}
	else if( iArtCount <= 0 && blnHideArt ) {
		strEvt = '<tr><td nowrap align="center" style="color: white; font: normal 10pt Times New Roman;"><div style="padding: 2px 0px 2px 0px; background-color: ' + coeArtColor + ';">&nbsp;&nbsp;art gallery&nbsp;&nbsp;</div></td><td colspan="3" nowrap ' + strEvtStrCls + '><span style="color: ' + coeArtColor + '" class="coeEvent">' + arrRoomsToHide[arrFilters['artFilterBullet']][1] + '</span></td>';
		//strEvt = strEvt.concat('<td class="coeMainBlock" style="color: ' + coeArtColor + '">Closed</td><td class="coeMainBlock" style="color: ' + coeArtColor + '">-</td>');
		strEvt = strEvt.concat('</tr>\r\n');
		strRet += strEvt;
	}
	/////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	
	strRet += '<tr><td height="25" colspan="4" class="coeListDayFooter"></td></tr>';
	
	return strRet;
}


function setCurrentDate( dtDate ) {
	dtCurrent = new Date(dtDate);
}


function getMonthsDayCount( iM, iY ) {
	// add 1 to the month and 0 for day to get last day of month passed in
	// actually returns last day of month
	
	return new Date(iY, iM+1, 0).getDate();

}

function setLocation( dt, d2 ) {
	var frmPost = (ie4) ? document.all["frmPost"] : document.getElementById("frmPost");
	var selYear = (ie4) ? document.all["selYear"] : document.getElementById("selYear");
	
	var iSelMinYear = parseInt(selYear.options[1].value);
	var iSelMaxYear = parseInt(selYear.options[selYear.options.length-1].value);

	
	if( dt.getFullYear() > iSelMaxYear || dt.getFullYear() < iSelMinYear )
		return false;
	
	
	var strLoc = new String("");
	//strLoc = "http://" + location.hostname + ((location.port != 80) ? (":" + location.port) : "") + location.pathname;
	strLoc = location.pathname
	strLoc += "?d0=" + dt.getFullYear();
	strLoc += "&d1=" + dt.getMonth();
	strLoc += "&d2=" + d2;
	
	location.href = strLoc
	
	/*frmPost.action = location.pathname;
	frmPost.d0.value = dt.getFullYear();
	frmPost.d1.value = dt.getMonth()
	frmPost.d2.value = d2;
	frmPost.submit();*/
}

function jumpTo() {
	var selYear = (ie4) ? document.all["selYear"] : document.getElementById("selYear");
	var selMonth = (ie4) ? document.all["selMonth"] : document.getElementById("selMonth");
	
	var iSelYear = parseInt(selYear.options[selYear.selectedIndex].value);
	var iSelMonth = parseInt(selMonth.options[selMonth.selectedIndex].value);
	
	if(iSelYear == -1 || iSelMonth == -1 ) {
		return false;
	}
	
	selYear = null;
	selMonth = null;
	
	if( blnMini ) {
		setCurrentDate( new Date(iSelYear, iSelMonth, 1) );
		createCalendarMonth();
	} else {
		setLocation( new Date(iSelYear, iSelMonth, 1), arrFilters[getLastFilter()] );
	}
	
}


function nextMonth() {
	if( blnMini ) {
		setCurrentDate( new Date(dtCurrent.getFullYear(), (dtCurrent.getMonth()+1), dtCurrent.getDate()) );
		createCalendarMonth();
	} else {
		setLocation( new Date(dtCurrent.getFullYear(), dtCurrent.getMonth()+1, 1), arrFilters[getLastFilter()] );
	}
}

function prevMonth() {
	if( blnMini ) {
		setCurrentDate( new Date(dtCurrent.getFullYear(), (dtCurrent.getMonth()-1), dtCurrent.getDate()) );
		createCalendarMonth();
	} else {
		setLocation( new Date(dtCurrent.getFullYear(), dtCurrent.getMonth()-1, 1), arrFilters[getLastFilter()] );
	}
}


function getObject( strObjName ) {
	if( ie4 ) {
		if(document.all[strObjName] != null) return document.all[strObjName];
		else return null;
		
	} else {
		if(document.getElementById(strObjName) != null) return document.getElementById(strObjName);
		else return null;
	}
}

function getLastFilter() {
	var objTxtLastFilter = getObject("txtLastFilter");		//(ie4) ? document.all["txtLastFilter"] : document.getElementById("txtLastFilter");
	
	if( objTxtLastFilter != null ) {
		blnFillEvents = (objTxtLastFilter.value != "");
	
		return objTxtLastFilter.value;
	}
}

// blnFromInit is used for cases such as Mozilla;
//		- when I hit F5 the text input field holds its data which in turn causes the last 
//		  condition (call createCalendarMonth?) of this function to fail
function setFilter( fltrType, blnFromInit ) {
	var objFilterIndicator;//(ie4) ? document.all[fltrType] : document.getElementById(fltrType);
	var objTxtLastFilter = (ie4) ? document.all["txtLastFilter"] : document.getElementById("txtLastFilter");
	
	var strLast = objTxtLastFilter.value;
	
	
	objFilterIndicator = (ie4) ? document.all[fltrType] : document.getElementById(fltrType);
	objFilterIndicator.src = "images/coe/" + fltrType + "_on" + ".jpg";
	
	
	if( strLast != "" && strLast != fltrType ) {
		objFilterIndicator = (ie4) ? document.all[strLast] : document.getElementById(strLast);
		objFilterIndicator.src = "images/coe/" + strLast + "_off" + ".jpg";
	}

	objTxtLastFilter.value = fltrType;

	//alert( "blnFillEvents = " + blnFillEvents + "\r\n(strLast != fltrType)\r\n" + strLast + " != " + fltrType );
	if( (strLast != fltrType) || blnFromInit )
		createCalendarMonth();
	
	
	objFilterIndicator = null;
	objTxtLastFilter = null;
}


function getCursor() {
	return ((ie4) ? "hand" : "pointer" );
}



// returns string in 12hr format
function getFormattedTime( dtDate ) {
	var dtDate = new Date(dtDate);
	var strHrs = "", strMins = "", strAMPM;
	
	
	if(dtDate) {
		if( dtDate.getHours() >= 12 ) {
			strHrs = (dtDate.getHours() > 12) ? "" + (dtDate.getHours() - 12) : strHrs;
			strAMPM = "PM";
		}
		else {
			strHrs = dtDate.getHours();
			strAMPM = "AM";
		}
		
		strMins = (dtDate.getMinutes() < 10) ? "0" + dtDate.getMinutes() : dtDate.getMinutes();
		
		return strHrs + ":" + strMins + " " + strAMPM;
	}
}


// used to clear timeout
var timeoutID = -1, displayTimeoutID = -1;
//
function showToolTip(event, strText, objCaller, strBgClr) {
	var tt = getObject("coeToolTip");
	
	// placed here to keep underline when hovering...for some reason loses underline when second time hovering
	objCaller.style.textDecoration = "underline";
	
	// strBgClr is null when hovering over the date part and not an event link
	if( strBgClr == '' ) {
		strBgClr = coeRoomsColor;
		objCaller.style.cursor = getCursor();
		objCaller.style.textDecoration = "underline";
		
		//objCaller.style.fontWeight = "bold";
		//objCaller.style.textAlign = "center";
		
		//objCaller.onclick="location.href = 'CoE_View.asp?eid=all';";
		//objCaller.onClick = "alert('wow')";
		
	}
		
	
	if( strText != '' ) {
		var xm, ym, xtt, ytt;
		var wtt = 150;
		
		var xOffset = 0, yOffset = 0;
		var winw, winh;
		
		if(ie4) {
			yOffset = document.body.scrollTop;
			xOffset = document.body.scrollLeft;
			winw = document.body.clientWidth;
			winh = document.body.clientHeight;
		}
		else {
			xOffset = window.pageXOffset;
			yOffset = window.pageYOffset;
			winw = window.innerWidth;
			winh = window.innerHeight;
		}
		
		tt.style.fontFamily = "Verdana";
		tt.style.fontSize = "9pt";
		tt.style.color = "black";
		tt.style.backgroundColor = strBgClr;
		tt.style.border = coeBlockBorderStyle;
		tt.style.padding = "1px 2px 1px 2px";
		
		
		tt.innerHTML = strText

		tt.style.width = wtt + "px";
		tt.style.height = "auto";
		
		xm = event.clientX;
		ym = event.clientY;
		xtt = xm + xOffset + 15;
		ytt = ym + yOffset + 10;
		
		xtt = xtt > (wtt+winw) ? (xm+xOffset-15)-wtt : xtt;
		//ytt = ytt > (tt.offsetHeight+winh) ? (ym+yOffset-10)-tt.offsetHeight : ytt;
		
		
		tt.style.whitespace = "nowrap";
		tt.style.position = "absolute";
		
		tt.style.left = xtt + "px";
		tt.style.top = ytt + "px";
		
		
		
		//////////////////////////////////
		if( timeoutID != -1 )
			clearTimeout(timeoutID);
		
		
		timeoutID = setTimeout( "showAfterTimeout()", 250 );
		
		if( displayTimeoutID != -1 )
			clearTimeout(displayTimeoutID);
		
		displayTimeoutID = setTimeout( "hideAfterTimeout()", 5000 );
		
		
	}
	else {
		clearTimeout(timeoutID);
		objCaller.style.textDecoration = "none";
		objCaller.style.textAlign = "left";
		tt.style.visible = "hidden";
		tt.style.display = "none";
	}
}

function showAfterTimeout() {
	getObject("coeToolTip").style.visibility = "visible";
	getObject("coeToolTip").style.display = "block";
}

function hideAfterTimeout() {
	getObject("coeToolTip").style.visibility = "hidden";
	getObject("coeToolTip").style.display = "none";
}

// -->
