<?php
/**
 * Avalanche for Magento 1.8+
 * Designed by Fast Division (http://fastdivision.com)
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file license.txt.
 * It is also available through the world-wide-web at this URL:
 * http://fastdivision.com/legal/license.txt
 *
 * @author     Fast Division
 * @version    1.5.0
 * @copyright  Copyright 2013 Fast Division
 * @license    http://fastdivision.com/legal/license.txt
 */
?>
<div class="page-title">
    <h1><?php echo $this->__('Address Books') ?></h1>
</div>

<div class="page-messages">
	<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
</div>

<table style="width: 100%">
    <tr>
        <td style="width:50%;"><h3>Default</h3>
            <table style="width: 100%">
            <?php if(!empty($primaryAddresses)): ?>
                <?php foreach($primaryAddresses as $_address): ?>
                <tr>
                    <td>
                    <address>
                        <?php echo $_address->format('html') ?>
                    </address>
                    <p>
                        <strong><a href="<?php echo $this->getUrl('customer/address/form', array('address'=>$_address->getAddressId())) ?>" class="red-link"><?php echo $this->__('Edit Address') ?></a></strong>
                    </p>
                    </td>
                </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr>
                    <td>
                        <p><?php echo $this->__('You have no default entries in your address book.') ?></p>
                    </td>
                </tr>
            <?php endif ?>
            </table>
        </td>
        <td style="width: 50%;"><h3><?php echo $this->__('Additional Address Entries') ?></h3>
            <table style="width: 100%">
            <?php if(!empty($alternativeAddresses)): ?>
                <?php foreach($alternativeAddresses as $_address): ?>
                <tr>
                    <td>
                    <address>
                        <?php echo $_address->format('html') ?>
                    </address>
                    <p>
                        <strong><a href="<?php echo $this->getUrl('customer/address/form', array('address'=>$_address->getAddressId())) ?>" class="red-link"><?php echo $this->__('Edit Address') ?></a></strong><span class="separator">&nbsp;|&nbsp;</span><strong><a href="#" onclick="return deleteAddress('<?php echo $_address->getAddressId() ?>');" class="red-link"><?php echo $this->__('Delete Address') ?></a></strong>
                    </p>
                    </td>
                </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr>
                    <td>
                        <p><?php echo $this->__('You have no additional entries in your address book.') ?></p>
                    </td>
                </tr>
            <?php endif ?>
            </table>
        </td>
    </tr>
</table>
<div class="buttons-set">
    <p class="back-link"><a href="<?php echo $this->getUrl('customer/account/') ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
    <button type="button" onclick="window.location='<?php echo $this->getUrl('customer/address/form') ?>';" class="button"><span><span><?php echo $this->__('New Address') ?></span></span></button>
</div>
<script type="text/javascript">
    function deleteAddress(addressId) {
        if(confirm('<?php echo $this->__('Are you sure you want to delete this address?') ?>')) {
            window.location='<?php echo $this->getUrl("customer/address/delete") ?>address/'+addressId;
        }
        return false;
    }
</script>
