<div class="{{ is_logged_in ? 'checkout-content' : '' }} checkout-{{ type }}-form">
	{% if (is_logged_in) %}
		<h2 class="secondary-title">
			{{ type == 'payment' ? text_billing_address: text_shipping_address }}
		</h2>
	{% endif %}
	<div class="box-inner">
		<form class="form-{{ type }}">
			{% if (addresses) %}
				<div class="radio">
					<label>
						<input type="radio" name="{{ type }}_address" value="existing" checked="checked"/>
						{{ text_address_existing }}
					</label>
				</div>
				<div id="{{ type }}-existing">
					<select name="{{ type }}_address_id" class="form-control">
						{% for address in addresses %}
							{% if (address['address_id'] == address_id) %}
								<option value="{{ address['address_id'] }}" selected="selected">{{ address['firstname'] }} {{ address['lastname'] }}, {{ address['address_1'] }}, {{ address['city'] }}, {{ address['zone'] }}, {{ address['country'] }}</option>
							{% else %}
								<option value="{{ address['address_id'] }}">{{ address['firstname'] }} {{ address['lastname'] }}, {{ address['address_1'] }}, {{ address['city'] }}, {{ address['zone'] }}, {{ address['country'] }}</option>
							{% endif %}
						{% endfor %}
					</select>
				</div>
				<div class="radio">
					<label>
						<input type="radio" name="{{ type }}_address" value="new"/>
						{{ text_address_new }}
					</label>
				</div>
			{% endif %}
			<div id="{{ type }}-new" style="display: {{ addresses ? 'none' : 'block' }};">
				{% if (name) %}
					<div class="form-group required">
						<label>{{ entry_firstname }}</label>
						<input type="text" name="{{ type }}_firstname" value="{{ attribute(_context, type ~ '_' ~ firstname) }}" id="input-{{ type }}-firstname" class="form-control"/>
					</div>
					<div class="form-group required">
						<label>{{ entry_lastname }}</label>
						<input type="text" name="{{ type }}_lastname" value="{{ attribute(_context, type ~ '_' ~ lastname) }}" id="input-{{ type }}-lastname" class="form-control"/>
					</div>
				{% endif %}

				{% for custom_field in custom_fields %}
					{% if (custom_field['location'] == 'address') %}
						{% if (custom_field['type'] == 'select') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field"
								 data-sort="{{ custom_field['sort_order'] }}">
								<label for="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">{{ custom_field['name'] }}</label>
								<select name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}" class="form-control">
									<option value="">{{ text_select }}</option>
									{% for custom_field_value in custom_field['custom_field_value'] %}
										<option value="{{ custom_field_value['custom_field_value_id'] }}">{{ custom_field_value['name'] }}</option>
									{% endfor %}
								</select>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'radio') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}">
								<label>{{ custom_field['name'] }}</label>
								<div id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">
									{% for custom_field_value in custom_field['custom_field_value'] %}
										<div class="radio">
											<label>
												<input type="radio" name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" value="{{ custom_field_value['custom_field_value_id'] }}"/>
												{{ custom_field_value['name'] }}
											</label>
										</div>
									{% endfor %}
								</div>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'checkbox') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}">
								<label>{{ custom_field['name'] }}</label>
								<div id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">
									{% for custom_field_value in custom_field['custom_field_value'] %}
										<div class="checkbox">
											<label>
												<input type="checkbox" name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}][]" value="{{ custom_field_value['custom_field_value_id'] }}"/>
												{{ custom_field_value['name'] }}
											</label>
										</div>
									{% endfor %}
								</div>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'text') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}" style="width: 100%">
								<label for="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">{{ custom_field['name'] }}</label>
								<input type="text" name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" value="{{ custom_field['value'] }}" placeholder="{{ custom_field['name'] }}" id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}" class="form-control"/>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'textarea') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}" style="width: 100%">
								<label for="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">{{ custom_field['name'] }}</label>
								<textarea name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" rows="5" placeholder="{{ custom_field['name'] }}" id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}" class="form-control">{{ custom_field['value'] }}</textarea>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'file') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}">
								<label>{{ custom_field['name'] }}</label>
								<button type="button" id="button-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}" data-loading-text="{{ text_loading }}" class="btn btn-default"><i class="fa fa-upload"></i> {{ button_upload }}</button>
								<input type="hidden" name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" value="" id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}"/>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'date') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}">
								<label for="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">{{ custom_field['name'] }}</label>
								<div class="input-group date">
									<input type="text" name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" value="{{ custom_field['value'] }}" placeholder="{{ custom_field['name'] }}" data-date-format="YYYY-MM-DD" id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}" class="form-control"/>
									<span class="input-group-btn">
                                        <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                                    </span>
								</div>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'time') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}">
								<label for="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">{{ custom_field['name'] }}</label>
								<div class="input-group time">
									<input type="text" name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" value="{{ custom_field['value'] }}" placeholder="{{ custom_field['name'] }}" data-date-format="HH:mm" id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}" class="form-control"/>
									<span class="input-group-btn">
                                        <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                                    </span>
								</div>
							</div>
						{% endif %}
						{% if (custom_field['type'] == 'datetime') %}
							<div class="form-group{{ custom_field['required'] ? ' required' : '' }} custom-field" data-sort="{{ custom_field['sort_order'] }}">
								<label for="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}">{{ custom_field['name'] }}</label>
								<div class="input-group datetime">
									<input type="text" name="{{ type }}_custom_field[{{ custom_field['custom_field_id'] }}]" value="{{ custom_field['value'] }}" placeholder="{{ custom_field['name'] }}" data-date-format="YYYY-MM-DD HH:mm" id="input-{{ type }}-custom-field{{ custom_field['custom_field_id'] }}" class="form-control"/>
									<span class="input-group-btn">
                                        <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                                    </span>
								</div>
							</div>
						{% endif %}
					{% endif %}
					<div class="clearfix"></div>
				{% endfor %}

				<div class="form-group required" style="width: 100%">
					<label>{{ entry_address_1 }}</label>
					<input type="text" name="{{ type }}_address_1" value="{{ attribute(_context, type ~ '_' ~ address_1) }}" id="{{ type }}_address" class="form-control"/>
				</div>

				<div class="clearfix"></div>

				<div class="form-group required">
					<label>{{ entry_city }}</label>
					<input type="text" name="{{ type }}_city" value="{{ attribute(_context, type ~ '_' ~ city) }}" id="{{ type }}_city" class="form-control"/>
				</div>
				<div class="form-group required">
					<label>{{ entry_postcode }}</label>
					<input type="text" name="{{ type }}_postcode" value="{{ attribute(_context, type ~ '_' ~ postcode) }}" id="{{ type }}_postcode" class="form-control"/>
				</div>
				<div class="clearfix"></div>
				<div class="form-group required">
					<label>{{ entry_country }}</label>
					<select name="{{ type }}_country_id" id="{{ type }}_country" class="form-control">
						{% for country in countries %}
							<option value="{{ country['country_id'] }}" {% if country['country_id'] == 171 %}selected{% endif %}>{{ country['name'] }}</option>
						{% endfor %}
					</select>
				</div>
				<div class="form-group required">
					<label>{{ entry_zone }}</label>
					<select name="{{ type }}_zone_id" id="{{ type }}_zone" class="form-control"></select>
				</div>
			</div>
		</form>
	</div>
</div>
<input type="hidden" name="default_zone_id" id="default_zone_id" value="{{ 171 }}"/>