{if $ajax eq 0}
{include file="$admingentemplates/admin_top.tpl"}
<script language="JavaScript" type="text/javascript" src="{$site_root}{$index_theme_path}/js/jquery.form.js"></script>

<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_settings.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.pays.list_settings}</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>
<div class="help_text" style="display:block;">
    <div class="close_help">
        <img src="{$site_root}{$template_root}/images/close_help.png" alt="">
    </div>
    <div class="help_body">
        <span class="help_title">{$lang.help}:</span>{$lang.admin_help.billing_settings_paysystem}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a class="current">{$lang.index.payments.paysys}</a>
    </li>
    <li>
        <a href="admin_pays.php?sel=currency">{$lang.settings.site_currency}</a>
    </li>
</ul>
<div class="panel">
    <div class="user_operation_line" style="height:4px;font-size:0px;">
    </div>
    <div class="cr"></div>
    <div class="fl">
        {foreach from=$paysystems item=item key=k}
            <div class="sgs_system_box_outer">
            {strip}
            <div class="sgs_system_box" onclick="ShowSettings('{$item.name_orig}')">
                {if $item.used}
                    <img height="100px" width="150px;" src="{$site_root}{$template_root}/images/systems/{$item.name_orig}.png" alt="">
                    <div class="sgs_action_active"><img width="16" src='{$site_root}{$template_root}/images/success.png'alt=""></div>
                {else}
                    <img height="100px" width="150px;" src="{$site_root}{$template_root}/images/systems/{$item.name_orig}_gray.png"alt="">
                {/if}
                <div class="sgs_action_edit"><img width="16" src='{$site_root}{$template_root}/images/edit.png'alt=""></div>
            </div>
            {/strip}
            </div>
{*            {if $k is div by 5}
                </div>
                <div class="cr"></div>
                <div class="fl">
            {/if}*}
        {/foreach}
    </div>
    <div id="paysys_set">
    </div>
    <div class="cr">&nbsp;</div>
    <div class="user_operation_line" style="height:4px;font-size:0px;">
    </div>
</div>
<script type="text/javascript">
{literal}
function ChangeLang(paysys, par) {
    ajaxLoadingImage(1, 'paysys_set');
    $.post('admin_pays.php',{sel:'settings',settype:paysys, ajax:1, "language_id_1":par},function(data){
        ajaxLoadingImage(0, 'paysys_set');
        $('#paysys_set').html(data);
    });
}

$('.sgs_system_box').mouseover(function (e) {
    $(this).addClass('sgs_system_box_sel');
    $(this).css('top', '-3');
    $(this).css('left', '-3');
    $(this).find(".sgs_action_edit").show();
});
$('.sgs_system_box').mouseout(function (e) {
    $(this).removeClass('sgs_system_box_sel');
    $(this).css('top', '0');
    $(this).css('left', '0');
    $(this).find(".sgs_action_edit").hide();
});
function ShowSettings(paysys) {
    ajaxLoadingImage(1, 'paysys_set');
    $.post('admin_pays.php',{sel:'settings',settype:paysys, ajax:1},function(data){
        ajaxLoadingImage(0, 'paysys_set');
        $('#paysys_set').html(data);
    });
}

var options = { 
    success: function(data){
        $('#error_box').html(data);
        $('#error_box').oneTime(3000, function() {
            $('#error_box').fadeOut(500);
        });
        return false;
    },
    beforeSubmit: function() { 
        ajaxIndicator(1, 'error_box');
    }
 };
 function SavePaysys(){
 	manual_body = $('iframe').contents().find('iframe').contents().find('body').html() ? $('iframe').contents().find('iframe').contents().find('body').html() : null;
 	if(manual_body){
 		$('#manual_body').val(manual_body);
 	}
    $('#money_form').submit();
    return false;
 }
    
{/literal}
</script>
{include file="$admingentemplates/admin_bottom.tpl"}
{else}
    <form id="money_form" name="money_form" action="{$form.action}" method="post" {if $settype == "general"}onsubmit="javascript: return checkMoneyForm();"{/if}>
    {$form.hiddens}
    <input type="hidden" name="sel" value="saveset">
    <input type="hidden" name="settype" value="{$settype}">
    <br>
    <table border="0" cellspacing="1" cellpadding="5" width="100%">
    {if $settype != 'general'}
        {$data.table_options}
    {/if}
        <tr height="10" bgcolor="#ffffff">
            <td colspan="2" align="left">
                <a class="admin_button_major" onclick="SavePaysys();">{$lang.button.save}<span>&nbsp;</span></a>
            </td>
            <td align="left">
                <div id="error_box" class="error_box_blue">
                </div>
            </td>
        </tr>
	</table>
    </form>
    {if $settype eq 'ccbill'}
    <form name="ccbill_form" action="{$form.action}" method="post">
    {$form.hiddens}
    <input type="hidden" name="sel" value="saveset">
    <input type="hidden" name="settype" value="{$settype}">
    <input type="hidden" name="groups_periods" value="1">
    <br>
    <table border="0" cellspacing="1" cellpadding="5" width="100%">
    <tr bgcolor="#ffffff">
        <td colspan="3" style="padding-top: 10px;">&nbsp;</td>
    </tr>
    <tr bgcolor="#ffffff">
        <td colspan="2" align="left" class="main_header_text">{$lang.pays.ccbill_groups_periods_header}</td>
        <td class="main_header_text">{$lang.pays.ccbill_subscription_types_header}</td>
    </tr>
    {section name=gp loop=$group_periods}
    <tr bgcolor="#ffffff">
        <td colspan="2" align="left" class="main_content_text">{$group_periods[gp].amount}&nbsp;{$group_periods[gp].period} - {$group_periods[gp].group_name} - {$group_periods[gp].cost}&nbsp;{$group_periods[gp].currency}</td>
        <td class="main_content_text"><input type="text" size="30" name="ccbill_group_sub_id[]" value="{$group_periods[gp].ccbill_sub_id}"><input type="hidden" name="groups_periods_id[]" value="{$group_periods[gp].id}"><input type="hidden" name="ccbill_group_id[]" value="{$group_periods[gp].ccbill_group_id}"></td>
    </tr>
    {/section}
    <tr bgcolor="#ffffff">
        <td colspan="2" align="left">
			<a class="admin_button_major" onclick="javascript: document.ccbill_form.submit();">{$lang.button.save}<span>&nbsp;</span></a>
		</td>
        <td>&nbsp;</td>
    </tr>
	</table>
    </form>
    {/if}
    {if $settype eq 'allopass'}
    <form name="allopass_form" action="{$form.action}" method="post">
    {$form.hiddens}
    <input type="hidden" name="sel" value="saveset">
    <input type="hidden" name="settype" value="{$settype}">
    <input type="hidden" name="groups_periods" value="1">
    <br>
    <table border="0" cellspacing="1" cellpadding="5" width="100%">
    <tr bgcolor="#ffffff">
        <td colspan="3" style="padding-top: 10px;">&nbsp;</td>
    </tr>
    <tr bgcolor="#ffffff">
        <td colspan="2" align="left" class="main_header_text">{$lang.pays.allopass_groups_periods_header}</td>
        <td class="main_header_text">{$lang.pays.allopass_docs_header}</td>
    </tr>
    {section name=gp loop=$group_periods}
    <tr bgcolor="#ffffff">
        <td colspan="2" align="left" class="main_content_text">{$group_periods[gp].amount}&nbsp;{$group_periods[gp].period} - {$group_periods[gp].group_name} - {$group_periods[gp].cost}&nbsp;{$group_periods[gp].currency}</td>
	<td class="main_content_text">
	<input type="text" size="20" name="allopass_group_doc_id_mobile[]" value="{$group_periods[gp].allopass_doc_id_mobile}"> ({$lang.pays.allopass_docs_mobile}) &nbsp;
	<input type="text" size="20" name="allopass_group_doc_id_credit[]" value="{$group_periods[gp].allopass_doc_id_credit}"> ({$lang.pays.allopass_docs_credit}) &nbsp;
	<input type="hidden" name="groups_periods_id[]" value="{$group_periods[gp].id}">
	<input type="hidden" name="allopass_group_id[]" value="{$group_periods[gp].allopass_group_id}">
	</td>
    </tr>
    {/section}
    <tr bgcolor="#ffffff">
        <td colspan="2" align="left">			
			<a class="admin_button_major" onclick="javascript: document.allopass_form.submit();">{$lang.button.save}<span>&nbsp;</span></a>
		</td>
        <td>&nbsp;</td>
    </tr>
	</table>
    </form>
    {/if}
{/if}