$this->print_link);
		echo JemOutput::createButtonBar($this->getName(), $this->permissions, $btn_params);
		?>
	
	params->get('show_page_heading', 1)): ?>
		
			escape($this->params->get('page_heading')); ?>
		
	
	params->get('showintrotext')) : ?>
		
			params->get('introtext'); ?>
		
		 
	
	params->get('daylimit', 10);
	$evbg_usecatcolor = $this->params->get('eventbg_usecatcolor', 0);
	$showtime = $this->settings->get('global_show_timedetails', 1);
	foreach ($this->rows as $row) :
		if (!JemHelper::isValidDate($row->dates)) {
			continue; // skip, open date !
		}
		//get event date
		$year = strftime('%Y', strtotime($row->dates));
		$month = strftime('%m', strtotime($row->dates));
		$day = strftime('%d', strtotime($row->dates));
		@$countperday[$year.$month.$day]++;
		if ($countperday[$year.$month.$day] == $limit+1) {
			$var1a = JRoute::_('index.php?option=com_jem&view=day&id='.$year.$month.$day . $this->param_topcat);
			$var1b = JText::_('COM_JEM_AND_MORE');
			$var1c = "".$var1b."";
			$id = 'eventandmore';
			$this->cal->setEventContent($year, $month, $day, $var1c, null, $id);
			continue;
		} elseif ($countperday[$year.$month.$day] > $limit+1) {
			continue;
		}
		//for time in tooltip
		$timehtml = '';
		if ($showtime) {
			$start = JemOutput::formattime($row->times);
			$end = JemOutput::formattime($row->endtimes);
			if ($start != '') {
				$timehtml = ''.JText::_('COM_JEM_TIME_SHORT').': ';
				$timehtml .= $start;
				if ($end != '') {
					$timehtml .= ' - '.$end;
				}
				$timehtml .= '
';
			}
		}
		$eventname  = ''.JText::_('COM_JEM_TITLE_SHORT').': '.$this->escape($row->title).'
';
		$detaillink = JRoute::_(JemHelperRoute::getEventRoute($row->slug));
		//initialize variables
		$multicatname = '';
		$colorpic = '';
		$nr = is_array($row->categories) ? count($row->categories) : 0;
		$ix = 0;
		$content = '';
		$contentend = '';
		$catcolor = array();
		//walk through categories assigned to an event
		foreach((array)$row->categories AS $category) {
			//Currently only one id possible...so simply just pick one up...
			$detaillink = JRoute::_(JemHelperRoute::getEventRoute($row->slug));
			//wrap a div for each category around the event for show hide toggler
			$content    .= '';
			$contentend .= '
';
			//attach category color if any in front of the catname
			if ($category->color) {
				$multicatname .= ' '.$category->catname;
			} else {
				$multicatname .= $category->catname;
			}
			$ix++;
			if ($ix != $nr) {
				$multicatname .= ', ';
			}
			//attach category color if any in front of the event title in the calendar overview
			if (isset($category->color) && $category->color) {
				$colorpic .= '';
				$catcolor[$category->color] = $category->color; // we need to list all different colors of this event
			}
			//count occurence of the category
			if (!isset($row->multi) || ($row->multi == 'first')) {
				if (!array_key_exists($category->id, $countcatevents)) {
					$countcatevents[$category->id] = 1;
				} else {
					$countcatevents[$category->id]++;
				}
			}
		}
		$color  = '';
		$color .= $colorpic;
		$color .= '
';
		// multiday
		$multi_mode = 0; // single day
		$multi_icon = '';
		if (isset($row->multi)) {
			switch ($row->multi) {
			case 'first': // first day
				$multi_mode = 1;
				$multi_icon = JHtml::_("image","com_jem/arrow-left.png",'', NULL, true);
				break;
			case 'middle': // middle day
				$multi_mode = 2;
				$multi_icon = JHtml::_("image","com_jem/arrow-middle.png",'', NULL, true);
				break;
			case 'zlast': // last day
				$multi_mode = 3;
				$multi_icon = JHtml::_("image","com_jem/arrow-right.png",'', NULL, true);
				break;
			}
		}
		//for time in calendar
		$timetp = '';
		if ($showtime) {
			$start = JemOutput::formattime($row->times,'',false);
			$end   = JemOutput::formattime($row->endtimes,'',false);
			switch ($multi_mode) {
			case 1:
				$timetp .= $multi_icon . ' ' . $start . '
';
				break;
			case 2:
				$timetp .= $multi_icon . '
';
				break;
			case 3:
				$timetp .= $multi_icon . ' ' . $end . '
';
				break;
			default:
				if ($start != '') {
					$timetp .= $start;
					if ($end != '') {
						$timetp .= ' - '.$end;
					}
					$timetp .= '
';
				}
				break;
			}
		} else {
			if (!empty($multi_icon)) {
				$timetp .= $multi_icon . ' ';
			}
		}
		$catname = ''.$multicatname.'
';
		$eventdate = !empty($row->multistartdate) ? JemOutput::formatdate($row->multistartdate) : JemOutput::formatdate($row->dates);
		if (!empty($row->multienddate)) {
			$eventdate .= ' - ' . JemOutput::formatdate($row->multienddate);
		} else if ($row->enddates && $row->dates < $row->enddates) {
			$eventdate .= ' - ' . JemOutput::formatdate($row->enddates);
		}
		//venue
		if ($this->jemsettings->showlocate == 1) {
			$venue  = ''.JText::_('COM_JEM_VENUE_SHORT').': ';
			$venue .=     !empty($row->venue) ? $this->escape($row->venue) : '-';
			$venue .= '
';
		} else {
			$venue = '';
		}
		// state if unpublished
		$statusicon = '';
		if (isset($row->published) && ($row->published != 1)) {
			$statusicon  = JemOutput::publishstateicon($row);
			$eventstate  = ''.JText::_('JSTATUS').': ';
			switch ($row->published) {
			case  1: $eventstate .= JText::_('JPUBLISHED');   break;
			case  0: $eventstate .= JText::_('JUNPUBLISHED'); break;
			case  2: $eventstate .= JText::_('JARCHIVED');    break;
			case -2: $eventstate .= JText::_('JTRASHED');     break;
			}
			$eventstate .= '
';
		} else {
			$eventstate  = '';
		}
		//date in tooltip
		$multidaydate = ''.JText::_('COM_JEM_DATE').': ';
		switch ($multi_mode) {
		case 1:  // first day
			$multidaydate .= JemOutput::formatShortDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $showtime);
			$multidaydate .= JemOutput::formatSchemaOrgDateTime($row->dates, $row->times, $row->enddates, $row->endtimes);
			break;
		case 2:  // middle day
			$multidaydate .= JemOutput::formatShortDateTime($row->multistartdate, $row->times, $row->multienddate, $row->endtimes, $showtime);
			$multidaydate .= JemOutput::formatSchemaOrgDateTime($row->multistartdate, $row->times, $row->multienddate, $row->endtimes);
			break;
		case 3:  // last day
			$multidaydate .= JemOutput::formatShortDateTime($row->multistartdate, $row->times, $row->multienddate, $row->endtimes, $showtime);
			$multidaydate .= JemOutput::formatSchemaOrgDateTime($row->multistartdate, $row->times, $row->multienddate, $row->endtimes);
			break;
		default: // single day
			$multidaydate .= JemOutput::formatShortDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $showtime);
			$multidaydate .= JemOutput::formatSchemaOrgDateTime($row->dates, $row->times, $row->enddates, $row->endtimes);
			break;
		}
		$multidaydate .= '
';
		//create little Edit and/or Copy icon on top right corner of event if user is allowed to edit and/or create
		$editicon = '';
		if (!$this->print) {
			$btns = array();
			if ($this->params->get('show_editevent_icon', 0) && $row->params->get('access-edit', false)) {
				$btns[] = JemOutput::editbutton($row, null, null, true, 'editevent');
			}
			if ($this->params->get('show_copyevent_icon', 0) && $this->permissions->canAddEvent) {
				$btns[] = JemOutput::copybutton($row, null, null, true, 'editevent');
			}
			if (!empty($btns)) {
				$editicon .= '';
				$editicon .= join(' ', $btns);
				$editicon .= '
';
			}
		}
		//generate the output
		// if we have exact one color from categories we can use this as background color of event
		if (!empty($evbg_usecatcolor) && (count($catcolor) == 1)) {
			$content .= '';
			$content .= $editicon;
			$content .= JemHelper::caltooltip($catname.$eventname.$timehtml.$venue.$eventstate, $eventdate, $row->title . $statusicon, $detaillink, 'editlinktip hasTip', $timetp, $category->color);
			$content .= $contentend . '
';
		} else {
			$content .= '' . $colorpic;
			$content .= $editicon;
			$content .= JemHelper::caltooltip($catname.$eventname.$timehtml.$venue.$eventstate, $eventdate, $row->title . $statusicon, $detaillink, 'editlinktip hasTip', $timetp, $category->color);
			$content .= $contentend . '
';
		}
		$this->cal->setEventContent($year, $month, $day, $content);
	endforeach;
	// enable little icon right beside day number to allow event creation
	if (!$this->print && $this->params->get('show_addevent_icon', 0) && !empty($this->permissions->canAddEvent)) {
		$html = JemOutput::prepareAddEventButton();
		$this->cal->enableNewEventLinks($html);
	}
	$displayLegend = (int)$this->params->get('displayLegend', 1);
	if ($displayLegend == 2) : ?>
	
	
	
		
		
	
		
			params->get('displayLegend')) {
				##############
				## FOR EACH ##
				##############
				$counter = array();
				# walk through events
				foreach ($this->rows as $row) {
					foreach ($row->categories as $cat) {
						# sort out dupes for the counter (catid-legend)
						if (!in_array($cat->id, $counter)) {
							# add cat id to cat counter
							$counter[] = $cat->id;
							# build legend
							if (array_key_exists($cat->id, $countcatevents)) {
							?>
								
									color) && $cat->color) {
										echo '';
									}
									echo $cat->catname.' ('.$countcatevents[$cat->id].')';
									?>
								
							
		 
	
	cal->showMonth();
	?>
	
	
	
	
		
		
	
		
			rows as $row) {
					foreach ($row->categories as $cat) {
						# sort out dupes for the counter (catid-legend)
						if (!in_array($cat->id, $counter)) {
							# add cat id to cat counter
							$counter[] = $cat->id;
							# build legend
							if (array_key_exists($cat->id, $countcatevents)) {
							?>
								
									color) && $cat->color) {
										echo '';
									}
									echo $cat->catname.' ('.$countcatevents[$cat->id].')';
									?>