<!-- sms activation tab -->

<div class="area_smsActivation step_area content-padding">
    <div style="padding-bottom: 5px;">{$success_code}</div>

    <div id="area_smsActivation" style="padding: 10px 0px 50px 0px;">
        {if ($isLogin && $smarty.session.account.smsActivation) || $smarty.session.registration.smsActivation}
            <div class="info">{$lang.smsActivation_activated_aa}</div>
        {else}
            <div class="submit-cell">
                <div class="name">{$lang.smsActivation_code}</div>
                <div class="field single-field">
                    <input class="w120" type="text" id="sms_code" name="sms_code" maxlength="{$config.sms_activation_code_length}" />
                    <input type="button" id="sms_check" value="{$lang.smsActivation_confirm}" />
                    <span style="padding: 0 8px;">{$lang.smsActivation_or}</span>
                    <input id="new_code" type="button" value="{$lang.smsActivation_get_code}"  />
                </div>
            </div>
        {/if}
    </div>

    <form id="form-smsActivation" method="post" action="{$rlBase}{if $config.mod_rewrite}{$pageInfo.Path}/{$reg_steps.$cur_step.path}.html{else}?page={$pageInfo.Path}&amp;step={$reg_steps.$cur_step.path}{/if}">
        <input type="hidden" name="step" value="smsActivation" />

        <div class="form-buttons no-top-padding">
            <a href="{$rlBase}{if $config.mod_rewrite}{$pageInfo.Path}/{$prev_step.path}.html{else}?page={$pageInfo.Path}&amp;step={$prev_step.path}{/if}">{if $smarty.const.RL_LANG_DIR == 'ltr'}&larr;{else}&rarr;{/if} {$lang.perv_step}</a>
            <input type="submit" {if !$smarty.session.account.smsActivation}disabled="disabled"{/if} value="{$lang.next_step}" class="registration-next-step" />
        </div>
    </form>
    
    <script class="fl-js-dynamic">
    {literal}
        $('input[name=new_code]').flModal({
            caption: '{/literal}{$lang.warning}{literal}',
            content: '{/literal}{$lang.smsActivation_get_code_confirm}{literal}',
            prompt: 'sendSMSCode()',
            width: 'auto',
            height: 'auto'
        });

        $(document).ready(function(){
            $('input#sms_check').click(function() {
                checkSMSCode($('#sms_code').val());
            });    
        });
        
        var sendSMSCode = function() {
                
        }

        var checkSMSCode = function(code) {
            $('input#sms_check').val(lang['loading']);
            $.getJSON(rlConfig['ajax_url'], {mode: 'smsActivationCheck', item: code}, function(response) {
                if (response) {
                    if (response.status == 'ok') {
                        printMessage('notice', response.message_text);
                        $('.registration-next-step').attr('disabled', false);
                        $('#area_smsActivation').html('<div class="info">{/literal}{$lang.smsActivation_activated_aa}{literal}</div>');
                    } else {
                        printMessage('error', response.message_text);
                    }
                }
                $('input#sms_check').val('{/literal}{$lang.smsActivation_confirm}{literal}');
            });
        }
    {/literal}
    </script>
</div>

<!-- sms activation tab end -->