{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
	<!--// $Id$ //-->
	<h1>{$layout.pagetitle}</h1>
	<div id="lms-ui-welcome-boxes">
		<div id="lms-ui-welcome-main-panels">
			<div id="lms-ui-welcome-panel-1" class="lms-ui-welcome-main-panel">
				{block name="welcome-left-panel"}
					{if empty($welcome_visible_panels) || isset($welcome_visible_panels.appinfo)}
						{include file="welcome/welcome_sysinfo_about_lms.html"}
					{/if}
					{if empty($welcome_visible_panels) || isset($welcome_visible_panels.customers)}
						{include file="welcome/welcome_sysinfo_customers.html"}
					{/if}
					{if empty($welcome_visible_panels) || isset($welcome_visible_panels.helpdesk)}
						{include file="welcome/welcome_sysinfo_rtstats.html"}
					{/if}
				{/block}
			</div>
			<div id="lms-ui-welcome-panel-2" class="lms-ui-welcome-main-panel">
				{block name="welcome-right-panel"}
					{if empty($welcome_visible_panels) || isset($welcome_visible_panels.sysinfo)}
						{include file="welcome/welcome_sysinfo_about_system.html"}
					{/if}
					{if empty($welcome_visible_panels) || isset($welcome_visible_panels.nodes)}
						{include file="welcome/welcome_summaries.html"}
					{/if}
					{if empty($welcome_visible_panels) || isset($welcome_visible_panels.links)}
						{include file="welcome/welcome_links.html"}
					{/if}
					{if empty($welcome_visible_panels) || isset($welcome_visible_panels.reginfo)}
						{include file="welcome/welcome_registration.html"}
					{/if}
				{/block}
			</div>
			{for $panel=3 to intval(ConfigHelper::getConfig('phpui.welcome_panels', 2))}
				<div id="lms-ui-welcome-panel-{$panel}" class="lms-ui-welcome-main-panel">
				</div>
			{/for}
		</div>
		<div id="lms-ui-welcome-extra-panel">
			{block name="extra-panel"}
			{/block}
		</div>
		{if !ConfigHelper::checkConfig('phpui.hide_fortunes')}
			<div id="lms-ui-welcome-bottom-panel">
				{block name="fortune-panel"}
					{if $layout.fortune}
						<div id="fortune" class="cf fall superlight" style="padding: 10px;">
							<img src="img/totd.gif" alt="Fortune" class="lf" style="margin-right: 10px;">
							<p class="txt">{$layout.fortune|replace:"\n":"<br>"}</p>
						</div>
					{/if}
				{/block}
			</div>
		{/if}
	</div>
	<script>

		function markEmptyPanels() {
			$('.lms-ui-welcome-main-panel').addClass('empty').each(function() {
				if ($(this).children('table,div').length) {
					$(this).removeClass('empty');
				}
			});
		}

		$('.lms-ui-welcome-main-panel').sortable({
			connectWith: '.lms-ui-welcome-main-panel',
			items: "> table",
			handle: "thead tr",
			placeholder: {
				element: function(currentItem) {
					return $('<div class="lms-ui-welcome-box-placeholder"></div>')[0];
				},
				update: function(container, p) {
					return;
				}
			},
			update: function(event, ui) {
				var panels = {};
				if (!ui.sender) {
					$('.lms-ui-welcome-main-panel').each(function() {
						panels[$(this).attr('id')] = $(this).sortable('toArray').join(';');
					});
					savePersistentSettings( { 'welcome-sortable-order': panels } );
					markEmptyPanels();
				}
			}
		});

		restoreSortable('lms-ui-welcome-main-panels', JSON.parse('{$welcome_sortable_order}'));

		markEmptyPanels();
	</script>
	{if isset($newer_version) && $newer_version}
		<script>
			alertDialog($t("There is newer version of LMS ($a) available for download from $b.",'{$newer_version}', 'http://lms.org.pl/download'));
		</script>
	{/if}
{/block}
