<?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
 * @package     default_iphone
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<form id="co-billing-form" action="">
<?php if ($this->customerHasAddresses()): ?>
    <p><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></p>
    <ul><li><p class="select300inner"><?php echo $this->getAddressesHtmlSelect('billing') ?></p></li></ul>

<?php endif ?>
    <fieldset class="group-select" id="billing-new-address-form" <?php if ($this->customerHasAddresses()): ?>style="display:none"<?php endif ?>>
        <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />
        <ul class="form-list">
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:firstname"><?php echo $this->__('First Name') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="text" id="billing:firstname" name="billing[firstname]" value="<?php echo $this->htmlEscape($this->getFirstname()) ?>" title="<?php echo $this->__('First Name') ?>" class="required-entry input-text" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:lastname"><?php echo $this->__('Last Name') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="text" id="billing:lastname" name="billing[lastname]" value="<?php echo $this->htmlEscape($this->getLastname()) ?>" title="<?php echo $this->__('Last Name') ?>" class="required-entry input-text" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:company"><?php echo $this->__('Company') ?></label>
                </div><div class="col-2">
                    <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" />
                </div></div><div class="clear"></div>
            </li>
            <?php if(!$this->isCustomerLoggedIn()): ?>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:email"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" />
                </div></div><div class="clear"></div>
            </li>
            <?php endif ?>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:street1"><?php echo $this->__('Address') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="text" title="<?php echo $this->__('Street Address') ?>" name="billing[street][1]" id="billing:street1" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet(1)) ?>" class="required-entry input-text" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    &nbsp;
                </div><div class="col-2">
                    <input type="text" title="<?php echo $this->__('Street Address 2') ?>" name="billing[street][2]" id="billing:street2" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet(2)) ?>" class="input-text" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:city"><?php echo $this->__('City') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="text" title="<?php echo $this->__('City') ?>" name="billing[city]" value="<?php echo $this->htmlEscape($this->getAddress()->getCity()) ?>" class="required-entry input-text" id="billing:city" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:region"><?php echo $this->__('State/Province') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="width:190px;display:none">
                        <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
                    </select>
                    <script type="text/javascript">
                        $('billing:region_id').setAttribute('defaultValue',  "<?php echo $this->getAddress()->getRegionId() ?>");
                    </script>
                    <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>"  title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:country_id"><?php echo $this->__('Country') ?> <span class="required">*</span></label>
                </div><div class="col-2 select190inner">
                    <?php echo $this->getCountryHtmlSelect('billing') ?>
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:telephone"><?php echo $this->__('Telephone') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="text" name="billing[telephone]" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="required-entry input-text" id="billing:telephone" />
                </div></div><div class="clear"></div>
            </li>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:fax"><?php echo $this->__('Fax') ?></label>
                </div><div class="col-2">
                    <input type="text" name="billing[fax]" value="<?php echo $this->htmlEscape($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text" id="billing:fax" />
                </div></div><div class="clear"></div>
            </li>
            <?php if(!$this->isCustomerLoggedIn()): ?>

            <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
            <?php if ($_dob->isEnabled()): ?>
                        <li>
                            <?php echo $_dob->setDate($this->getQuote()->getCustomerDob())
                                ->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
                        </li>
            <?php endif ?>

            <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
            <?php if ($_taxvat->isEnabled()): ?>
                        <li>
                            <?php echo $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())
                                ->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
                        </li>
            <?php endif ?>

            <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
            <?php if ($_gender->isEnabled()): ?>
                        <li>
                            <?php echo $_gender->setGender($this->getQuote()->getCustomerGender())
                                ->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
                        </li>
            <?php endif ?>

            <li id="register-customer-password">
                <div class="col2-alt-set"><div class="col-1">
                    <label for="billing:customer_password"><?php echo $this->__('Password') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo $this->__('Password') ?>" class="required-entry validate-password input-text" />
                </div></div><div class="clear"></div>
                <div class="col2-alt-set" style="margin-top:8px;"><div class="col-1">
                    <label for="billing:confirm_password"><?php echo $this->__('Confirm Password') ?> <span class="required">*</span></label>
                </div><div class="col-2">
                    <input type="password" name="billing[confirm_password]" title="<?php echo $this->__('Confirm Password') ?>" id="billing:confirm_password" class="required-entry validate-cpassword input-text" />
                </div></div><div class="clear"></div>
            </li>
            <?php endif ?>
            <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
            <li>
                <div class="col2-alt-set"><div class="col-1">
                    <input type="checkbox" name="billing[save_in_address_book]" value="1" title="<?php echo $this->__('Save in address book') ?>" id="billing:save_in_address_book" onchange="if(window.shipping) shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> />
                </div><div class="col-2">
                    <label for="billing:save_in_address_book"><?php echo $this->__('Save in Address Book') ?></label>
                </div></div><div class="clear"></div>
            </li>
            <?php else:?>
            <input type="hidden" name="billing[save_in_address_book]" value="1" />
            <?php endif;?>
        </ul>
    </fieldset>
    <?php if ($this->canShip()): ?>
    <p>
        <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1" <?php if ($this->isUseBillingAddressForShipping()) {?>checked="checked" <?php }?>onclick="$('shipping:same_as_billing').checked = true;" />&nbsp;<label for="billing:use_for_shipping_yes"><?php echo  $this->__('Ship to this address') ?></label>&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0" <?php if (!$this->isUseBillingAddressForShipping()) {?>checked="checked" <?php }?>onclick="$('shipping:same_as_billing').checked = false;" />&nbsp;<label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address') ?></label>&nbsp;&nbsp;&nbsp;&nbsp;
    </p>
    <?php else: ?>
        <input type="hidden" name="billing[use_for_shipping]" value="1" />
    <?php endif; ?>
</form>
<div class="col2-alt-set button-set">
    <div class="col-1">
        <p class="required"><?php echo $this->__('* Required Fields') ?></p>
    </div>
    <div class="col-2">
        <div class="form-buttons">
            <span id="billing-buttons-container" >
                <span id="billing-please-wait" style="display:none;" class="opc-please-wait">
                    <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" class="v-middle" alt="" /> &nbsp; <?php echo $this->__('Loading next step...') ?> &nbsp;
                </span><br />
                <button type="button" class="form-button right" onclick="billing.save();"><span><?php echo $this->__('Continue') ?></span></button>
            </span>
        </div>
    </div>
</div><div class="clear"></div>

<script type="text/javascript">
<!--
    var billing = new Billing('co-billing-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>');
    var billingForm = new VarienForm('co-billing-form');

    //billingForm.setElementsRelation('billing:country_id', 'billing:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
    $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);

    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', countryRegions, undefined, 'billing:postcode');
//-->
</script>
