
<?php
/**
 * Edit customer address template
 *
 * @see Mage_Customer_Block_Address_Edit
 */
?>

<?php if($this->getTitle()): ?>
<div class="page-title">
    <h2><?php echo $this->getTitle() ?></h2>
</div>
<?php endif; ?>

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<form action="<?php echo $this->getSaveUrl() ?>" method="post" id="form-validate">
    <div class="fieldset group-select">
    <?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() ?>" />
        <h2 class="legend"><?php echo $this->__('Contact Information') ?></h2>
        <ul class="">
            <li class="">
                <?php echo $this->getNameBlockHtml() ?>
            </li>
            <li class="">
                <div class="">
                    <label for="company"><?php echo $this->__('Company') ?></label>
                    <br />
                    <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
                </div>
            </li>
            <li class="">
                
                    <div class="input-box">
                    <label for="telephone"><?php echo $this->__('Telephone') ?><em class="required">*</em></label>
                    <br />
                        <input type="text" name="telephone" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text  <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="telephone" />
                    </div>
            
                   <div class="input-box">
                    <label for="fax"><?php echo $this->__('Fax') ?></label>
                    <br />
                        <input type="text" name="fax" id="fax" title="<?php echo $this->__('Fax') ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" />
                    </div>
                
            </li>
        </ul>
    </div>
    <div class="fieldset group-select">
        <h2 class="legend"><?php echo $this->__('Address') ?></h2>
        <ul class="">
        <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
            <li class="">
                <label for="street_1"><?php echo $this->__('Street Address') ?><em class="required">*</em></label>
                <br />
                    <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
                
            </li>
        <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
        <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
            <li class="">
                
                    <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
                
            </li>
        <?php endfor; ?>
            <?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
            <li class="">
                <label for="vat_id"><?php echo $this->__('VAT Number') ?></label>
                <br />
                    <input type="text" name="vat_id" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo $this->__('VAT Number') ?>" id="vat_id" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
                
            </li>
            <?php endif; ?>
            <li class="">
                <div class="field">
                    <div class="input-box">
                    <label for="city"><?php echo $this->__('City') ?><em class="required">*</em></label>
                    <br />
                        <input type="text" name="city" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"  title="<?php echo $this->__('City') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
                    </div>
                </div>
                <div class="field">
                    <div class="input-box">
                    <label for="region_id"><?php echo $this->__('State/Province') ?></label>
                    <br />
                        <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->escapeHtml($this->getAddress()->getRegion()) ?>"  title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" />
                    </div>
                </div>
            </li>
            <li class="">
                <div class="field">
                    <div class="input-box">
                    <label for="zip"><?php echo $this->__('Zip/Postal Code') ?><em class="required">*</em></label>
                    <br />
                        <input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
                    </div>
                </div>
                <div class="field">
                    <div class="input-box">
                    <label for="country"><?php echo $this->__('Country') ?><em class="required">*</em></label>
                    <br />
                        <?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()): ?>
                    <input type="checkbox" id="primary_billing" name="default_billing" value="1" title="<?php echo $this->__('Use as My Default Billing Address') ?>" class="checkbox" /><label for="primary_billing"><?php echo $this->__('Use as my default billing address') ?></label>
                <?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()): ?>
                    <input type="checkbox" id="primary_shipping" name="default_shipping" value="1" title="<?php echo $this->__('Use as My Default Shipping Address') ?>" class="checkbox" /><label for="primary_shipping"><?php echo $this->__('Use as my default shipping address') ?></label>
                <?php else: ?>
                    <input type="hidden" name="default_shipping" value="1" />
                <?php endif; ?>
            </li>
        </ul>
    </div>
    <div class="buttons-set">
        <p class="required"><?php echo $this->__('* Required Fields') ?></p>
        <button type="submit" title="<?php echo $this->__('Save Address') ?>" class="button"><span><?php echo $this->__('Save Address') ?></span></button>
        <a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a>
    </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>