<?php
/**
 * aheadWorks Co.
 *
 * 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://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
?>

<?php
    define('METHOD_GUEST', defined('Mage_Checkout_Model_Type_Onepage::METHOD_GUEST') ? Mage_Checkout_Model_Type_Onepage::METHOD_GUEST : 'guest');
    define('METHOD_REGISTER', defined('Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER') ? Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER : 'register');
?>

<div>
        <h4><?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?><?php echo $this->__('Checkout as a Guest or Register') ?><?php else: ?><?php echo $this->__('Register to Create an Account') ?><?php endif; ?></h4>

        <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
        <?php else: ?>
            <strong><?php echo $this->__('Register and save time!') ?></strong><br />
            <?php echo $this->__('Register with us for future convenience:') ?>
            <ul class="disc">
                <li><?php echo $this->__('Fast and easy check out') ?></li>
                <li><?php echo $this->__('Easy access to your order history and status') ?></li>
            </ul>
        <?php endif; ?>
        <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
            <ul class="form-list">
                <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
                <li style="margin:5px 0;padding:0;">
                    <input type="radio" name="checkout_method" id="login:guest" value="guest"<?php if($this->getQuote()->getCheckoutMethod()==METHOD_GUEST): ?> checked="checked"<?php endif ?> />
                    <label for="login:guest"><?php echo $this->__('Checkout as Guest') ?></label>
                </li>
                <?php endif; ?>
                <li style="margin:5px 0;padding:0;">
                            <input type="radio" name="checkout_method" id="login:register" value="register"<?php if($this->getQuote()->getCheckoutMethod()==METHOD_REGISTER || !$this->getQuote()->isAllowedGuestCheckout()): ?> checked="checked"<?php endif ?> />
                            <label for="login:register"><?php echo $this->__('Register') ?></label>
                </li>
            </ul>
            <?php else: ?>
                <input type="hidden" name="checkout_method" id="login:register" value="register" checked="checked" />
            <?php endif; ?>
            <div>
                    <div class="a-center">
                        <button type="button" class="form-button" onclick="checkout.setMethod();"><span><?php echo ($this->getQuote()->isAllowedGuestCheckout() ? $this->__('Continue') : $this->__('Register')) ?></span></button>
                    </div>
            </div>

</div>
<div class="separator">
        <h4><?php echo $this->__('Login') ?></h4>
        <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
        <form id="login-form" action="<?php echo $this->getPostAction() ?>" method="post">
             <ul class="form-list">
                <li>
                    <div><label for="email"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label></div>
                    <div class="input-box"><input type="text" class="input-text required-entry validate-email" id="email" name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" /></div>
                </li>
                <li>
                    <div class="col2-alt-set">
                      <div class="col-1 a-left"><label for="password"><?php echo $this->__('Password') ?> <span class="required">*</span></label></div>
                      <div class="col-2 a-right innerbox">
                                <a href="<?php echo $this->getUrl('customer/account/forgotpassword') ?>" class="recover"><?php echo $this->__('Forgot your password?') ?></a>
                      </div>
                      <div class="clear"></div>
                    </div>
                    <div class="input-box"><input type="password" class="input-text required-entry" id="password" name="login[password]" /></div>
                </li>
            </ul>
            <p class="a-center"><button class="form-button" onclick="onepageLogin(this)" ><span><?php echo $this->__('Login') ?></span></button></p>
        </form>
</div>
<script type="text/javascript">
    var loginForm = new VarienForm('login-form', true);
    function onepageLogin(button)
    {
        if(loginForm.validator && loginForm.validator.validate()){
            button.disabled = true;
            loginForm.submit();
        }
    }
</script>
