<div id="actions" class="offset_toolbar Toolbar<?php echo $this->viewType; ?>">
	<ul id="for_calendar_view_control">
		<li id="action_view_today" title="<?php echo $this->translate('Today')?>"><a href="#"><span><strong><?php echo $this->translate('Today')?></strong></span></a></li>
		<li <?php echo ($this->viewType == "Day" ? "class='enabled'" : ""); ?> id="action_view_day" title="<?php echo $this->translate('Day')?>"><a href="#"><span><strong><?php echo $this->translate('Day')?></strong></span></a></li>
		<li <?php echo ($this->viewType == "Week" ? "class='enabled'" : ""); ?> id="action_view_week" title="<?php echo $this->translate('Week')?>"><a href="#"><span><strong><?php echo $this->translate('Week')?></strong></span></a></li>
		<li <?php echo ($this->viewType == "Month" ? "class='enabled'" : ""); ?> id="action_view_month" title="<?php echo $this->translate('Month')?>"><a href="#"><span><strong><?php echo $this->translate('Month')?></strong></span></a></li>
		<li id="action_refresh" title="<?php echo $this->translate('Refresh')?>"><a href="#"><span><strong><?php echo $this->translate('Refresh')?></strong></span></a></li>
		<li id="action_view_sync" title="<?php echo $this->translate('Sync')?>"><a href="#"><span><strong><?php echo $this->translate('Sync')?></strong></span></a></li>
	</ul>
</div>

<div id="secondary" class="mainLayoutLeft mainLayoutLeft<?php echo $this->viewType; ?>View">
	<div id="mainLayoutLeftInnerTop">
		<div id="displayDate" style="display:none;">
			<div id="displayDateImg">&nbsp;</div>
			<div id="displayDateText">&nbsp;</div>
		</div>
		<div id="datePicker" class="datePicker<?php echo $this->viewType; ?>View">
			<div id="datePickerPadding">
				<div id="miniCalendar">			
				</div>
			</div>
		</div>
	</div>
	<div id="dateMonthPicker">
		<div id="monthSelectorBox"></div>
	</div>
	<ul id="folder_actions" style="z-index:100;">
		<li id="folder_add" disabled="true" style="opacity: 0.4;" title='<?php print $this->translate('New Calendar')?>'><a><?php print $this->translate('Calendar Folder')?></a></li>
		<li id="folder_remove" disabled="true" style="opacity: 0.4;" title='<?php print $this->translate('Delete Calendar')?>'><a class="enabled"><?php print $this->translate('Calendar Folder')?></a></li>
		<li id="folder_color" disabled="true" style="opacity: 0.4;" title='<?php print $this->translate('Calendar Color')?>'><a class="enabled"><?php print $this->translate('Calendar Color')?></a></li>
		<li id="folder_options" disabled="true" style="opacity: 0.4;" title='<?php print $this->translate('Calendar Options')?>'><a class="enabled"><?php print $this->translate('Calendar Options')?></a></li>
		<li id="error" style="display:none"><a><?php print $this->translate('Error')?></a></li>
	</ul>
	<div id="mainLayoutLeftInnerBottom">
		<div id="calendarPicker" class="calendarPicker<?php echo $this->viewType; ?>View">
			<div id="calendarList">				
			</div>
		</div>
		<div id="eventsListBox">
		</div>
	</div>
</div>

<div id="primary">
	<div id="primary_content" class="mainLayoutRight mainLayoutRight<?php echo $this->viewType; ?>View">
		<div id="Flash" style="position:absolute"></div>
		<div id="primary_content_inner_cal">
			<div id="calendarInside">
				<div id='loading-text'><span class='loading'></span></div>
			</div>
		</div>
	</div>
</div>

<div id="colourPickerBG">
	<div id="colourPickerItem" color="#00bf02">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #00bf02;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#bf0000">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #bf0000;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#FF8300">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #FF8300;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#00bfbf">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #00bfbf;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#bf00bd">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #bf00bd;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#0002bf">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #0002bf;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#4d4d4d">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #4d4d4d;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#64DF64">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #64DF64;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#ff8080">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #ff8080;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#FFA240">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #FFA240;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#38DFDF">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #38DFDF;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#ff80fe">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #ff80fe;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#8081ff">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #8081ff;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
	<div id="colourPickerItem" color="#A6A6A6">
		<div class="checkboxHolder">
			<div class="checkboxBackground" style="background-color: #A6A6A6;"></div>
			<div class="checkboxFrame"></div>
		</div>
	</div>
</div>


<script type="text/javascript">
	function newEvent()
	{
		startDate = new Date();
		endDate = new Date();
		current_local_offset = new Date();
		current_local_offset = current_local_offset.getTimezoneOffset();
		startDateUTC = new Date(+startDate - (current_local_offset * 60 * 1000));
		endDateUTC = new Date(+endDate - (current_local_offset * 60 * 1000));
		$.ajax({
			async: false,
			type: "POST",
			url: "<?php echo rtrim($this->siteBaseUrl, '/'); ?>/index.php/mail/calendar/caldavglue",
			dataType: "json",
			data:
			{
				'func' : 'add',
				'json' : 1,
				'ajax' : 1,
				'relative_href' : getCalendarData("relative_href"),
				'Location' : '',
				'Msg_Text' : '',
				'Msg_Title' : jsTranslate('New Event'),
				'Msg_Type' : jsTranslate('General'),
				'appmode' : jsTranslate('Private'),
				'startDate' : Math.round(startDateUTC.getTime() / 1000),
				'endDate' : Math.round(endDateUTC.getTime() / 1000),
				'AllDayEvent' : ((true) ? 1 : "")
			},
			success: function(json)
			{
				if(json.status != 201)
				{
					$("#calendarInside", '#Calendar').fullCalendar("unselect");
					$.simpleFlash(jsTranslate("An error occured creating the event."), 'error');
					return;
				}

				$("#miniCalendar", '#Calendar').monthCal("addEventHint", startDateUTC, 1);
				$("#miniCalendar", '#Calendar').monthCal("renderEventHints");
				$("#calendarInside", '#Calendar').fullCalendar("unselect");
				$("#calendarInside", '#Calendar').fullCalendar("renderEvent",
					{
						id: json["id"],
						title: jsTranslate("New Event"),
						start: Math.round(startDate.getTime() / 1000),
						end: Math.round(endDate.getTime() / 1000),
						"allDay": true,
						color: getCalendarData("color"),
						relative_href: getCalendarData("relative_href"),
						source: com.atmail.calendar.baseUrl + "/index.php/mail/calendar/caldavglue?ajax=1&func=ajaxcal&json=1&calendarhref=" + getCalendarData("relative_href")
					});
				$("#eventsListBox", '#Calendar').data('quickview').refresh({refreshAll: true});
				//setTimeout(function() { $("#" + json["id"] + ":first a", '#Calendar').trigger('click'); }, 250);
			}
		});
	}

	$(function(){
		disableAction('all');

		window.setTimeout(function() {
            var client_tz = '<?php $tt = new DateTimeZone(date_default_timezone_get()); echo ($tt->getOffset(new DateTime("now")) / 3600); ?>';
			startCalendar("<?php echo rtrim($this->siteBaseUrl, '/'); ?>", "<?php echo ($this->viewType); ?>", client_tz, "<?php echo ($this->owner_username); ?>");

			/*var tzo=(new Date().getTimezoneOffset()/60)*(-1);
			if(tzo != client_tz)
			{
				timezoneIncorrectDisplay(tzo, client_tz);
			}*/
		}, 0);

		$('#mainLayoutLeftInnerBottom').bind('click', function(e) {
			if( $("#colourPickerBG", '#Calendar').is(':visible')) {
				$("#colourPickerBG", '#Calendar').hide();				
			}
		})

	});
	
</script>
