<script type="text/javascript">

<!--

	var addresses = new Array();

	{foreach from=$addresses key=k item=address}

		addresses[{$address.id_address|intval}] = new Array('{$address.company|addslashes}', '{$address.firstname|addslashes}', '{$address.lastname|addslashes}', '{$address.address1|addslashes}', '{$address.address2|addslashes}', '{$address.postcode|addslashes}', '{$address.city|addslashes}', '{$address.country|addslashes}', '{$address.state|default:''|addslashes}');

	{/foreach}

-->

</script>

<script type="text/javascript" src="{$js_dir}order-address.js"></script>



{capture name=path}{l s='Addresses'}{/capture}

{include file=$tpl_dir./breadcrumb.tpl}



<h2>{l s='Addresses'}</h2>



{assign var='current_step' value='address'}

{include file=$tpl_dir./order-steps.tpl}



{include file=$tpl_dir./errors.tpl}



<form action="{$base_dir}order.php" method="post">

	<div class="addresses">

		<p class="address_delivery">

			<label for="id_address_delivery">{l s='Choose a delivery address:'}</label>

			<select name="id_address_delivery" id="id_address_delivery" class="address_select" onchange="updateAddressesDisplay();">

			{foreach from=$addresses key=k item=address}

				<option value="{$address.id_address|intval}" {if $address.id_address == $cart->id_address_delivery}selected="selected"{/if}>{$address.alias|escape:'htmlall':'UTF-8'}</option>

			{/foreach}

			</select>

		</p>

		<p class="checkbox">

			<input type="checkbox" name="same" id="addressesAreEquals" value="1" onclick="updateAddressesDisplay();" onchange="updateAddressesDisplay();" {if $cart->id_address_invoice == $cart->id_address_delivery}checked="checked"{/if} />

			<label for="addressesAreEquals">{l s='Use the same address for billing.'}</label>

		</p>

		<p id="address_invoice_form" {if $cart->id_address_invoice == $cart->id_address_delivery}style="display: none;"{/if}>

			<label for="id_address_invoice" class="strong">{l s='Choose a billing address:'}</label>

			<select name="id_address_invoice" id="id_address_invoice" class="address_select" onchange="updateAddressesDisplay();">

			{foreach from=$addresses key=k item=address}

				<option value="{$address.id_address|intval}" {if $address.id_address == $cart->id_address_invoice}selected="selected"{/if}>{$address.alias|escape:'htmlall':'UTF-8'}</option>

			{/foreach}

			</select>

		</p>



		<ul class="address item" id="address_delivery">

			<li class="address_title">{l s='Your delivery address'}</li>

			<li class="address_company"></li>

			<li class="address_name"></li>

			<li class="address_address1"></li>

			<li class="address_address2"></li>

			<li class="address_city"></li>

			<li class="address_country"></li>

			<li class="address_update"><a href="{$base_dir_ssl}address.php?id_address={$address.id_address|intval}&amp;back=order.php?step=1" title="{l s='Update'}">{l s='Update'}</a></li>

		</ul>

		<ul class="address alternate_item" id="address_invoice">

			<li class="address_title">{l s='Your billing address'}</li>

			<li class="address_company"></li>

			<li class="address_name"></li>

			<li class="address_address1"></li>

			<li class="address_address2"></li>

			<li class="address_city"></li>

			<li class="address_country"></li>

			<li class="address_update"><a href="{$base_dir_ssl}address.php?id_address={$address.id_address|intval}&amp;back=order.php?step=1" title="{l s='Update'}">{l s='Update'}</a></li>

		</ul>

		<br class="clear" />

		<p class="address_add">

			<a href="{$base_dir_ssl}address.php?back=order.php?step=1" title="{l s='Add'}" class="button_large">{l s='Add a new address'}</a>

		</p>

	</div>



	<script type="text/javascript">

	<!--

		updateAddressesDisplay();

	-->

	</script>



	<p class="cart_navigation">

		<input type="hidden" name="step" value="2" />

		<a href="{$base_dir_ssl}order.php?step=0" title="{l s='Previous'}" class="button">&laquo; {l s='Previous'}</a>

		<input type="submit" name="processAddress" value="{l s='Next'} &raquo;" class="exclusive" />

	</p>

</form>

