{block name=pages_login}
    {if $smarty.get.form == "register" || $smarty.post.form == "register"}
        <a href="{link page='customer' paction='login'}" class="btn btn-success pull-right">
            <i class="fa fa-sign-in"></i> {txt key=BUTTON_LOGIN}
        </a>
    {/if}

    <h1>{txt key=TEXT_PAGE_TITLE_LOGIN}</h1>

    {$message}

    <div class="row">
        {if $smarty.get.form != "register" && $smarty.post.form != "register"}
            <div class="col col-md-6 col-md-push-6">
                <div class="panel panel-default">
                    <p class="panel-heading"><strong><i class="fa fa-user"></i> {txt key=TEXT_RETURNING}</strong></p>
                    <div id="loginbox" class="clearfix panel-body">
                        <p>{txt key=TEXT_TXT_RETURNING}</p>
                        {form type=form name=login action='dynamic' link_params='page_action=login' method=post conn=SSL}
                        {form type=hidden name=action value=login}
                        {form type=hidden name=link_target value=index}

                        <div class="form-group">
                            <label for="email">{txt key=text_email}*</label>
                            {form id=email type=text name=email maxlength='50'}
                        </div>

                        <div class="form-group">
                            <label for="password">{txt key=text_password}*</label>
                            {form id=password type=password name=password maxlength='30'}
                        </div>

                        <p class="required pull-left">{txt key=TEXT_MUST}</p>

                        <p class="pull-right">
                            <a href="{link page='customer' paction='password_reset' conn=SSL}" class="btn btn-default">{txt key=text_link_lostpassword}</a>
                            <button type="submit" class="btn btn-success">
                                <i class="fa fa-sign-in"></i> {txt key=BUTTON_LOGIN}
                            </button>
                        </p>

                        {form type=formend}
                    </div>
                </div>
            </div>
            <div class="col col-md-6 col-md-pull-6">
                <div class="panel panel-default">
                    <p class="panel-heading"><strong><span class="glyphicon glyphicon-share-alt"></span> {txt key=TEXT_NEW_CUSTOMER}</strong></p>
                    <div class="panel-body">
                        <p>{txt key=TEXT_TXT_NEW_CUSTOMER}</p>
                        <div class="register-short">
                            <form>
                                <div class="pull-right text-right">
                                    <p>
                                        <a href="{link page='customer' paction='login' params='form=register' conn=SSL}" class="btn btn-primary">
                                            {txt key=BUTTON_NEXT}
                                        </a>
                                    </p>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        {/if}

        {if $smarty.get.form == "register" || $smarty.post.form == "register"}
        <div class="col col-xs-12">
            <div class="panel panel-default">
                <p class="panel-heading"><strong><span class="glyphicon glyphicon-share-alt"></span> {txt key=TEXT_NEW_CUSTOMER}</strong></p>
                <div class="panel-body">
                    <div class="info-text alert alert-info">{txt key=TEXT_TXT_NEW_CUSTOMER}</div>

                    <div id="registerbox">
                        {form type=form name=create_account action='dynamic' link_params='page_action=login' method=post conn=SSL role="form"}
                        {form type=hidden name=action value=add_customer}
                        {form type=hidden name=page value='customer'}
                        {form type=hidden name=form value='register'}
                        {form type=hidden name='default_address[address_class]' value=default}
                            <fieldset>
                                <legend>{txt key=TEXT_PERSONAL}</legend>
                                {if $show_gender eq 1}
                                    <div class="form-group row">
                                        <label for="default_address_customers_gender" class="col col-md-3">{txt key=TEXT_GENDER}*</label>
                                        <div class="col col-md-9">
                                            {form params='id="default_address_customers_gender"' type=select name='default_address[customers_gender]' value=$gender_data default=$default_address.customers_gender class="form-control"}
                                        </div>
                                    </div>
                                {/if}
                                <div class="form-group row">
                                    <label for="default_address_customers_firstname" class="col col-md-3">{txt key=TEXT_FIRSTNAME}*</label>
                                    <div class="col col-md-9">
                                        {form id=default_address_customers_firstname type=text name='default_address[customers_firstname]' value=$default_address.customers_firstname}
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="default_address_customers_lastname" class="col col-md-3">{txt key=TEXT_LASTNAME}*</label>
                                    <div class="col col-md-9">
                                        {form id=default_address_customers_lastname type=text name='default_address[customers_lastname]' value=$default_address.customers_lastname}
                                    </div>
                                </div>
                                {if $show_birthdate eq 1}
                                    <div class="form-group row">
                                        <label for="default_address_customers_dob" class="col col-md-3">{txt key=TEXT_BIRTHDATE}*</label>
                                        <div class="col col-md-9">
                                            {form id=default_address_customers_dob type=text name='default_address[customers_dob]' value=$default_address.customers_dob}
                                        </div>
                                    </div>
                                {/if}
                                <div class="form-group row">
                                    <label for="cust_info_customers_email_address" class="col col-md-3">{txt key=TEXT_EMAIL}*</label>
                                    <div class="col col-md-9">
                                        {form id=cust_info_customers_email_address type=text name='cust_info[customers_email_address]' value=$cust_info.customers_email_address}
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="cust_info_customers_email_address_confirm" class="col col-md-3">{txt key=TEXT_EMAIL_CONFIRM}*</label>
                                    <div class="col col-md-9">
                                        {form id=cust_info_customers_email_address_confirm type=text name='cust_info[customers_email_address_confirm]' value=$cust_info.customers_email_address_confirm}
                                    </div>
                                </div>
                            </fieldset>

                            {if $show_company eq 1}
                                <fieldset>
                                    <legend>{txt key=TEXT_COMPANY}</legend>
                                    <div class="form-group row">
                                        <label for="default_address_customers_company" class="col col-md-3">{txt key=TEXT_COMPANY_NAME}{if _STORE_COMPANY_MIN_LENGTH > 0}*{/if}</label>
                                        <div class="col col-md-9">
                                            {form id=default_address_customers_company type=text name='default_address[customers_company]' value=$default_address.customers_company}
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="default_address_customers_company_2" class="col col-md-3">{txt key=TEXT_COMPANY_NAME_2}</label>
                                        <div class="col col-md-9">
                                            {form id=default_address_customers_company_2 type=text name='default_address[customers_company_2]' value=$default_address.customers_company_2}
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="default_address_customers_company_3" class="col col-md-3">{txt key=TEXT_COMPANY_NAME_3}</label>
                                        <div class="col col-md-9">
                                            {form id=default_address_customers_company_3 type=text name='default_address[customers_company_3]' value=$default_address.customers_company_3}
                                        </div>
                                    </div>
                                    {if $show_vat eq 1}
                                        <div class="form-group row">
                                            <label for="cust_info_customers_vat_id" class="col col-md-3">{txt key=TEXT_VAT_ID}</label>
                                            <div class="col col-md-9">
                                                {form id=cust_info_customers_vat_id type=text name='cust_info[customers_vat_id]' value=$cust_info.customers_vat_id}
                                            </div>
                                        </div>
                                    {/if}
                                </fieldset>
                            {/if}
                            <fieldset>
                                <legend>{txt key=TEXT_ADDRESS}</legend>
                                <div class="form-group row">
                                    <label for="default_address_customers_street_address" class="col col-md-3">{txt key=TEXT_STREET}*</label>
                                    <div class="col col-md-9">
                                        {form id=default_address_customers_street_address type=text name='default_address[customers_street_address]' value=$default_address.customers_street_address}
                                    </div>
                                </div>
                                {if $show_suburb eq 1}
                                    <div class="form-group row">
                                        <label for="default_address_customers_suburb" class="col col-md-3">{txt key=TEXT_SUBURB}</label>
                                        <div class="col col-md-9">
                                            {form id=default_address_customers_suburb type=text name='default_address[customers_suburb]' value=$default_address.customers_suburb}
                                        </div>
                                    </div>
                                {/if}
                                <div class="form-group row">
                                    <label for="default_address_customers_postcode" class="col col-md-3">{txt key=TEXT_CODE}*</label>
                                    <div class="col col-md-9">
                                        {form id=default_address_customers_postcode type=text name='default_address[customers_postcode]' value=$default_address.customers_postcode}
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="default_address_customers_city" class="col col-md-3">{txt key=TEXT_CITY}*</label>
                                    <div class="col col-md-9">
                                        {form id=default_address_customers_city type=text name='default_address[customers_city]' value=$default_address.customers_city}
                                    </div>
                                </div>
                                <div id="countries" class="form-group row">
                                    <label for="default_address_customers_country_code" class="col col-md-3">{txt key=TEXT_COUNTRY}*</label>
                                    <div class="col col-md-9">
                                        {if isset($default_address.customers_country_code)}
                                            {form params='id="default_address_customers_country_code"' class="form-control" type=select name='default_address[customers_country_code]' value=$country_data default=$default_address.customers_country_code}
                                        {else}
                                            {form params='id="default_address_customers_country_code"' class="form-control" type=select name='default_address[customers_country_code]' value=$country_data default=$smarty.const._STORE_COUNTRY}
                                        {/if}
                                    </div>
                                </div>
                                {if $show_federal_states eq 1}
                                    <div id="federals" class="form-group row"></div>
                                {/if}
                            </fieldset>

                            <fieldset class="inputs-with-prefix">
                                <legend>{txt key=TEXT_CONTACT}</legend>
                                <div class="form-group row">
                                    <label for="default_address_customers_phone" class="col col-md-3">{txt key=TEXT_PHONE}{if _STORE_TELEPHONE_MIN_LENGTH > 0}*{/if}</label>
                                    <div class="col col-md-9">
                                        {if _STORE_SHOW_PHONE_PREFIX eq 'true'}
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-5 col-md-4">
                                                    {if isset($default_address.customers_phone_prefix)}
                                                        {form params='id="default_address_customers_phone_prefix"' type=select name='default_address[customers_phone_prefix]' value=$phone_prefix default=$default_address.customers_phone_prefix}
                                                    {else}
                                                        {form params='id="default_address_customers_phone_prefix"' type=select name='default_address[customers_phone_prefix]' value=$phone_prefix default=$smarty.const._STORE_PHONE_PREFIX}
                                                    {/if}
                                                </div>
                                                <div class="col-xs-12 col-sm-7 col-md-8">
                                                    {form id=default_address_customers_phone type=text name='default_address[customers_phone]' value=$default_address.customers_phone}
                                                </div>
                                            </div>
                                        {else}
                                            {form id=default_address_customers_phone type=text name='default_address[customers_phone]' value=$default_address.customers_phone}
                                        {/if}
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="default_address_customers_mobile_phone" class="col col-md-3">{txt key=TEXT_MOBILE_PHONE}{if _STORE_MOBILE_PHONE_MIN_LENGTH > 0}*{/if}</label>
                                    <div class="col col-md-9">
                                        {if _STORE_SHOW_PHONE_PREFIX eq 'true'}
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-5 col-md-4">
                                                    {if isset($default_address.customers_mobile_phone_prefix)}
                                                        {form params='id="default_address_customers_mobile_phone_prefix"' type=select name='default_address[customers_mobile_phone_prefix]' value=$phone_prefix default=$default_address.customers_mobile_phone_prefix}
                                                    {else}
                                                        {form params='id="default_address_customers_mobile_phone_prefix"' type=select name='default_address[customers_mobile_phone_prefix]' value=$phone_prefix default=$smarty.const._STORE_PHONE_PREFIX}
                                                    {/if}
                                                </div>
                                                <div class="col-xs-12 col-sm-7 col-md-8">
                                                    {form id=default_address_customers_mobile_phone type=text name='default_address[customers_mobile_phone]' value=$default_address.customers_mobile_phone}
                                                </div>
                                            </div>
                                        {else}
                                            {form id=default_address_customers_mobile_phone type=text name='default_address[customers_mobile_phone]' value=$default_address.customers_mobile_phone}
                                        {/if}
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label for="default_address_customers_fax" class="col col-md-3">{txt key=TEXT_FAX}</label>
                                    <div class="col col-md-9">
                                        {if _STORE_SHOW_PHONE_PREFIX eq 'true'}
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-5 col-md-4">
                                                    {if isset($default_address.customers_fax_prefix)}
                                                        {form params='id="default_address_customers_fax_prefix"' type=select name='default_address[customers_fax_prefix]' value=$phone_prefix default=$default_address.customers_fax_prefix}
                                                    {else}
                                                        {form params='id="default_address_customers_fax_prefix"' type=select name='default_address[customers_fax_prefix]' value=$phone_prefix default=$smarty.const._STORE_PHONE_PREFIX}
                                                    {/if}
                                                </div>
                                                <div class="col-xs-12 col-sm-7 col-md-8">
                                                    {form id=default_address_customers_fax type=text name='default_address[customers_fax]' value=$default_address.customers_fax}
                                                </div>
                                            </div>
                                        {else}
                                            {form id=default_address_customers_fax type=text name='default_address[customers_fax]' value=$default_address.customers_fax}
                                        {/if}
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <legend>{txt key=BUTTON_REGISTER}</legend>
                                {if $smarty.const._STORE_ALLOW_GUEST_ORDERS == 'true'}
                                    <div class="form-group row">
                                        <label for="guest-account" class="col col-md-3">{txt key=TEXT_ACCOUNT}*</label>
                                        <div class="col col-md-9">
                                            <select id="guest-account" name="guest-account" class="guest-account form-control">
                                                <option value="register"
                                                        data-content="<span class='glyphicon glyphicon-ok text-success'></span> {txt key=TEXT_I_WANT_TO_REGISTER}">
                                                    {txt key=TEXT_I_WANT_TO_REGISTER}
                                                </option>
                                                <option value="guest"
                                                        data-content="<span class='glyphicon glyphicon-remove text-danger'></span> {txt key=TEXT_I_AM_A_GUEST}">
                                                    {txt key=TEXT_I_AM_A_GUEST}
                                                </option>
                                            </select>
                                            <p class="help-block visible-switch-account visible-register-account">{txt key=TEXT_TXT_NEW_CUSTOMER_GUEST}</p>
                                            <p class="help-block visible-switch-account visible-guest-account">{txt key=TEXT_TXT_GUEST}</p>
                                        </div>
                                    </div>
                                {/if}
                                <div class="form-group row visible-switch-account visible-register-account">
                                    <label for="cust_info_customers_password" class="col col-md-3">{txt key=TEXT_PASSWORD_ENTRY}</label>
                                    <div class="col col-md-9">
                                        {form id=cust_info_customers_password type=password name='cust_info[customers_password]' value=$cust_info.customers_password}
                                    </div>
                                </div>
                                <div class="form-group row visible-switch-account visible-register-account">
                                    <label for="cust_info_customers_password_confirm" class="col col-md-3">{txt key=TEXT_PASSWORD_ENTRY_CONFIRM}</label>
                                    <div class="col col-md-9">
                                        {form id=cust_info_customers_password_confirm type=password name='cust_info[customers_password_confirm]' value=$cust_info.customers_password_confirm}
                                    </div>
                                </div>
                            </fieldset>

                            {hook key=login_create_account_tpl}

                            <div class="form-submit pull-right text-right">
                                {if $show_privacy eq 1}
                                    {content cont_id=2 is_id='false'}
                                    {if $show_privacy_type eq 1}
                                        <div class="checkbox">
                                            <label>
                                                {form type=checkbox name=privacy value=1}
                                                {txt key=TEXT_PRIVACY_TEXT_INFO} <a href="{$privacy_link}" target="_blank">{txt key=TEXT_PRIVACY_TEXT}</a>{txt key=TEXT_DOT}
                                            </label>
                                        </div>
                                    {else}
                                        <p>{txt key=TEXT_PRIVACY_TEXT_INFO} <a href="{$privacy_link}" target="_blank">{txt key=TEXT_PRIVACY_TEXT}</a>{txt key=TEXT_DOT}</p>
                                    {/if}
                                {/if}
                                <p>
                                    <a href="{link page='customer' paction='login' conn=SSL}" class="btn btn-default">
                                        {txt key=BUTTON_BACK}
                                    </a>
                                    <button type="submit" class="btn btn-primary">
                                        {txt key=BUTTON_NEXT}
                                    </button>
                                </p>
                            </div>

                            <div class="clearfix visible-xs"></div>

                            <p class="required pull-right-xs">{txt key=TEXT_MUST}</p>
                            <div class="clearfix"></div>

                        {form type=formend}

                        <div style="display:none;">
                            {foreach item='federal_states' from=$country_data}
                                {if $federal_states.federal_states}
                                    <div class="form-group {$federal_states.id}">
                                        <label for="default_address_customers_federal_state_code" class="col col-md-3">{txt key=TEXT_FEDERAL_STATES}*</label>
                                        <div class="col col-md-9">
                                            {form params='id="default_address_customers_federal_state_code"' class="form-control" type=select name='default_address[customers_federal_state_code]' value=$federal_states.federal_states default=$default_address.customers_federal_state_code}
                                        </div>
                                    </div>
                                {/if}
                            {/foreach}
                        </div>

                        {block name=pages_login_jsCountries}
                            {literal}
                                <script type="text/javascript">
                                /* <![CDATA[ */
                                var dobClicked = false;
                                var dobPreselect = {/literal}new Date({$dobPreselect}){literal};
                                $(document).ready(function(){
                                    $('#countries').change(function(){
                                        var selected_country = $('#countries option:selected').val();
                                        if($('.'+selected_country).length != 0){
                                            $('#federals').html($('.'+selected_country).html());
                                        } else {
                                            $('#federals').html('');
                                        }

                                        //update bootstrap-select
                                        $("#federals select, #countries select").attr('data-live-search', 'true').selectpicker('render');
                                    });
                                    var selected_country = $('#countries option:selected').val();
                                    if($('.'+selected_country).length != 0){
                                        $('#federals').html($('.'+selected_country).html());
                                    } else {
                                        $('#federals').html('');
                                    }

                                    //update bootstrap-select
                                    $("#federals select, #countries select").attr('data-live-search', 'true').selectpicker('render');

                                    var dobInput = $('#default_address_customers_dob');
                                    if (dobInput.length) {
                                        dobInput.datetimepicker({
                                            minDate: new Date({/literal}{$min_date}{literal}),
                                            maxDate:  new Date({/literal}{$max_date}{literal}),
                                            useCurrent: false,
                                            format: '{/literal}{$smarty.const._STORE_ACCOUNT_DOB_FORMAT|upper}{literal}',
                                            locale: '{/literal}{if $federal_states.language_code == "bp"}pt{else}{$federal_states.language_code}{/if}{literal}'
                                        }).on('dp.show', function()
                                        {
                                            if (!dobClicked && dobPreselect!=false){
                                                dobInput.data("DateTimePicker").date( dobPreselect );// set
                                                {/literal}{if $is_new}{literal}dobInput.data("DateTimePicker").date( null ); // and unset to unselect and force user to click{/literal}{/if}{literal}
                                                dobClicked = true;
                                            }
                                        });
                                    }
                                });
                                /* ]]> */
                                </script>
                            {/literal}
                        {/block}
                    </div>
                </div>
            </div>
        </div>
        {/if}

    </div>
{/block}