{include file="$gentemplates/$header_tpl"}
    <h2>{$sms_notifications.sms_notifications}</h2>
    <div style="padding-top: 10px;">
        <form name="sms_notifications" action="{$form.action}" method="POST">
        {foreach from=$form.hiddens item=hidden}
                <input type="hidden" name="{$hidden.name}" value="{$hidden.value}">
        {/foreach}
        <table cellpadding="0" cellspacing="0" width="100%" border="0" style="padding-top:10px;">
        
        {*if $error}
        <tr>
            <td style="padding-top:5px; padding-{$default_right}:0px; padding-bottom:10px; padding-{$default_left}:5px;">
            <div class="error_msg">*&nbsp;{$error}</div>
            </td>
        </tr>
        {/if*}
        
        {if !$not_turn_on}
        <tr>
            <td style="padding-top: 0px; padding-bottom: 5px; padding-{$default_left}:4px;">{$sms_notifications.sms_notifications_help_p1}</td>
        </tr>

        <tr>
            <td style="padding-top: 0px;">
            <table cellpadding="4" cellspacing="0" border="0" width="90%" align="{$default_left}">
                <tr>
                    <td valign="top" colspan="2">
						<br />
                        <b>{$sms_notifications.phone_number}:</b>
                    </td>
                </tr>
                <tr>
                    <td valign="top" colspan="2">
                        <input type="text" id="phone_number" name="phone_number" value="{$phone_number}">
                    </td>
                </tr>

                <tr>
                    <td valign="top" colspan="2">
						<br />
                        <b>{$sms_notifications.sms_notifications_about}:</b>
                    </td>
                </tr>

                <tr>
                    <td colspan="2" valign="top">
                        <table cellpadding="4" cellspacing="1" border="0">
                        {foreach from=$sms_cases item=item key=key}
                        {assign var=lang_str value=about_$item}
                        <tr>
                            <td style="padding:1px;">
                            <input type="checkbox" id="sms_price_{$key}" name="sms_price[{$key}]" onclick="CheckBalance(this);" {if $sms_user_event[$key]}checked{/if}>
                            </td>
							
                            <td style="padding:1px;padding-{$default_left}:0px;">
                            &nbsp;{$sms_notifications[$lang_str]}
                            </td>
                        </tr>
                        {/foreach}
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" style="margin:10px 0 10px 0;" value="{$lang.button.save}" onclick="if (CheckBalance('')) {literal}{{/literal} document.sms_notifications.sel.value='subscribe'; document.sms_notifications.submit();{literal}}{/literal}">
                    </td>
                </tr>
                <tr>
                    <td valign="top" colspan="2">
                        <b>{$sms_notifications.balance_of_sms}:</b>
                    </td>
                </tr>
                <tr>
                    <td valign="top" colspan="2">
                    {if !$sms_balance}<font color='red'>{$sms_balance}&nbsp;SMS</font>{else}{$sms_balance}&nbsp;SMS{/if}
                    </td>
                </tr>
                <tr>
                <td valign="top" colspan="2">
					<br />
                    <b>{$sms_notifications.cost_of_sms}:</b>
                </td>
                </tr>
                <tr>
                    <td colspan="2">
                    <select name="sel_packet">
                    {foreach from=$sms_costs item=item}
                        <option value="{$item.id}" {if $item.id == $price_id}selected="selected"{/if}>{$item.sms_packet}&nbsp;SMS&nbsp;-&nbsp;{$item.cost}&nbsp;{$form.cur}</option>
                    {/foreach}
                    </select>
                    </td>
                </tr>
				<tr>
				<td>
					<input type="button" style="margin-top:10px;" value="{$sms_notifications.buy_sms}" onclick="if (confirm('{$sms_notifications.sure_buy_sms|escape:javascript}')) {literal}{{/literal}document.sms_notifications.sel.value='buy_sms'; document.sms_notifications.submit();{literal}}{/literal}">
				</td>
				</tr>
            </table>
            <td>
        </tr>
        {/if}
        </table>
        </form>
    </div>
{include file="$gentemplates/$footer_tpl"}
{literal}
<script>
function CheckBalance(checkbox){
	{/literal}
	{if !$sms_balance}
	{literal}
	alert('{/literal}{$sms_notifications.empty_balance|escape:javascript}{literal}');
	if (checkbox != ''){
		checkbox.checked = false;
	}
	return false;
	{/literal}
	{else}
	{literal}
	if (document.getElementById('phone_number').value.search(/^[0-9]{10,14}$/) == -1){
		alert('{/literal}{$sms_notifications.incorrect_phone|escape:javascript}{literal}');
		return false;
	}
	return true;
	{/literal}
	{/if}
	{literal}
}

</script>
{/literal}