//
//	COPYRIGHT NOTICE:
// 	Copyright 2002 - 2006 Barry Saxifrage. Stonebreaker Designs. All Rights Reserved.
//	By using this code you agree to indemnify Barry Saxifrage and Stonebreaker Designs 
//	from any liability that might arise from its use. Selling this code or distributing 
//	this code without prior written consent is expressly forbidden. Copyright notice  
//	must remain with this code. For more information: www.stonebreakerdesigns.com	
//

	var gstrCalAllDay 	= 'all day';  // ex: 'all day'...or '' if nothing wanted

// ---------------------------	
//
//	MENU COMMANDS
//
	function calReportChangeWeek(nYear, nMonth, nWeek) {
		// can only be called from week view
		//		-- get info on weeks in the month the...
		//		1. if nWeek < 1 then move to last week of previous month
		//		2. if nWeek > #ofWeeksInMonth, move to first week of next month
		//		3. else set WEEK

		//		-- info on weeks
		var tMStart 		= new Date(nYear,nMonth-1,1, 0, 0, 0); 
		var nDayOneOfCal 	= tMStart.getDay(); 	
		var nDaysInMonth 	= getDaysInMonth(tMStart);
		//		-- weeks in month (sun-sat)
		var nTotalCells 	= nDaysInMonth + nDayOneOfCal;
		var nWeeksInMonth 	= parseInt(nTotalCells / 7)
		if ((nTotalCells % 7) > 0 ) { nWeeksInMonth++;	}
		
		if (nWeek < 1) {
			//		1. if nWeek < 1 then move to last week of previous month
			nMonth--;
			if (nMonth < 1) { nMonth = 12; nYear--; }
			var tNew 			= new Date(nYear,nMonth-1,1, 0, 0, 0); 
			var nDayOneOfCal 	= tNew.getDay(); 	
			var nDaysInMonth 	= getDaysInMonth(tNew);
			var nTotalCells 	= nDaysInMonth + nDayOneOfCal;
			var nWeeksInMonth 	= parseInt(nTotalCells / 7)
			if ((nTotalCells % 7) > 0 ) { nWeeksInMonth++;	}
			document.frm.WEEK.value = nWeeksInMonth;
			calReportOneMonth(nYear, nMonth); 
		} else if (nWeek > nWeeksInMonth) {
			//		2. if nWeek > #ofWeeksInMonth, move to first week of next month
			nMonth++;
			if (nMonth > 12) { nMonth = 1; nYear++; }
			document.frm.WEEK.value = 1;
			calReportOneMonth(nYear, nMonth); 
		} else {
			//		3. else just go to that week of current month
			document.frm.WEEK.value = nWeek;
			calFormSubmit();
		}
	}
	function calReportChangeMonth(nYear, nMonth, nViewType) {
		// if week view then switch to month view
		if (nViewType == 2) { document.frm.VIEW.value = 3;	}
		calReportOneMonth(nYear, nMonth);
	}
	function calReportOneMonth(nYear, nMonth) {
		// new start date
		var startDate = nYear+'-';
		if (nMonth < 10) { startDate += '0'; }
		startDate += nMonth+'-01';
		document.frm.DAYA.value = startDate;
		// new end date
		var t = new Date(nYear,nMonth-1,1, 0, 0, 0);
		var nLastDay = getDaysInMonth(t);
		var endDate = nYear+'-';
		if (nMonth < 10) { endDate += '0'; }
		endDate += nMonth+'-'+nLastDay;
		document.frm.DAYZ.value = endDate;
		calFormSubmit();
	}
	function calReportChangeYear(nYear, nMonth, nViewType) {
			calReportChangeMonth(nYear, nMonth, nViewType);
	}
	function calReportChangeWeekView(nWeek) {
		document.frm.WEEK.value = nWeek;
		calReportChangeView(2);
	}
	function calReportChangeView(nView) {
		document.frm.VIEW.value = nView;
		calFormSubmit();
	}
	function calSetOption(strOpt, nSetting) {
		if 		(strOpt == 'listdesc') 		{ SetCookie ('calReportShowText',nSetting); }
		else if (strOpt == 'weekdesc')  	{ SetCookie ('calReportShowWeekText',nSetting); }
		else if (strOpt == 'monthdesc') 	{ SetCookie ('calReportShowMonthText',nSetting); }
		calFormSubmit();
	}		


// ---------------------------	
//
//	HTML builders
//

	function getTitlebarDateString (nYearA, nMonthA, nDayA, nYearZ, nMonthZ, nDayZ, nViewType, nWeek) {
		var strReturn = '';
		// TITLEBAR DATE STRING
		//		-- date range strings
		//		-- month
		//		-- list
		//		-- weeks 1-6
		var strCurMonth = aMonths[nMonthA - 1];
		var strCurMonthShort = aMonthsShort[nMonthA - 1];
		var strDRMonth = strCurMonth+' '+nYearA;
		if (nViewType == 1) {
			//		-- list
			var strDRList  = '';
			if (nYearA != nYearZ) {
				strDRList += nDayA + ' ' + strCurMonthShort + ' ' + nYearA;
				strDRList += ' - ';
				strDRList += nDayZ + ' ' + aMonthsShort[nMonthZ - 1] + ' ' + nYearZ;
			} else if (nMonthA != nMonthZ) {
				strDRList += nDayA + ' ' + strCurMonthShort;
				strDRList += ' - ';
				strDRList += nDayZ + ' ' + aMonthsShort[nMonthZ - 1] + ' ' + nYearZ;				
			} else {
				strDRList += nDayA + ' - ' + nDayZ;
				strDRList += ' ';
				strDRList += strCurMonth + ' ' + nYearZ;								
			}
			strReturn = strDRList;
		} else if (nViewType == 2) {
			//		-- weeks
			//			-- day of week the month starts on (0-6)
			var tMStart 		= new Date(nYearA,nMonthA-1,1, 0, 0, 0); 
			var nDayOneOfCal 	= tMStart.getDay(); 	
			var nDaysInWeekOne 	= 7 - nDayOneOfCal;
			var nDaysInMonth 	= getDaysInMonth(tMStart);
			//		-- weeks in month (sun-sat)
			var nTotalCells = nDaysInMonth + nDayOneOfCal;
			var nWeeksInMonth = parseInt(nTotalCells / 7)
			if ((nTotalCells % 7) > 0 ) {
				nWeeksInMonth++;
			}
			if (nWeek < 1) { nWeek = 1; frm.document.WEEK.value = nWeek; }
			if (nWeek > nWeeksInMonth) { nWeek = nWeeksInMonth; frm.document.WEEK.value = nWeek; }		
			
			
			var nWDStart = 1;
			var nWDEnd	 = 1;
			if (nWeek == 1) {
				nWDStart = 1;
				nWDEnd = nDaysInWeekOne;
			} else {
				nWDStart = (nDaysInWeekOne + 1) + ((nWeek - 2) * 7);
				nWDEnd = nWDStart + 6;
				if (nWDEnd > nDaysInMonth) {
					nWDEnd = nDaysInMonth;
				}
			}
			var strReturn = nWDStart + ' - ' + nWDEnd;
			strReturn += ' '+ strCurMonth+ ' '+nYearA;
		} else if (nViewType == 3) {
			//		-- month
			strReturn = strCurMonth + ' ' + nYearA;
		}
		
		return strReturn;
	}
	
	function preprocessEvents (aE) {
		var aReturn = new Array();
		var strE = '';
		// for each event
		//		-- get date in various formats once and store back in array
		//		-- setup location display
		//
		for (var i = 0; i < aE.length - 1; i++) {
			var aP = aE[i].split("|");
			var idEvent		 	= aP[0];
			var szTitle 		= aP[1];
			var szText 			= aP[2];
			var szLocation		= aP[3];
			var EStart		 	= aP[4];
			var EFinish 		= aP[5];
			var szAuthor		= aP[6];
			var szEmail			= aP[7];
			var szURL			= aP[8];
			var idProduct  		= aP[9];
			var strProdInfo		= aP[10];
	
			// -- determine hours to display
			aDT = parseMysqlDatetime(EStart);
			var nStartYear 		= aDT[0];
			var nStartMonth 	= aDT[1];
			var nStartDay 		= aDT[2];
			var nStartHour		= aDT[3];
			var nStartMinute	= aDT[4];
			aP[11] = nStartYear;
			aP[12] = nStartMonth;
			aP[13] = nStartDay;
			aP[14] = nStartHour;
			aP[15] = nStartMinute;
			
			aDT = parseMysqlDatetime(EFinish);
			var nEndYear 		= aDT[0];
			var nEndMonth 		= aDT[1];
			var nEndDay 		= aDT[2];
			var nEndHour		= aDT[3];
			var nEndMinute		= aDT[4];
			aP[16] = nEndYear;
			aP[17] = nEndMonth;
			aP[18] = nEndDay;
			aP[19] = nEndHour;
			aP[20] = nEndMinute;
	
			var tStart    = new Date(nStartYear,nStartMonth-1,nStartDay, nStartHour, nStartMinute, 0); 
			var msecStart = tStart.getTime();
			aP[21] = msecStart;
			var tEnd      = new Date(nEndYear,nEndMonth-1,nEndDay, nEndHour, nEndMinute, 0);
			var msecEnd   = tEnd.getTime();
			aP[22] = msecEnd;
			
			// -- put all back into array format
			// -- append to array
			strE = aP.join('|');
			aReturn[i] = strE;
		}

		aReturn[aReturn.length] = '****';
		return aReturn;
	}
	
	// ---------------------------------------------
	//
	// GET CALENDAR REPORT -- MONTH OR WEEK VIEW HTML 
	//		-- dayA is start of date range (only month and year are used in this view)
	//		-- dayZ is end of entire date range requested (can be more than a month...ignored except for list view)
	//		-- expects aCalEvents to be ordered by StartDate!
	//		-- nWeek 
	//			 0 = show MonthView 
	//			(1-6) = show WeekView with this being number of week in the month to display (week is Sunday-Saturday)
	//		-- fShowDescriptions: if true then show text description for all events
	function getCalReportMonthHTML(dayA, dayZ, aCalEvents, fShowDescriptions, nWeek, fCanPost, idTopic, nStatusShow) {
		//	GLOBALS
		// 	set function globals to MonthView defaults
		// 	then check if WeekView and reset globals
		var fMonthView 		= true;
		var pxTable			= 780;
		var pxColSpacer		= parseInt(pxTable / 7) - 4;
		var pxEventSpacer	= pxColSpacer - 4;
		var nMinCellHeight 	= 7;	// min lines of the day cells in month grid
		var nMaxRows		= 6;	// max number of rows in a month grid
		aCalEvents 			= preprocessEvents(aCalEvents);
		var nEvents 		= aCalEvents.length - 1;
		nWeek = parseInt(nWeek);
		if ((nWeek > 0) && (nWeek < 7)) { 
			fMonthView 		= false; 
			nMinCellHeight 	= 30;
			nMaxRows		= 1;
		}

		// GET DATES 
		
		//	-- 0. first determine month info
		var nDayOneOfCal 	= -1;	// weekday number (0-6) that first day of month is on
		var nDaysInWeekOne 	= -1;	// total days in week 1
		var nDaysInMonth 	= -1;	// total number of days in the month
		var nWeekdayStart	= 0;	// day of the week to start displayed nWeek on (0=sunday for all weeks except nWeek=1)
		//			-- day of week the month starts on
		var aDT = parseMysqlDatetime(dayA);
		var nYearMStart		= aDT[0];
		var nMonthMStart	= aDT[1];
		var tMStart 		= new Date(nYearMStart,nMonthMStart-1,1, 0, 0, 0); 
		nDayOneOfCal 		= tMStart.getDay(); 	
		nDaysInWeekOne 		= 7 - nDayOneOfCal;
		nDaysInMonth 		= getDaysInMonth(tMStart);		
		
		//	-- 1. dayA...first day of events to display
		//			if month, dayA = 1
		//			if week, dayA = first day in that week
		var nYearA 		= nYearMStart;
		var nMonthA 	= nMonthMStart;
		var nDayA 		= 1;
		if ((fMonthView) || (nWeek == 1)) {
			nWeekdayStart = nDayOneOfCal;	// first week can start on any day of the week
			nDayA 		  = 1;
		} else {
			nWeekdayStart = 0; 				// sunday
			nDayA 		  = nDaysInWeekOne + 1 + ((nWeek - 2) * 7);
		}
		var tDayA 		= new Date(nYearA,nMonthA-1,nDayA, 0, 0, 0); 
		var msecDayA	= tDayA.getTime();
		

		//	-- 2. dayZ...last day of events to display
		//			if month, dayZ = last day of month
		//			if week, dayZ = last day of that week
		var nYearZ 		= nYearA;
		var nMonthZ 	= nMonthA;
		var nDayZ 		= 0;	
		if (fMonthView) { 
			nDayZ 		= nDaysInMonth;
		} else if (nWeek == 1) {
			nDayZ 		= nDaysInWeekOne;
		} else {
			nDayZ 		= nDayA + 6;
			if (nDayZ > nDaysInMonth) {
				nDayZ 	= nDaysInMonth;
			}
		}
		var tDayZ 		= new Date(nYearZ,nMonthZ-1,nDayZ, 0, 0, 0); 
		var msecDayZ	= tDayZ.getTime();
		
		//	-- 3. currently day being built in calendar (updated after each day is filled with events)
		var msecDayDisplayStart = msecDayA;
		var tDayDisplayStart 	= new Date(msecDayDisplayStart);

		var tDayDisplayEnd	 	= new Date(msecDayDisplayStart);
		var nDayEnd = tDayDisplayEnd.getDate();
		tDayDisplayEnd.setDate(nDayEnd + 1);
		var msecDayDisplayEnd	= tDayDisplayEnd.getTime() - 1000;
		
		//	-- 4. today
		var tToday = getNow();
		var msecNow = tToday.getTime();

		
		// START TABLE
		var str = '';
		str += '<table cellspacing="0" cellpadding="2" width="'+pxTable+'" >';				
		str += '<tr>';
			for (var i = 0; i < 7; i++ ) {
				str += '<td><img src="spacer.gif" width="'+pxColSpacer+'" height="1" alt="" border="0"></td>';
			}
		str += '</tr>';
		
		
		// WEEKDAY NAMES
		str += '<tr>';
			for (var i = 0; i < 7; i++ ) {
				var strTDClass = 'cvD_name';
				if (i == 0) 	{	strTDClass = 'cvD_nameL'; }
				if (i == 6) 	{	strTDClass = 'cvD_nameR';	}
				str += '<td class="'+strTDClass+'"><div class="cvM_DayName">'+aDays[i]+'</div></td>';
			}
		str += '</tr>';

		
		// -- DAY BOXES	
		//		0-based -- if first week then set to negative for number of blank days at start of month
		var iDay = nDayA - nWeekdayStart;
		for (var row = 0; row < nMaxRows; row++ ) {
			if ((row == 5) && (iDay > nDayZ)) {
				// empty bottom row...skip it
				break;
			}
			str += '<tr>';
			for (var col = 0; col < 7; col++) {
			
				// for each day
				// 		-- decide what type of day it is: PAST, NOW, FUTURE -- WEEKEND or WEEKDAY
				//		-- decide if day is weekend
				//		-- set correct style for that day box
				var strTimeStyle = 'Now';
				var nWhen 		 = 0;	// -1=past 0=now 1=future
				if 		(msecDayDisplayEnd   < msecNow) { strTimeStyle = 'Past';   nWhen = -1; }
				else if (msecDayDisplayStart > msecNow) { strTimeStyle = '_F'; nWhen =  1; }
				var strTDID    = '';
				if (nWhen == 0) { strTDID = 'id="cvTDIDToday"'; }
				var strTDClass = 'cvD_box';
				if (col == 0) 	{	strTDClass = 'cvD_boxL'; }
				if (col == 6) 	{	strTDClass = 'cvD_boxR';	}
				// cell height
				var nCurCellHeight = 0;
				// link to week view
				var strWeekLink = '';
				if ((col == 0) && fMonthView) { var iWeek = row+1; strWeekLink = '<div id="cvW_btn'+col+'"> <a class="btn" href="javascript:calReportChangeWeekView('+(iWeek)+')">view week</a></div>'; }
				// start cell
				var idCurCell = 'cvCell'+row+''+col;
				str += '<td valign="top" class="'+ strTDClass +'" '+strTDID+'><div id="'+idCurCell+'" style="position:relative;">';
				if ((iDay <= 0) || (iDay > nDayZ)) {
					// non-numbered day...just put space in it
					str += strWeekLink + '&nbsp;';
				} else {
					// numbered day
					
					// -- ADD DAY NUMBER
					var	strLinkTitle = 'Click to add an event on this day...';
					str += strWeekLink;
					str += '<div class="cvM_Dno_area">';
					if (fCanPost) {
						str += '<a class="cvM_Dno'+strTimeStyle+'" href="javascript:addEvent('+idTopic+','+iDay + ',' + nMonthA  + ',' + nYearA + ')" title="'+strLinkTitle+'">'+iDay+'</a>';
					} else {
						str += '<span class="cvM_Dno'+strTimeStyle+'">'+iDay+'</span>';;
					}
					str += '</div>';
					nCurCellHeight++;
					
					// -- START TABLE FOR EVENTS
					str += '<table cellspacing="0" cellpadding="0">';
					
					
					// -- CHECK ALL EVENTS EACH DAY...LIST THOSE THAT ARE IN PROGRESS THAT DAY
					for (var i = 0; i < nEvents; i++) {
						var aP = aCalEvents[i].split("|");
						var msecStart 		= parseInt(aP[21]);
						var msecEnd   		= parseInt(aP[22]);
						
						// -- IS IT AN EVENT FOR THIS DAY??
						//
						//		if eventStart <= displayDayEnd and eventEnd >= displayDayStart then display the day
						//		if eventStart *after* dayDisplayEnd...then we can stop looking through events as they are in date order
						//
						if (msecStart > msecDayDisplayEnd) {break;}
						
						if ((msecStart <= msecDayDisplayEnd) && (msecEnd >= msecDayDisplayStart)) {
						
							// -- GET ALL DATA FOR THIS EVENT
							var idEvent		 	= aP[0];
							var szTitle 		= aP[1];
							var szText 			= aP[2];
							var szLocation   	= aP[3];
							var EStart		 	= aP[4];
							var EFinish 		= aP[5];
							var szAuthor		= aP[6];
							var urlEmail		= aP[7];
							var urlWebsite		= aP[8];
							var idProduct		= aP[9];
							var strProdInfo		= aP[10];
							var nStartYear 		= aP[11];
							var nStartMonth 	= aP[12];
							var nStartDay 		= aP[13];
							var nStartHour		= aP[14];
							var nStartMinute	= aP[15];
							var nEndYear 		= aP[16];
							var nEndMonth 		= aP[17];
							var nEndDay 		= aP[18];
							var nEndHour		= aP[19];
							var nEndMinute		= aP[20];
							
							
							// -- TIME STRING
							//		1. if started today
							//			a: list start time
							//			b: if ends today, list end time
							//			c: else add " on"
							//		2. if started before today
							//			a: if ends today list "til <end time>"
							//			b: else list "all day"
							//		
							var strTime = "";
							var fAllDay = false;
							if ((msecStart >= msecDayDisplayStart) && (msecStart <= msecDayDisplayEnd)) { 
								// 	1. started today
								strTime += getTimeString(nStartHour, nStartMinute);
								if (msecEnd < msecDayDisplayEnd) {
									if ((nStartHour == 0) && (nStartMinute == 0) && (nEndHour == 23) && (nEndMinute == 59)) {
										 fAllDay = true; strTime = gstrCalAllDay; 
									} else { 
										var nMins = ((nEndHour-nStartHour) * 60) + (nEndMinute-nStartMinute) + 1;
										if (nMins == 2) {
											strTime += ' on';	
										}
										if (nMins > 5) {
											strTime += '-' + getTimeString(nEndHour, nEndMinute); 
										}
									}
									
				
				
								} else {
									if ((nStartHour == 0) && (nStartMinute == 0)) { fAllDay = true; strTime = gstrCalAllDay; }
									else { strTime += '-ongoing'; }
								}
								
							} else if (msecStart < msecDayDisplayStart) {
								// 	2. started before today
								if (msecEnd < msecDayDisplayEnd) {
									if ((nStartHour == 0) && (nStartMinute == 0) && (nEndHour == 23) && (nEndMinute == 59)) { fAllDay = true; strTime = gstrCalAllDay; }
									else { strTime += 'til ' + getTimeString(nEndHour, nEndMinute); }
								} else {
									fAllDay = true; 
									strTime += gstrCalAllDay;
								}
							}
							
				
							// -- ADD EVENT HTML
							str += '<tr>';
								// -- LEFT Column Icon
								if (fAllDay) {
									str += '<td class="cvD_box_icon_bar" valign="top" align="right">';
									str += '<img src="bits/icon-bigcal-allday.gif" width="8" height="8" alt="" border="0">';
									str += '</td>';
								} else {
									str += '<td class="cvD_box_icon" valign="top" align="right">';
									str += '<img src="bits/icon-bigcal-evt.gif" width="8" height="8" alt="" border="0">';
									str += '</td>';
								}
								// -- RIGHT Column Text
								//		1. time
								//		2. title
								//		3. location
								//		4. description
								//		5. group recipient(s)
								var	fNeedsDot = false;
								if (fAllDay) {
									str += '<td class="cvD_box_evt_bar" valign="top">';
								} else {
									str += '<td class="cvD_box_evt" valign="top">';								
								}

								//		1. time
								if (!fAllDay) {
									str += '<span class="cvM_Time'+strTimeStyle+'">'+strTime+'</span>';
									str += '<br>';
								}

								//		2. title
								str += '<span class="cvM_Title'+strTimeStyle+'">';
								str += '<a href="javascript:showEventPreview(\''+idCurCell+'\',aCalEvents,'+i+','+fCanPost+','+nStatusShow+')">'+szTitle+'</a>';
								str += '</span>';
								str += '<br>';

								nCurCellHeight += 2;
								
								//		4. text
								if ((fShowDescriptions == 1) && isNotEmpty(szText)) {
									if (fNeedsDot) { str += ' &middot; '; } 
									str += '<span class="cvM_Text'+strTimeStyle+'">';
										str += szText;
										if (isNotEmpty(szLocation)) { str += ' &middot; '+ szLocation; }
									str += '</span>';
									var cchText = szText.length;
									nCurCellHeight += parseInt(cchText / 20);
									fNeedsDot = true;
									//		3. location
								}
								str += '</td>';
							str += '</tr>';
							
						} // if event happens on this day
					} // for each event loop
					
					// -- INCREMENT DAY
					var nDayEnd = tDayDisplayStart.getDate();
					tDayDisplayStart.setDate(nDayEnd + 1);
					tDayDisplayEnd.setDate(nDayEnd + 2);
					msecDayDisplayStart = tDayDisplayStart.getTime();
					msecDayDisplayEnd 	= tDayDisplayEnd.getTime() - 1000;
				
					//	-- ADD EXTRA HEIGHT PADDING FOR THIS CELL IF NEEDED
					var nNeededCellHeight = nMinCellHeight - nCurCellHeight;
					for (var n = 1; n <= nNeededCellHeight; n++) {
						str += '<tr><td colspan="2" class="cvD_box_blank">&nbsp;</td></tr>';
					}

					// -- END TABLE FOR EVENTS
					str += '<tr><td colspan="2"><img src="spacer.gif" width="'+pxEventSpacer+'" height="1" alt="" border="0"></td></tr>';
					str += '</table>';
				
				}
				// -- END CELL FOR THIS DAY
				str += '</td>';
				iDay++;
			}
			// -- END ROW
			str += '</tr>';
		}
		// -- END CALENDAR
		str += '</table>';
		return str;
	}

	
	// ---------------------------------------------
	// showEventPreview
	// 		-- displays popup with events listed
	//		-- set of event ids and event list passed in

	function showEventPreview(idCurCell, aEventsAll, iEvent, fCanPost, nStatusShow) {
		// -- get events
		// 		new event array to fill with good events
		var nShown = 0;
		var strBigCalEvent = aEventsAll[iEvent];

		// -- build html
		var str = '';
		str += '<div id="ev_pop_x"><a href="javascript:hideEventPreview();"><img src="bits/x.gif" width="9" height="9" alt="" border="0"></a></div>';
		str += getBigCalEventHTML(strBigCalEvent, fCanPost, nStatusShow);
		//	-- insert html and show preview box in correct location
		var dom = getDOM('ev_pop_inner',0);
		dom.innerHTML = str;
		var domStyle = getDOM('ev_pop',1);
		var newTop = getTop(idCurCell) + 1;
		var newLeft = getLeft(idCurCell) + 1;
		if (newLeft > 570) { newLeft = 570; }
		domStyle.top 	= newTop+'px';
		domStyle.left 	= newLeft+'px';
		domStyle.visibility = 'visible';
	}
	function hideEventPreview() {
		var domStyle = getDOM('ev_pop',1);
		domStyle.visibility = 'hidden';		
	}

	function getBigCalEventHTML(strBigCalEvent, fCanPost, nStatusShow) {
		var str = ''; 	
		var aP = strBigCalEvent.split("|");
		var idEvent		 	= aP[0];
		var strTitle 		= aP[1];
		var strDescription	= aP[2];
		var strLocation   	= aP[3];
		var EStart		 	= aP[4];
		var EFinish 		= aP[5];
		var strAuthor		= aP[6];
		var strEmail		= aP[7];
		var urlWebsite		= aP[8];
		var idProduct		= aP[9];
		var strProdInfo		= aP[10];
		var nStartYear 		= aP[11];
		var nStartMonth 	= aP[12];
		var nStartDay 		= aP[13];
		var nStartHour		= aP[14];
		var nStartMinute	= aP[15];
		var nEndYear 		= aP[16];
		var nEndMonth 		= aP[17];
		var nEndDay 		= aP[18];
		var nEndHour		= aP[19];
		var nEndMinute		= aP[20];
		var nModifiedDays	= 0;
		
		// PRODUCT INFO
		var fProdOK  	= false;
		var strProdName = '';
		var strPPhoto  = '';
		if (idProduct > 0) { 
			var aPI = strProdInfo.split('::');
			fProdOK	 	= (parseInt(aPI[0]) > 0);
			strProdName = aPI[1];
			var strVNameURL	= scrubTitleForURL(strProdName);
			strPPhoto   = aPI[2];
		}

		// DATE
		var strEDate = getEventDateHTML(EStart, EFinish, 1);
		str += '<div class="ev_date">' + strEDate+ '</div>' ;
		
		// TITLE
		str += '<div class="ev_title">';
			if (fProdOK) { 
				str += '<a href="javascript:showProduct('+idProduct+',\''+strVNameURL+'\')">'+strTitle+'</a>';	
			} else {
				str += strTitle;
			}
		str += '</div>';
		
		// TEXT 
		str += '<div class="ev_text">';
			str += strDescription;
			if (isNotEmpty(strLocation)) { str += '<br><b>Location:</b> '+strLocation;	}
			if (fProdOK) { 
				str += '<br><b>More info:</b> <a class="ev_ftr" href="javascript:showProduct('+idProduct+',\''+strVNameURL+'\')">\"'+strProdName+'\"</a><br>';
			}
		str += '</div>';
		
		// FOOTER
		str += '<div class="ev_ftr">';
			var fShowDivider = false;
			// f1. byline
			str += 'by '+strAuthor;
			fShowDivider = true;
			// f1. email
			if (strEmail != "") {
				if (fShowDivider) { str += getFooterDivider(); }
				str += '<a class="ev_ftr" href="' + createMailString(strEmail) + '">email</a>';
				fShowDivider = true;
			}
			// f2. website
			if (urlWebsite != "") {
				if (fShowDivider) { str += getFooterDivider(); }
				str += '<a class="ev_ftr" ';
				str += getWebsiteHref(urlWebsite);
				str += '>website</a>';
				fShowDivider = true;
			} 
			if (fCanPost) {
				if (nStatusShow > 0) {
					// f3. plusview
					if (fShowDivider) { str += getFooterDivider(); }
					str += '<a class="ev_ftr" href="javascript:hideEventPreview();editEventPlus('+ idEvent + ')">edit</a>';
					fShowDivider = true;
					// f4. delete
					if (fShowDivider) { str += getFooterDivider(); }
					str += '<a class="ev_ftr" href="javascript:hideEventPreview();deleteEvent('+ idEvent + ')">del</a>';
					fShowDivider = true;
				} else {
					// undelete
					if (fShowDivider) { str += getFooterDivider(); }
					str += '<a class="ev_ftr" href="javascript:hideEventPreview();undeleteEvent('+ idEvent + ')">undelete</a>';
					fShowDivider = true;				
				}
			}
		str += '</div>';

		
		return(str);
	}
	

