<?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
/**
 * Edit customer address template
 *
 * @see Mage_Customer_Block_Address_Edit
 */
?>

<div class="white-box">
	<?php if($this->getTitle()): ?>
	    <h1 style="margin:0"><?php echo $this->getTitle() ?></h1>
	<?php endif; ?>
	
	<div class="page-messages">
		<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
	</div>
	
	<form action="<?php echo $this->getSaveUrl() ?>" method="post" id="form-validate" class="site-form">
	<h3 class="legend"><?php echo $this->__('Contact Information') ?></h3>
	<div class="white-box-inner">
	    <div class="fieldset">
	    <?php echo $this->getBlockHtml('formkey')?>
	    <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
	    <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
	        <ul class="form-list">
	            <li class="fields">
	                <?php echo $this->getNameBlockHtml() ?>
	            </li>
	            <li class="field">
	                <label for="company"><?php echo $this->__('Company') ?></label>
	                <div class="input-box">
	                    <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" class="input-text" />
	                </div>
	            </li>
	            <li class="fields">
	                <div class="field">
	                    <label for="telephone" class="required"><?php echo $this->__('Phone') ?><em>*</em></label>
	                    <div class="input-box">
	                        <input type="text" name="telephone" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Phone') ?>" class="input-text required-entry" id="telephone" />
	                    </div>
	                </div>
	                <div class="field">
	                    <label for="fax"><?php echo $this->__('Fax') ?></label>
	                    <div class="input-box">
	                        <input type="text" name="fax" id="fax" title="<?php echo $this->__('Fax') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getFax()) ?>" class="input-text" />
	                    </div>
	                </div>
	            </li>
	        </ul>
	    </div>
	</div>
	
	<h3 class="legend"><?php echo $this->__('Address') ?></h3>
	<div class="white-box-inner">
	    <div class="fieldset">
	        <ul class="form-list">
	            <li class="field">
	                <label for="street_1" class="required"><?php echo $this->__('Street Address') ?><em>*</em></label>
	                <div class="input-box">
	                    <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text required-entry" />
	                </div>
			        <?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
						<label>&nbsp;</label>
		                <div class="input-box">
		                    <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i?>" class="input-text" />
		                </div>
			        <?php endfor ?>
	            </li>
	            <li class="fields">
	                <div class="field">
	                    <label for="city" class="required"><?php echo $this->__('City') ?><em>*</em></label>
	                    <div class="input-box">
	                        <input type="text" name="city" value="<?php echo $this->htmlEscape($this->getAddress()->getCity()) ?>"  title="<?php echo $this->__('City') ?>" class="input-text required-entry" id="city" />
	                    </div>
	                </div>
	                <div class="field">
	                    <label for="region_id" class="required"><?php echo $this->__('State/Province') ?><em>*</em></label>
	                    <div class="input-box">
	                        <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
	                           <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
	                        </select>
	                        <script type="text/javascript">
	                        //<![CDATA[
	                            $('region_id').setAttribute('defaultValue',  "<?php echo $this->getAddress()->getRegionId() ?>");
	                        //]]>
	                        </script>
	                        <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>"  title="<?php echo $this->__('State/Province') ?>" class="input-text" />
	                    </div>
	                </div>
	            </li>
	            <li class="fields">
	                <div class="field">
	                    <label for="zip" class="required"><?php echo $this->__('Zip/Postal Code') ?><em>*</em></label>
	                    <div class="input-box">
	                        <input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international required-entry" />
	                    </div>
	                </div>
	                <div class="field">
	                    <label for="country" class="required"><?php echo $this->__('Country') ?><em>*</em></label>
	                    <div class="input-box">
	                        <?php echo $this->getCountryHtmlSelect() ?>
	                    </div>
	                </div>
	            </li>
	            <li<?php if($this->canSetAsDefaultBilling()) echo ' class="control"' ?>>
	                <?php if($this->isDefaultBilling()): ?>
	                    <strong><?php echo $this->__('Default Billing Address') ?></strong>
	                <?php elseif($this->canSetAsDefaultBilling()): ?>
						<table class="checkbox-field"><tr><td>
	                    	<input type="checkbox" id="primary_billing" name="default_billing" value="1" title="<?php echo $this->__('Use as My Default Billing Address') ?>" class="checkbox" />
						</td><td>
							<label for="primary_billing"><?php echo $this->__('Use as my default billing address') ?></label>
						</td></tr></table>
	                <?php else: ?>
	                    <input type="hidden" name="default_billing" value="1" />
	                <?php endif; ?>
	            </li>
	            <li<?php if($this->canSetAsDefaultShipping()) echo ' class="control"' ?>>
	                <?php if($this->isDefaultShipping()): ?>
	                    <strong><?php echo $this->__('Default Shipping Address') ?></strong>
	                <?php elseif($this->canSetAsDefaultShipping()): ?>
						<table class="checkbox-field"><tr><td>
	                    	<input type="checkbox" id="primary_shipping" name="default_shipping" value="1" title="<?php echo $this->__('Use as My Default Shipping Address') ?>" class="checkbox" />
						</td><td>
							<label for="primary_shipping"><?php echo $this->__('Use as my default shipping address') ?></label>
						</td></tr></table>
	                <?php else: ?>
	                    <input type="hidden" name="default_shipping" value="1" />
	                <?php endif; ?>
	            </li>
	        </ul>
	    </div>
	
	    <div class="buttons-set">
	        <button type="submit" title="<?php echo $this->__('Save Address') ?>" class="button"><span><span><?php echo $this->__('Save Address') ?></span></span></button>
	    </div>
	</div>
	</form>
	<script type="text/javascript">
	//<![CDATA[
	    var dataForm = new VarienForm('form-validate', true);
	    new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
	//]]>
	</script>
</div>