<?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
 */
?>

<?php
/**
 * Temlate for Mage_Customer_Block_Address_Book block
 * @var $test Mage_Customer_Block_Address_Book
 */
?>

<h1><?php echo $this->__('Address Book') ?></h1>

<div class="white-box-inner">
	<div class="page-messages">
		<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
	</div>
	<div class="col2-set addresses-list">
	    <div class="col-1 addresses-primary">
	        <ul>
	        <?php if($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling()): ?>
	            <li class="item">
	                <h3><?php echo $this->__('Default Billing Address') ?></h3>
	                <address>
	                    <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>
	                </address>
	                <p><a href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Billing Address') ?></a></p>
	           </li>
	        <?php else: ?>
	            <li class="item">
	                <h3><?php echo $this->__('Default Billing Address') ?></h3>
	                <?php echo $this->__('You have no default billing address in your address book.') ?>
	            </li>
	        <?php endif ?>

	        <?php if($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping()): ?>
	            <li class="item">
	                <h3><?php echo $this->__('Default Shipping Address') ?></h3>
	                <address>
	                    <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>
	                </address>
	                <p><a href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Shipping Address') ?></a></p>
	            </li>
	        <?php else: ?>
	            <li class="item empty">
	                <h3><?php echo $this->__('Default Shipping Address') ?></h3>
	                <p><?php echo $this->__('You have no default shipping address in your address book.') ?></p>
	            </li>
	        <?php endif ?>
	        </ul>
	    </div>
	    <div class="col-2 addresses-additional">
	        <h3><?php echo $this->__('Additional Address Entries') ?></h3>
	        <ul>
	        <?php if($_pAddsses = $this->getAdditionalAddresses()): ?>
	            <?php foreach($_pAddsses as $_address): ?>
	            <li class="item">
	                <address>
	                    <?php echo $this->getAddressHtml($_address) ?>
	                </address>
	                <p><a href="<?php echo $this->getUrl('customer/address/edit', array('id'=>$_address->getId())) ?>"><?php echo $this->__('Edit Address') ?></a> <span class="separator">|</span> <a href="#" class="link-remove" onclick="return deleteAddress('<?php echo $_address->getId() ?>');"><?php echo $this->__('Delete Address') ?></a></p>
	            </li>
	            <?php endforeach; ?>
	        <?php else: ?>
	            <li class="item empty">
	                <p><?php echo $this->__('You have no additional address entries in your address book.') ?></p>
	            </li>
	        <?php endif ?>
	        </ul>
	    </div>
	</div>
	
	 <button type="button" title="<?php echo $this->__('Add New Address') ?>" class="button" onclick="window.location='<?php echo $this->getAddAddressUrl() ?>';"><?php echo $this->__('Add New Address') ?></button><br><br>
</div>
<div class="box-action">
    <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
</div>
<script type="text/javascript">
//<![CDATA[
    function deleteAddress(addressId) {
        if(confirm('<?php echo $this->__('Are you sure you want to delete this address?') ?>')) {
            window.location='<?php echo $this->getDeleteUrl() ?>id/'+addressId;
        }
        return false;
    }
//]]>
</script>
