{% macro selectbox(name, options, selected, required, nullOption) %}
    <select name="{{ name }}" {% if required %}required="required"{% endif%}>
        {% if nullOption %}<option value="">-- {{ nullOption }} --</option>{% endif %}
        {% for val,label in options %}
        <option value="{{ val }}" label="{{ label|e }}" {% if selected == val %}selected="selected"{% endif %}>{{ label|e }}</option>
        {% endfor %}
    </select>
{% endmacro %}

{% macro selectboxtld(name, options, selected, required) %}
    <select name="{{ name }}" {% if required %}required="required"{% endif%} style="width:80px;">
        {% for data in options %}
        <option value="{{ data.tld }}" label="{{ data.tld }}" {% if selected == data.tld %}selected="selected"{% endif %}>{{ data.tld }}</option>
        {% endfor %}
    </select>
{% endmacro %}

{% macro currency_format(price, currency) %}
    {% set c = guest.currency_get({"code":currency}) %}
    {% set p = (price)|number %}
    {% if c.price_format == 1 %}
        {% set p = p|number('2', '.', '') %}
    {% elseif c.price_format == 2 %}
        {% set p = p|number('2', '.', ',') %}
    {% elseif c.price_format == 3 %}
        {% set p = p|number('2', ',', '.') %}
    {% elseif c.price_format == 4 %}
        {% set p = p|number('0', '', ',') %}
    {% elseif c.price_format == 5 %}
        {% set p = p|number(0, '', '') %}
    {% endif %}
    {{ c.format|replace({'{{price}}': p }) }}
{% endmacro %}

{% macro currency(price, currency) %}
    {% if currency == NULL %}
        {% set c = guest.cart_get_currency %}
    {% else %}
        {% set c = guest.currency_get({"code":currency}) %}
    {% endif %}

    {% set p = (price * c.conversion_rate) %}
    
    {% if c.price_format == 1 %}
        {% set p = p|number('2', '.', '') %}
    {% elseif c.price_format == 2 %}
        {% set p = p|number('2', '.', ',') %}
    {% elseif c.price_format == 3 %}
        {% set p = p|number('2', ',', '.') %}
    {% elseif c.price_format == 4 %}
        {% set p = p|number('0', '', ',') %}
    {% elseif c.price_format == 5 %}
        {% set p = p|number(0, '', '') %}
    {% endif %}
    
    {{ c.format|replace({'{{price}}': p }) }}
{% endmacro %}

{% macro status_name(status) %}
    {{ status|replace({'_': " "})|title|trans }}
{% endmacro %}

{% macro period_name(period) %}
    {{ guest.system_period_title({"code":period}) }}
{% endmacro %}

{% macro markdown_quote(text) %}



{% for line in text|split %}
> {{ line }}
{% endfor %}
{% endmacro %}


{% macro recaptcha() %}

{% if guest.extension_is_on({"mod":"spamchecker"}) %}
{% set rc = guest.spamchecker_recaptcha %}
{% if rc.enabled %}
    {% set server = "https://www.google.com/recaptcha/api" %}
    <script type="text/javascript">
        var RecaptchaOptions = {
        theme : 'custom',
        custom_theme_widget: 'recaptcha_widget'
    };
    </script>

    <div id="recaptcha_widget" style="display:none">

    <div id="recaptcha_image"></div>
    <div class="recaptcha_only_if_incorrect_sol" style="color:red">{% trans 'Incorrect please try again' %}</div>

    <p>
        <label>{% trans 'Enter the words above' %}</label>
        <br/>
        <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" style="width: 245px"/>
            <a class="bb-button" href="javascript:Recaptcha.reload()" style="float: right"><span class="dark-icon i-reload"></span></a>
    </p>
    </div>

    <script type="text/javascript" src="{{ server }}/challenge?k={{ rc.publickey }}"></script>
    <noscript>
        <iframe src="{{ server }}/noscript?k={{ rc.publickey }}" height="300" width="500" frameborder="0"></iframe><br/>
        <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
        <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
    </noscript>
{% endif %}
{% endif %}
{% endmacro %}