{include file="$gentemplates/$header_tpl"}
<td class="main_cell">
    <!-- begin main cell -->
    {strip}
		<h2>{$lang.sms_payments.payment_proccessing}</h2>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
        {if $data.err}
        <tr>
            <td valign="top" style="padding-top:10px;"><font class="error_msg">*&nbsp;{$data.err}</font><br>&nbsp;</td>
        </tr>
        {/if}
        <tr>
            <td valign="top" style="padding-top: 10px">
                <div style="padding-top: 5px;" class="text">
                {if $system neq 'zaypay'}
                    {$data.msg}<br><br>
                {else}
                    {if $action eq 'pay'}
                        <div class="header" style="padding: 5px 0px">{$zaypay_info.very_short_instructions_with_amount}</div>
                        <form name="formZaypayPay" method="post">
                          <input type="hidden" name="paymentid" value="{$zaypay_info.payment.id}" />
                          <input type="hidden" name="action" value="paid" />
                          <input type="hidden" name="rate" value="{$data.id_rate}" />                    
                          <input type="hidden" name="sel" value="step_2" />
                          <input type="hidden" name="system" value="{$system}" />                    
                          <input type="hidden" name="order_id" value="{$data.order_id}" />                    
                          
                          <table width="100%">
                            <tr>
                              <td width="20%" valign="top">{$lang.sms_payments.instruction}:</td>
                              <td width="80%" valign="top">{$zaypay_info.long_instructions}<font class="error_msg">*</font></td>
                            </tr>
                            <tr>
                              <td width="20%" valign="top">{$lang.sms_payments.status}:</td>
                              <td width="80%" valign="top">{$zaypay_info.status_string}</td>
                            </tr>
                        {if $zaypay_info.payment.verification_needed eq 'true'}
                            <tr>
                              <td width="20%" valign="top">{$lang.sms_payments.verification_code}:</td>
                              <td width="80%" valign="top"><input type="text" name="verification_code" size="6" /></td>
                            </tr>
                        {/if}
                          </table>
                          <br />
                          <div class="button">
                            <input type="submit" name="submit" value="{$lang.button.submit}" />&nbsp;<font class="error_msg">*{$lang.sms_payments.attention}</font>
                          </div>
                        </form> 
                        <br />
                    {elseif $action eq 'paid'}                    
                        <div>
                          <table width="100%">
                            <tr>
                              <td width="20%" valign="top">{$lang.sms_payments.status}:</td>
                              <td width="80%" valign="top"><b>{$paid}</b></td>
                            </tr>
                          </table>  
                        </div>
                        <br />
                    {else}
                    <div>
                    <div id="payment_method_empty" style="display: none;">
                        <div style="padding-top: 10px;"><font class="error_msg">*&nbsp;{$lang.sms_payments.payment_method_not_chosen}</font></div>
                    </div>

                    <form name="formZaypayMethod" method="post" id="formZaypayMethod">
                    <input type="hidden" name="rate" value="{$data.id_rate}" />                    
                    <input type="hidden" name="sel" value="step_2" />
                    <input type="hidden" name="action" value="pay" />                    
                    <input type="hidden" name="system" value="{$system}" />
                    <input type="hidden" name="paymentmethod_val" value="" id="paymentmethod_val"/>
                    <table width="100%">
                      <tr>
                        <td width="25%">
                            {$lang.sms_payments.choose_country}:
                        </td>
                        <td>
                          <select name="locale_country" onchange="ChangeCountriesZayPay(this.value);"> 
                            {foreach from=$locales.countries item=item}
                              <option value="{$item.code}" {if $set_country_zaypay eq $item.code} selected {/if} /> {$item.name}</option>
                            {/foreach}
                          </select>
                        </td>
                      </tr>
                      <tr>
                        <td width="25%"> 
                          {$lang.sms_payments.choose_payment_method}:  
                        </td>
                        <td  id="payment_methods_div"> 
                            {foreach from=$payment_methods item=item}
                              <b><label><input type="radio" name="paymentmethod" value="{$item.payment_method_id}" onclick="SetPaymentMethod('{$item.payment_method_id}');"/> {$item.very_short_instructions_with_amount}</label></b><br />
                            {/foreach}
                            <input type="hidden" name="locale" value="{$locale}" />
                        </td>
                      </tr>
                    </table>
                    <br />
                    <div class="button">
                      <input type="button" name="" value="{$lang.button.submit}" onclick="CheckPaymentMethod();" />
                    </div> 
                    </form> <br/>
                    {/if}
                {/if}               
                {if $system eq 'daopay'}
                {$lang.sms_payments.daopay.follow_instructions}
                <br><br>
                {/if}
                    {$please_note}
                </div>
            </td>
        </tr>
        <tr>
            <td style="padding-top: 10px;"><a href="sms_payment.php">{$lang.button.back}</a></td>
        </tr>
        </table>
    {/strip}
    <!-- end main cell -->
</td>
{literal}
<script type="text/javascript">

var req = null;

function InitXMLHttpRequest() {
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
}

function ChangeCountriesZayPay(country) {
    if (country == undefined) return ;
    destination = document.getElementById("payment_methods_div");
    InitXMLHttpRequest();
    if (req){
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                destination.innerHTML = req.responseText;
            } else {
                destination.innerHTML = "";
            }
        }
        req.open('GET', 'sms_payment.php?sel=change_country&r='+Math.random()+'&system=zaypay&id_rate={/literal}{$data.id_rate}{literal}&locale_country='+country, true);
        req.send(null);
    }
    else{
        destination.innerHTML = 'Browser unable to create XMLHttp Object';
    }
    return;
    
}
function CheckPaymentMethod () {
    if (document.getElementById('paymentmethod_val').value == '') {
        document.getElementById('payment_method_empty').style.display = "inline";
    } else {
        document.getElementById('payment_method_empty').style.display = "none";
        document.getElementById('formZaypayMethod').submit();
    }
    return;
}

function SetPaymentMethod(val) {
    document.getElementById('payment_method_empty').style.display = "none";
    document.getElementById('paymentmethod_val').value = val;
    return false;
}

</script>
{/literal}
{include file="$gentemplates/$footer_tpl"}