{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}

{% import "macro_functions.phtml" as mf %}

{% block meta_title %}{{ product.title }}{% endblock %}

{% block content_before %}
    {% include "partial_steps.phtml" with { 'selected': 2 } %}
{% endblock %}

{% block content %}
    {% set periods = guest.system_periods %}
    {% set pricing = product.pricing %}

<form method="post" action="" class="api_form" data-api-url="guest/cart/add_item" data-api-redirect="{{ 'cart'|link }}">
    <div class="h-block">
        <div class="h-block-header">
            <div class="icon"><span class="number">2</span></div>
            <h2>{{ 'Configure'|trans }}</h2>
            <p>{{ 'Please configure VPS service.'|trans }}</p>
        </div>
        <div class="block">
            <div class="grid_8 alpha">
                <div class="box">
                    <div class="block">
                        <h1>{{ product.title }}</h1>
                        {{ product.description|bbmd }}
                    </div>
                    <div class="rowElem">
                        <label>{{ 'Hostname'|trans }}:</label>
                        <div class="formRight">
                            <input type="text" name="hostname" value="" placeholder="VPS hostname"/>
                        </div>
                        <div class="fix"></div>
                    </div>

                    <div class="rowElem">
                        <label>{{ 'Template'|trans }}</label>
                        <div class="formRight">
                            {{ mf.selectbox('template', guest.servicesolusvm_get_templates, null, 1) }}
                        </div>
                        <div class="fix"></div>
                    </div>

                </div>
            </div>
            <div class="grid_4 omega">
                {% include 'partial_pricing.phtml' with { 'product': product } %}
            </div>
            <div class="clear"></div>
        </div>
    </div>
    {% include 'partial_addons.phtml' with {'product': product} %}
    <input type="hidden" name="id" value="{{ product.id }}" />
</form>
{% endblock %}

{% block sidebar2 %}
    {% include 'partial_currency.phtml' %}
{% endblock %}

{% block js %}
<script type="text/javascript">
    $(function() {
        if($(".addons").length && $(".addons").is(':hidden')) {
            $('#order-button').one('click', function() {
                $(this).hide();
                $('.addons').slideDown('fast');

                return false;
            });
        }

        $('#period-selector').change(function() {
            $('.period').hide();
            $('.period.' + $(this).val()).show();
        }).trigger('change');

        $('.addon-period-selector').change(function() {
            var r = $(this).attr('rel');
            
            $('#' + r + ' span').hide();
            $('#' + r + ' span.' + $(this).val()).fadeIn();
        }).trigger('change');
    });
</script>
{% endblock %}