{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<SCRIPT type="text/javascript">
<!--
function addaccount()
{
	document.aliasadd.action += '&addaccount=1';
	document.aliasadd.submit();
}

function delaccount(id)
{
	document.aliasadd.action += '&delaccount=' + id;
	document.aliasadd.submit();
}
function addmailforward()
{
	document.aliasadd.action += '&addmailforward=1';
	document.aliasadd.submit();
}

function delmailforward(mailforward)
{
	document.aliasadd.action += '&delmailforward=' + mailforward;
	document.aliasadd.submit();
}

function togglelogin()
{
	document.aliasadd.login.disabled =
		!document.aliasadd.login.disabled;
}
//-->
</SCRIPT>
<H1>{$layout.pagetitle}</H1>
<FORM name="aliasadd" method="POST" action="?m=aliasadd">
<INPUT type="submit" class="hiddenbtn">
<TABLE class="lmsbox">
    <THEAD>
	<TR>
		<TD width="1%">
			<IMG src="img/alias.gif" alt="">
		</TD>
		<TD width="1%">
			<B>{trans("Login:")}</B>
		</TD>
		<TD width="98%">
			<INPUT type="text" name="alias[login]" id="login" value="{$alias.login}" required {tip text="Enter alias name" trigger="login"} size="20" {if $alias.domainalias}disabled{/if}>
			<INPUT type="checkbox" name="alias[domainalias]" id="domainalias" value="" onchange="togglelogin()" {if $alias.domainalias}checked{/if}><label for="domainalias">{trans("domain alias")}</label>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR>
		<TD width="1%">
			<IMG src="img/domain.gif" alt="">
		</TD>
		<TD width="1%">
			<B>{trans("Domain:")}</B>
		</TD>
		<TD width="98%">
			<select name="alias[domainid]" {tip text="Select domain name" trigger="domainid"}>
				<option value="0" {if !$alias.domainid}SELECTED{/if}>{trans("— select domain —")}</option>
    				{foreach from=$domainlist item=item}
				<option value="{$item.id}"{if $item.id == $alias.domainid} SELECTED{/if}>{$item.name}</option>
	    			{/foreach}
			</select>
		</TD>
	</TR>
	<TR>
		<TD width="1%">
			<IMG src="img/account.gif" alt="">
		</TD>
		<TD width="1%">
			<B>{trans("Destination:")}</B>
		</TD>
		<TD width="98%">
			{foreach from=$alias.accounts item=account}
			{$account.login}@{$account.domain}
			<A href="javascript:delaccount({$account.id})"><IMG src="img/delete.gif" alt="" {tip text="Delete"}></A><BR>
			{/foreach}
			<SELECT size="1" name="alias[accountid]" {tip text="Select account" trigger="accountid"}>
				<OPTION value="0"{if !$alias.accountid} SELECTED{/if}>{trans("— select account —")}</OPTION>
				{foreach from=$accountlist item=item}
				<OPTION value="{$item.id}"{if $item.id == $alias.accountid} SELECTED{/if}>{$item.login}@{$item.domain}</OPTION>
				{/foreach}
			</SELECT>
			<A href="javascript:addaccount()"><IMG src="img/add.gif" alt="" {tip text="Add"}></A>
		</TD>
	</TR>
	<TR>
		<TD width="1%">
			<IMG src="img/forward.gif" alt="">
		</TD>
		<TD width="1%" NOWRAP>
			<B>{trans("Forward e-mail:")}</B>
		</TD>
		<TD width="98%">
			{foreach from=$alias.mailforwards item=mailforward}
			{$mailforward}
			<A href="javascript:delmailforward('{$mailforward}')"><IMG src="img/delete.gif" alt="" {tip text="Delete"}></A><BR>
			{/foreach}
			<INPUT type="text" name="alias[mailforward]" value="" {tip text="Enter destination e-mail address for redirect (optional)" trigger="mailforward"} size="25">
			<A href="javascript:addmailforward()"><IMG src="img/add.gif" alt="" {tip text="Add"}></A>
		</TD>
	</TR>
	<TR>
		<TD colspan="3" align="right" nowrap>
			<A href="javascript: document.aliasadd.submit();" accesskey="s">{trans("Submit")} <IMG SRC="img/save.gif" ALT=""></A>
			<A href="?m=aliaslist">{trans("Cancel")} <IMG SRC="img/cancel.gif" ALT=""></A><BR>
			<INPUT type="checkbox" name="alias[reuse]" id="alias_reuse" value="ON" {if $alias.reuse}checked{/if}> <label for="alias_reuse">{trans("Display this form again, when this alias is saved")}</label>
		</TD>
	</TR>
    </TBODY>
</TABLE>
</FORM>
<SCRIPT type="text/javascript">
<!--//
$(function() {
	$('form[name="aliasadd"] [name="alias[login]"]').focus();
});
//-->
</SCRIPT>
{/block}
