<?
$login_custom_html = gluePath($sys['root'], "customizable/private/login_customization.html");
if (file_exists($login_custom_html)) {
	$customHTML = file_get_contents($login_custom_html);
}
echo $customHTML;
?>
<table border="0" cellpadding="0" cellspacing="0" height="90%" width="100%" style="width:100%;height:90%;">
<tr valign="middle" align="center">
	<td align="center">
	
<?
$customLogo = gluePath($sys['root'],"/customizable/public/login_logo.gif");
if (file_exists($customLogo)) {?>
<table cellspacing="0" cellpadding="0" border="0" width="300">
<tr>
	<td align="right">
	<img src="customizable/public/logo.gif" <?
$logoImageSize = @getImageSize($customLogo);
echo $logoImageSize[3];?> border="0" alt="">
	</td>
</tr>
</table>
<br>
<?}?>

<table cellspacing="0" cellpadding="0" border="0" width="300" height="150">
<tr id="popmenu-titlebar-afian_add_user">
    <td width="9" height="21"><img src="images/interface/popmenu/sp-titlebar-top-left.gif" width="9" height="21" alt="" border="0"></td>
    <td background="images/interface/popmenu/sp-titlebar-top-bg.gif" style="background-repeat:repeat-x;font-weight:bold" align="center"><?$lang->display("Welcome");?></td>
    <td width="11" height="21"><img src="images/interface/popmenu/sp-titlebar-top-right.gif" width="11" height="21" alt="" border="0"></td>
</tr>
<tr>
    <td width="9" height="5"><img src="images/interface/popmenu/sp-titlebar2-top-left.gif" width="9" height="5" alt="" border="0"></td>
    <td height="5" background="images/interface/popmenu/sp-titlebar2-top-bg.gif" style="background-repeat:repeat-x"><img src="images/interface/pixel.gif" width="1" height="5" border="0" alt=""></td>
    <td width="11" height="5"><img src="images/interface/popmenu/sp-titlebar2-top-right.gif" width="11" height="5" alt="" border="0"></td>
</tr>
<tr>
    <td width="9" background="images/interface/popmenu/sp-left.gif" style="background-repeat:repeat-y"><img src="images/interface/pixel.gif" width="9" height="1" border="0" alt=""></td>
    <td style="background-color:#E4E4E4;padding-left:20px;padding-right:20px;padding-top:10px" align="center">

<form action="./" method="post" name="loginForm">
<table>
<tr>
	<td><?$lang->display("Username");?></td>
<td>
<input type="text" name="username" value="<?echo $_POST['username']?>" style="width:120px" tabindex="1" onkeydown="if(event.keyCode == 13){document.loginForm.submit();}">
</td>
</tr>
<tr>
	<td><?$lang->display("Password");?></td><td><input type="password" name="password" value="" style="width:120px" tabindex="2" onkeydown="if(event.keyCode == 13){document.loginForm.submit();}"></td>
</tr>

</table>
<input type="hidden" name="language" value="english">
<input type="hidden" name="login" value="1">

<script>
document.loginForm.username.focus();
</script>
</td>
    <td width="11" background="images/interface/popmenu/sp-right.gif" style="background-repeat:repeat-y"><img src="images/interface/pixel.gif" width="9" height="1" border="0" alt=""></td>
</tr>
<tr>
    <td width="9" height="44"><img src="images/interface/popmenu/sp-bottom-left.gif" width="9" height="44" alt="" border="0"></td>
    <td height="44" background="images/interface/popmenu/sp-bottom-bg.gif" style="background-repeat:repeat-x" align="center">
<?
$tpl->btn(
$lang->get("Login"), 
$onclick="document.loginForm.submit()",
false,
false,
"tabindex=\"4\""
)
?>
</td>
    <td width="11" height="44"><img src="images/interface/popmenu/sp-bottom-right.gif" width="11" height="44" alt="" border="0"></td>
</tr>
</table>
</form>
<?
	$msg = "";
	if ($_POST['login'] && $_POST['username'] == "") {
		$msg = $lang->get("Please enter a username.");
		$statusBarMessage[] = array($msg, 0);
	} elseif ($loginResult == "nouser") {
		$msg = $lang->get("Invalid login.");
		$statusBarMessage[] = array($msg, 0);
	} elseif ($loginResult == "wrongpass") {
		$msg = $lang->get("Invalid login.");
		$statusBarMessage[] = array($msg, 0);
	} elseif ($loginResult == "suspend" || $auth->errorCode == "14") {
		$msg = "<span class=\"nowrap\">".$lang->get("Your account is temporarily suspended.")."</span>";
		$statusBarMessage[] = array($msg, 0);
	} elseif ($loginResult == "afiansuspend") {
		$msg = "<span class=\"nowrap\">".$lang->get("Access to files is temporarily suspended.")."</span>";
		$statusBarMessage[] = array($msg, 0);
	} else {
		/*
		if (!$_COOKIE["notFirstVisit"]) {
		$msg = "<div style=\"text-align:left;width:400px\">&nbsp;&nbsp;&nbsp;Please note that this software does not work like a common web site, it is more like a desktop application.<br>&nbsp;&nbsp;&nbsp;It takes a couple of seconds more to load but does not reload for every action you do.</div>";
		$statusBarMessage[] = array($msg, 0);
		setcookie("notFirstVisit", "1");
		}
		*/
	}

	if ($_GET['msg'] == "3") {
		$msg = $lang->get("Your account is misconfigured.<br>Please contact the administrator.");
		$statusBarMessage[] = array($msg, 0);
	}
	
	if ($_GET['msg'] == "2") {
		$msg = "<span class=\"nowrap\">".$lang->get("Access to %1 is temporarily suspended.",  array(($sys['license']['unbranded']?$sys['license']['unbranded']:"Afian")))."</span>";
		$statusBarMessage[] = array($msg, 0);
	}
	
	if ($_GET['logout']) {
		$msg = $lang->get("You were successfuly logged out.");
		$statusBarMessage[] = array($msg, 0);
	}
	
	if ($auth->errorCode == "13" && !$_POST['login']) {
		$msg = $lang->get("Your password is no longer valid.");
		$statusBarMessage[] = array($msg, 0);
		$msg = $lang->get("Please re-login.");
		$statusBarMessage[] = array($msg, 0);
	}
?>

	</td>
</tr>
<tr valign="middle" align="center">
	<td align="center" height="8%">
	&nbsp;
	</td>
</tr>
</table>
<script>
preloadStupidMSIEElementsPosition();
</script>

<br>
<br>
<?$tpl->status2Popup($statusBarMessage);?>

<script>
buttonize();
</script>