{extends file=$smarty.const.SMARTY_LAYOUT_MAIN}

{block name="template-head"}

	{$JS->loadGroup("base", [ 'defer'=>false ])}
	{$CSS->loadGroup("base")}

	{$JS->loadGroup("inputs", [ 'defer'=>false ])}
	{$CSS->loadGroup("inputs")}

	{$CSS->loadGroup("auth")}
	{$JS->loadGroup("auth")}

	{$CSS->render()}
	{$JS->render()}
{/block}

{* For login page  don't display menu and logout button *}
{block name="menu"}{/block}

{block name="body-declaration-class"}login{/block}

{block name="content"}
	<div id="pageContent">
		<div class="app-info-container">
			<img class="logo" alt="" src="{$smarty.const.SMARTY_BLANKGIF}" />

			<h2>Welcome to <span>{$smarty.const.APP_NAME}</span></h2>
			<h3>Version <span>{$smarty.const.APP_VERSION_NUMBER}.{$smarty.const.APP_VERSION_BUILD}</span></h3>
		</div>

		{block name="formContainer"}
			<div class="form-container">
				<form name="form_" id="form_01" class="form" enctype="multipart/form-data" method="POST" action="{appUrl module='Modules/Authenticate'}">
					<div class="formField-container-auth">
						{$fieldset->render()}

						{block name="formContainer_post"}
							<table>
								<tr>
									<td>
										&nbsp;
									</td>
									<td class="language">
										{input type="Engine\Form\Input\Select" disabled=$dontRenderForm possibleValues=$appLanguages name="lang" value=$currentLanguage}
									</td>
								</tr>
							</table>
						{/block}

						<button type="submit" {if $dontRenderForm or !$loginWithPassword}disabled="disabled"{/if}>{$lang['loginButton']}</button>
					</div>
				</form>
					{if $azureConfigured}
						<div class="formField-container-auth" style="margin-top: 20px;">
							<button type="submit" style="margin-top: 20px;" 
								{if $loginWithAzure}
									onclick = "window.location =  MVC.appUrl('Authenticate/Providers/Azure', 'index')"
								{else}
									disabled="1"
								{/if}
							>{$lang['loginAzure']}</button>
						</div>
					{/if}
			</div>
		{/block}

		<div class="copyright">&copy; <span class="years">2004-{$smarty.const.TODAY_YEAR}</span> <a class="company" href="http://dcsplus.net/">dcs plus</a></div>

	</div>
{/block}


{block name="js" append}
	<script type="text/javascript">
		if (window!=window.top) {
			window.top.location = MVC.appUrl("Authenticate", "logout", { });
		}

		MVC.scheduleOnLoad(function() {
			{block name="formScripts"}
				var input = $('form_01').select('input').first();
				input.focus();

				$('lang').observe('change', function(event){
					window.location = MVC.appUrl(MVC.CURRENT_MODULE, MVC.CURRENT_ACTION, { 'lang': $F('lang') });
					$('lang').disable();
					$('lang').up('form').select('button').each(function(btn) {
						btn.disable();
					});
				});

				setTimeout(function (input) {
					input.select();
				}.bind(null, input), 50);
			{/block}
		});
	</script>
{/block}
