<?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
 */
?>
<div id="registration" class="grid_12 white-box">
    <h1 style="margin: 0"><?php echo $this->__('Create an Account') ?></h1>

    <?php echo $this->getChildHtml('form_fields_before')?>

	<div class="page-messages">
    	<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
	</div>
	
    <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate" class="site-form">
        <div class="fieldset">
            <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
            <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
            <h3 class="legend"><?php echo $this->__('Personal Information') ?></h3>
			<div class="inner-box">
           		<ul class="form-list">
	                <li class="fields">
	                    <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->toHtml() ?>
	                </li>
	            <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
	            <?php if ($_dob->isEnabled()): ?>
	                <li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
	            <?php endif ?>
	            <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
	            <?php if ($_taxvat->isEnabled()): ?>
	                <li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
	            <?php endif ?>
	            <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
	            <?php if ($_gender->isEnabled()): ?>
	                <li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
	            <?php endif ?>
	            </ul>
			</div>
        </div>
    <?php if($this->getShowAddressFields()): ?>
        <div class="fieldset">
            <input type="hidden" name="create_address" value="1" />
            <h3 class="legend"><?php echo $this->__('Address Information') ?></h3>

			<div class="inner-box">
        	    <ul class="form-list">
	                <li class="fields">
	                    <div class="field">
	                        <label for="company"><?php echo $this->__('Company') ?></label>
	                        <div class="input-box">
	                            <input type="text" name="company" id="company" value="<?php echo $this->htmlEscape($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" />
	                        </div>
	                    </div>
	                    <div class="field">
	                        <label for="telephone" class="required"><?php echo $this->__('Telephone') ?><em>*</em></label>
	                        <div class="input-box">
	                            <input type="text" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text required-entry" />
	                        </div>
	                    </div>
	                </li>
	                <li class="fields">
	                	<div 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->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text required-entry" />
		                    </div>
		                </div>
	                </li>
		            <?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
	                <li class="fields" style="margin-top: -10px">
	                	<div class="field">
	                		<label>&nbsp;</label>
		                    <div class="input-box">
		                        <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i?>" class="input-text" />
		                    </div>
		                </div>
	                </li>
		            <?php endfor ?>
	                <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->getFormData()->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->getFormData()->getRegionId() ?>");
	                            //]]>
	                            </script>
	                            <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
	                        </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->getFormData()->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>
	            </ul>
			</div>
            <input type="hidden" name="default_billing" value="1" />
            <input type="hidden" name="default_shipping" value="1" />
        </div>
    <?php endif; ?>
        <div class="fieldset">
            <h3 class="legend"><?php echo $this->__('Login Information') ?></h3>

			<div class="inner-box">
       	     <ul class="form-list">
	                <li class="fields">
		                <div class="field">
		                    <label for="email_address" class="required"><?php echo $this->__('Email') ?><em>*</em></label>
		                    <div class="input-box">
		                        <input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
		                    </div>
		                </div>
	                    <div class="field">
	                        <label for="password" class="required"><?php echo $this->__('Password') ?><em>*</em></label>
	                        <div class="input-box">
	                            <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
	                        </div>
	                    </div>
	                    <div class="field">
	                        <label for="confirmation" class="required"><?php echo $this->__('Confirm Password') ?><em>*</em></label>
	                        <div class="input-box">
	                            <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
	                        </div>
	                    </div><br>
            <?php echo $this->getChildHtml('form.additional.info'); ?>
	          <?php echo $this->getChildHtml('persistent.remember.me'); ?>
						<?php if ($this->isNewsletterEnabled()): ?>
						<div class="field">
							<table class="checkbox-field"><tr><td>
		                		<input type="checkbox" class="input-radio" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
							</td><td>
		                    	<label for="is_subscribed" class="inline-label">&nbsp;&nbsp;<?php echo $this->__('Subscribe to our newsletter to receive special offers.') ?></label>
							</td></tr></table>
						</div>
						<?php endif ?>
	                </li>
	            </ul>
	          <?php echo $this->getChildHtml('persistent.remember.me.tooltip'); ?>
		        <div class="buttons-set">
		            <button type="submit" title="<?php echo $this->__('Submit') ?>" class="action-button"><span><?php echo $this->__('Create Account') ?></span></button>
		        </div>
			</div>
        </div>
        <?php if (Mage::helper('checkout')->isContextCheckout()): ?>
            <input name="context" type="hidden" value="checkout" />
        <?php endif; ?>
    </form>
    <script type="text/javascript">
    //<![CDATA[
        var dataForm = new VarienForm('form-validate', true);
        <?php if($this->getShowAddressFields()): ?>
        new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
        <?php endif; ?>
    //]]>
    </script>
</div>
