<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_default
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<h2>Address Book</h2>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<table cellspacing="0" width="100%">
    <tr>
        <td style="width:50%;"><h3>Primary</h3>
            <table width="100%" cellspacing="0"> 
            <?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 primary 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 width="100%" cellspacing="0"> 
            <?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">|</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-container">
    <a href="<?php echo $this->getUrl('customer/account/') ?>" class="float-left">&laquo; <?php echo $this->__('Back') ?></a>
    <input type="button" onclick="window.location='<?php echo $this->getUrl('customer/address/form') ?>';" value="<?php echo $this->__('New Address') ?>" class="input-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>