<div class="actionPanelLeft">
	<div class="actionPanelRight p16">
		<div id="actionTop" class="right">
			<div class="button actionSave">
				<div class="buttonRight">
					<div class="buttonMiddle">{rs:ACTION_SAVE}</div>
				</div>
			</div>

			<div class="button actionCancel">
				<div class="buttonRight">
					<div class="buttonMiddle">{rs:ACTION_CANCEL}</div>
				</div>
			</div>

			<div class="button actionBack">
				<div class="buttonRight">
					<div class="buttonMiddle">{rs:ACTION_BACK} {rs:TITLE_USERS}</div>
				</div>
			</div>

			<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="1" border="0" /></div>
		</div>
	</div>
</div>
<div class="middleLeft">
	<div class="middleRight p16">
		<script language="JavaScript" src="{global:PATH}js/checking.js"></script>

		{MESSAGE}
		{ERROR}
		<form method="post" id="editForm">
		<table width="100%" cellspacing="0" cellpadding="5" border="0" class="permission">
		<tr class="header">
		<td>{rs:MODULES}/{rs:PERMISSION}</td>
		{row:PERMISSIONS}
		<td align="center">{title}</td>
		{/row}
		</tr>

		{row:LINE}
		<tr class="line">
		<td>{module}</td>
		{line}
		</tr>
		{/row}

		<tr class="line">
		<td><b>{rs:SELECT_ALL}</b></td>
		{row:PERMISSIONS}
		<td align="center"><input type="checkbox" name="all[{p_id}]" value=""></td>
		{/row}
		</tr>

		<tr>
		<td><img src="{global:PATH}img/spacer.gif" width="200" height="10" border="0"></td>
		{row:PERMISSIONS}
		<td><img src="{global:PATH}img/spacer.gif" width="70" height="10" border="0"></td>
		{/row}
		</tr>
		</table>

		<table width="100%" cellspacing="0" cellpadding="5" border="0" class="permission">
		<tr class="header">
		<td>{rs:NEWSLETTER_PERMISSION}</td>
		<td>
			<div class="mini_menu" id="newsletters_type">
				<div class="item">
					{rs:PERMISSION_NEWSLETTERS_ACCESS_BUTTON_ALL}
					<input type="hidden" value="2">
				</div>
				<div class="item">
					{rs:PERMISSION_NEWSLETTERS_ACCESS_BUTTON_OWN}
					<input type="hidden" value="0">
				</div>
				<div class="item">
					{rs:PERMISSION_BUTTON_CUSTOM}
					<input type="hidden" value="1">
				</div>
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
				<input type="hidden" value="{newsletters_type}" name="r[newsletters_type]">
			</div>
		</td>
		</tr>

		<tr>
		<td colspan="2" id="newsletters_list">
			{if:newsletter_list}
			<div class="checkBoxItem">
				<div class="checkBox"><input type="checkbox" name="all_newsletters" id="all_newsletter" value=""></div>
				<div class="label"><label for="all_newsletters"><b>{rs:SELECT_ALL}</b></label></div>
			</div>
			{/if}
			{if:!newsletter_list}<b>{rs:NO_NEWSLETTERS_LIST}</b>{/if}
			{row:NEWSLETTER_SELECT}
			<div class="checkBoxItem">
				<div class="checkBox"><input type="checkbox" name="r[newsletter_id][]" id="newsletter_{id}" value="{id}"{if:selected} checked{/if}></div>
				<div class="label"><label for="newsletter_{id}">{title}</label></div>
			</div>
			{/row}
			<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
		</td>
		</tr>

		<tr><td colspan="2"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0" alt=""></td></tr>
		<tr class="header">
		<td>{rs:GROUPS_PERMISSION}</td>
		<td>
			<div class="mini_menu" id="groups_type">
				<div class="item">
					{rs:PERMISSION_MAILING_GROUPS_ACCESS_BUTTON_ALL}
					<input type="hidden" value="2">
				</div>
				<div class="item">
					{rs:PERMISSION_MAILING_GROUPS_ACCESS_BUTTON_OWN}
					<input type="hidden" value="0">
				</div>
				<div class="item">
					{rs:PERMISSION_BUTTON_CUSTOM}
					<input type="hidden" value="1">
				</div>
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
				<input type="hidden" value="{groups_type}" name="r[groups_type]">
			</div>
		</td>
		</tr>

		<tr>
		<td class="td_value" colspan="2" id="groups_list">
			{if:mg_list}
			<div class="checkBoxItem">
				<div class="checkBox"><input type="checkbox" name="all_groups" id="all_groups" value=""></div>
				<div class="label"><label for="all_groups"><b>{rs:SELECT_ALL}</b></label></div>
			</div>
			{/if}
			{if:!mg_list}<b>{rs:NO_MG_LIST}</b>{/if}
			{row:MAILING_GROUPS_SELECT}
			<div class="checkBoxItem">
				<div class="checkBox"><input type="checkbox" name="r[group_id][]" id="group_{id}" value="{id}"{if:selected} checked{/if}></div>
				<div class="label"><label for="group_{id}">{title}</label></div>
			</div>
			{/row}
			<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
		</td>
		</tr>

		<tr><td colspan="2"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0" alt=""></td></tr>
		<tr class="header"><td colspan="2">{rs:PERMISSION_USER_LIMITS}</td></tr>

		<tr>
		<td class="td_value" colspan="2">
			<table cellspacing="0" cellpadding="5" border="0">
			<tr>
			<td>{rs:PERMISSION_USER_LIMITS_MAX_NEWSLETTERS}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_newsletters]" value="{max_newsletters}"></div></td>
			<td>{rs:PERMISSION_BLANK}</td>
			</tr>

			<tr>
			<td>{rs:PERMISSION_USER_LIMITS_MAX_MAILING_GROUPS}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_groups]" value="{max_groups}"></div></td>
			<td>{rs:PERMISSION_BLANK}</td>
			</tr>

			<tr>
			<td>{rs:PERMISSION_USER_LIMITS_MAX_SUBSCRIBERS}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_subscribers]" value="{max_subscribers}"></div></td>
			<td>{rs:PERMISSION_BLANK}</td>
			</tr>

			<tr>
			<td>{rs:PERMISSION_USER_LIMITS_MAX_SUBSCRIBERS_PER_GROUPS}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_groups_subscribers]" value="{max_groups_subscribers}"></div></td>
			<td>{rs:PERMISSION_BLANK}</td>
			</tr>

			<tr>
			<td>{rs:PERMISSION_USER_LIMITS_MAX_NEWSLETTER_SIZE}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_newsletter_size]" value="{max_newsletter_size}"></div></td>
			<td>{rs:KB}</td>
			</tr>

			<tr>
			<td>{rs:PERMISSION_USER_LIMITS_MAX_MAILS_PER_MONTH}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_mails_per_month]" value="{max_mails_per_month}"></div></td>
			<td>{rs:PERMISSION_BLANK}</td>
			</tr>

			<tr>
			<td>{rs:PERMISSION_USER_LIMITS_MAX_MAILS_PER_DAYS}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_mails_per_days]" value="{max_mails_per_days}"></div></td>
			<td>{rs:PERMISSION_BLANK}</td>
			</tr>
			</table>
		</td>
		</tr>

		<tr><td colspan="2"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0" alt=""></td></tr>
		<tr class="header"><td colspan="2">{rs:PERMISSION_MAILING_METHOD}</td></tr>

		<tr>
		<td class="td_value" colspan="2">
			<div class="checkBoxItem">
				<div class="checkBox"><input type="checkbox" name="r[mailing_php]" id="mailing_php" value="1"{if:mailing_php} checked{/if}></div>
				<div class="label"><label for="mailing_php">{rs:PERMISSION_MAILING_METHOD_PHP}</label></div>
			</div>
			<div class="checkBoxItem">
				<div class="checkBox"><input type="checkbox" name="r[mailing_smtp]" id="mailing_smtp" value="1"{if:mailing_smtp} checked{/if}></div>
				<div class="label"><label for="mailing_smtp">{rs:PERMISSION_MAILING_METHOD_SMTP}</label></div>
			</div>
			<div class="mini_menu" id="mailing_smtp_type">
				<div class="item">
					{rs:PERMISSION_MAILING_METHOD_BUTTON_ALL}
					<input type="hidden" value="2">
				</div>
				<div class="item">
					{rs:PERMISSION_MAILING_METHOD_BUTTON_OWN}
					<input type="hidden" value="0">
				</div>
				<div class="item">
					{rs:PERMISSION_BUTTON_CUSTOM}
					<input type="hidden" value="1">
				</div>
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
				<input type="hidden" value="{mailing_smtp_type}" name="r[mailing_smtp_type]">
			</div>
			<div id="smtp_list">
				{if:smtp_list}
				<div class="checkBoxItem">
					<div class="checkBox"><input type="checkbox" name="all_smtp" id="all_smtp" value=""></div>
					<div class="label"><label for="all_smtp"><b>{rs:SELECT_ALL}</b></label></div>
				</div>
				{/if}
				{if:!mg_list}<b>{rs:NO_MG_LIST}</b>{/if}
				{row:MAILING_SMTP_SELECT}
				<div class="checkBoxItem">
					<div class="checkBox"><input type="checkbox" name="r[smtp_id][]" id="smtp_id_{id}" value="{id}"{if:selected} checked{/if}></div>
					<div class="label"><label for="smtp_id_{id}">{title}</label></div>
				</div>
				{/row}
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
			</div>
		</td>
		</tr>

		<tr><td colspan="2"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0" alt=""></td></tr>
		<tr class="header">
		<td>{rs:PERMISSION_MAILING_SPEED}</td>
		<td>
			<div class="mini_menu" id="mailing_speed_type">
				<div class="item">
					{rs:PERMISSION_MAILING_SPEED_BUTTON_DEFAULT}
					<input type="hidden" value="0">
				</div>
				<div class="item">
					{rs:PERMISSION_BUTTON_CUSTOM}
					<input type="hidden" value="1">
				</div>
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
				<input type="hidden" value="{mailing_speed_type}" name="r[mailing_speed_type]">
			</div>
		</td>
		</tr>

		<tr>
		<td class="td_value" colspan="2" id="mailing_speed_list">
			<table cellspacing="0" cellpadding="5" border="0">
			<tr>
			<td><div class="inputBox small"><input type="text" name="r[mailing_speed]" value="{mailing_speed}"></div></td>
			<td>{rs:PERMISSION_MAILING_SPEED_PER_MINUTE} {rs:PERMISSION_BLANK}</td>
			</tr>
			</table>
		</td>
		</tr>

		<tr><td colspan="2"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0" alt=""></td></tr>
		<tr class="header">
		<td>{rs:PERMISSION_ACCOUNT}</td>
		<td>
			<div class="mini_menu" id="account_type">
				<div class="item">
					{rs:PERMISSION_ACCOUNT_BUTTON_LIFE}
					<input type="hidden" value="0">
				</div>
				<div class="item">
					{rs:PERMISSION_ACCOUNT_BUTTON_LIMITED}
					<input type="hidden" value="1">
				</div>
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
				<input type="hidden" value="{account_type}" name="r[account_type]">
			</div>
		</td>
		</tr>

		<tr>
		<td class="td_value" colspan="2" id="account_time">
			<table cellspacing="0" cellpadding="5" border="0">
			<tr>
			<td>{rs:PERMISSION_ACCOUNT_START}</td>
			<td><div class="inputBox date"><input type="text" id="r[account_start]" name="r[account_start]" value="{account_start}" maxlength="10" readonly="readonly"></div></td>
			<td>{rs:PERMISSION_ACCOUNT_END}</td>
			<td><div class="inputBox date"><input type="text" id="r[account_end]" name="r[account_end]" value="{account_end}" maxlength="10" readonly="readonly"></div></td>
			</tr>
			</table>
		</td>
		</tr>

		<tr><td colspan="2"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0" alt=""></td></tr>
		<tr class="header">
		<td>{rs:PERMISSION_NEWSLETTER_HEADER_FOOTER}</td>
		<td>
			<div class="mini_menu" id="newsletter_header_type">
				<div class="item">
					{rs:PERMISSION_NEWSLETTER_HTML_HEADER_DEFAULT}
					<input type="hidden" value="0">
				</div>
				<div class="item">
					{rs:PERMISSION_NEWSLETTER_TEXT_HEADER_DEFAULT}
					<input type="hidden" value="1">
				</div>
				<div class="item">
					{rs:PERMISSION_NEWSLETTER_HTML_FOOTER_DEFAULT}
					<input type="hidden" value="2">
				</div>
				<div class="item">
					{rs:PERMISSION_NEWSLETTER_TEXT_FOOTER_DEFAULT}
					<input type="hidden" value="3">
				</div>
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
				<input type="hidden" value="{newsletter_header_type}" name="r[newsletter_header_type]">
			</div>
		</td>
		</tr>

		<tr>
		<td class="td_value" colspan="2" id="newsletter_header_list">
			<div id="newsletter_html_header" class="hidden">
				<div class="textareaBox"><textarea name="r[newsletter_html_header]" rows="5" class="big">{newsletter_html_header}</textarea></div>
			</div>
			<div id="newsletter_text_header" class="hidden">
				<div class="textareaBox"><textarea name="r[newsletter_text_header]" rows="5" class="big">{newsletter_text_header}</textarea></div>
			</div>
			<div id="newsletter_html_footer" class="hidden">
				<div class="textareaBox"><textarea name="r[newsletter_html_footer]" rows="5" class="big">{newsletter_html_footer}</textarea></div>
			</div>
			<div id="newsletter_text_footer" class="hidden">
				<div class="textareaBox"><textarea name="r[newsletter_text_footer]" rows="5" class="big">{newsletter_text_footer}</textarea></div>
			</div>
			<div id="variablesBox">
				<span id="variablesButton">{rs:LIST_OF_VARIABLES}</span>
				{include:templates/codes.tpl}
			</div>
		</td>
		</tr>

		<tr><td colspan="2"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0" alt=""></td></tr>
		<tr class="header">
		<td>{rs:PERMISSION_ATTACHMENTS}</td>
		<td>
			<div class="mini_menu" id="attachments">
				<div class="item">
					{rs:PERMISSION_ENABLE}
					<input type="hidden" value="1">
				</div>
				<div class="item">
					{rs:PERMISSION_DISABLE}
					<input type="hidden" value="0">
				</div>
				<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="10" border="0"></div>
				<input type="hidden" value="{attachments}" name="r[attachments]">
			</div>
		</td>
		</tr>

		<tr>
		<td class="td_value" colspan="2" id="attachments_list">
			<table cellspacing="0" cellpadding="5" border="0">
			<tr>
			<td>{rs:PERMISSION_ATTACHMENTS_MAX_SIZE}</td>
			<td><div class="inputBox small"><input type="text" name="r[max_attachments_size]" value="{max_attachments_size}"></div></td>
			<td>{rs:KB}. {rs:PERMISSION_BLANK}</td>
			</tr>
			</table>
		</td>
		</tr>

		<tr>
		<td><img src="{global:PATH}img/spacer.gif" width="200" height="1" border="0"></td>
		<td width="100%"><img src="{global:PATH}img/spacer.gif" width="70" height="1" border="0"></td>
		</tr>
		</table>
		<input type="hidden" name="save" value="1" class="hidden">
		</form>
		<div class="info">{rs:PERMISSION_INFO}</div>
	</div>
</div>
<div class="actionPanelLeft">
	<div class="actionPanelRight">
		<div class="actionPanelBottom">
			<div class="actionPanelBottomLeft">
				<div class="actionPanelBottomRight p16">
					<div id="actionBottom" class="right">
						<div class="button actionSave">
							<div class="buttonRight">
								<div class="buttonMiddle">{rs:ACTION_SAVE}</div>
							</div>
						</div>

						<div class="button actionCancel">
							<div class="buttonRight">
								<div class="buttonMiddle">{rs:ACTION_CANCEL}</div>
							</div>
						</div>

						<div class="button actionBack">
							<div class="buttonRight">
								<div class="buttonMiddle">{rs:ACTION_BACK} {rs:TITLE_USERS}</div>
							</div>
						</div>

						<div class="br"><img src="{global:PATH}img/spacer.gif" width="1" height="1" border="0" /></div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript" src="{global:PATH}js/permissions.js"></script>
<script language="JavaScript">
	$(".date").find("input").click(function() {
		Calendar.Create($(this).attr('name'), $(this).parent().offset().left+$(this).parent().outerWidth()+10, $(this).parent().offset().top);
	});
	$(".actionSave").click(function() {
		$("#editForm").submit();
	});
	$(".actionCancel").click(function() {
		if (confirm("{rs:SURE_CANCEL_EDIT}")) window.location.href="{global:BACK_LINK}";
	});
	$(".actionBack").click(function() {
		window.location.href="{global:BACK_LINK}";
	});
	$("input[name*='all']").click(function() {
		var id='access_id['+this.name.replace(/all\[(\d+)\]/, "$1")+']';
		$("input[name*="+id+"]").attr('checked', this.checked);
	});
	$("input[name='all_newsletters']").click(function() {
		$("input[name*='r[newsletter_id]']").attr('checked', this.checked);
	});
	$("input[name='all_groups']").click(function() {
		$("input[name*='r[group_id]']").attr('checked', this.checked);
	});
	$("input[name='all_smtp']").click(function() {
		$("input[name*='r[smtp_id]']").attr('checked', this.checked);
	});
	$('#permission .line').hover(function() {
		 $(this).toggleClass("hover");

	});
	$("#variablesButton").click(function() {
		$("#variablesList").slideToggle('fast');
	});

	new Permission('newsletters_type', {
		actions:[
			{values:1,	id:"newsletters_list",		type:"enable"},
			{values:[0,2],	id:"newsletters_list",		type:"disable"}
			]
	});
	new Permission('groups_type', {
		actions:[
			{values:1,	id:"groups_list",		type:"enable"},
			{values:[0,2],	id:"groups_list",		type:"disable"}
			]
	});
	new Permission('mailing_smtp_type', {
		actions:[
			{values:1,	id:"smtp_list",			type:"enable"},
			{values:[0,2],	id:"smtp_list",			type:"disable"}
			]
	});
	new Permission('mailing_speed_type', {
		actions:[
			{values:1,	id:"mailing_speed_list",	type:"enable"},
			{values:0,	id:"mailing_speed_list",	type:"disable"}
			]
	});
	new Permission('account_type', {
		actions:[
			{values:1,	id:"account_time",		type:"enable"},
			{values:0,	id:"account_time",		type:"disable"}
			]
	});
	new Permission('newsletter_header_type', {
		actions:[
			{values:0,	id:"newsletter_html_header",	type:"show"},
			{values:1,	id:"newsletter_text_header",	type:"show"},
			{values:2,	id:"newsletter_html_footer",	type:"show"},
			{values:3,	id:"newsletter_text_footer",	type:"show"}
			]
	});
	new Permission('attachments', {
		actions:[
			{values:0,	id:"attachments_list",		type:"disable"},
			{values:1,	id:"attachments_list",		type:"enable"}
			]
	});
</script>
