<?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
/**
 * One page checkout payment methods
 *
 * @see Mage_Checkout_Block_Onepage_Payment_Methods
 */
?>
<?php
    $isFree = false;
    $methods = $this->getMethods();
    $_showMethods = array();
    foreach ($methods as $_method){
        $_code = $_method->getCode();
        if ($_code == 'free'){
            $isFree = true;
        }
    }
    foreach ($methods as $_method){
        $_code = $_method->getCode();
        if ($isFree){
            if ($_code == 'free'){
                $_showMethods[] = $_method;
            }            
        } else {
            $_showMethods[] = $_method;
        }
    }
?>
<div class="payment-methods bottom-space">
    <dl id="checkout-payment-method-load">
    <?php foreach ($_showMethods as $_method): $_code = $_method->getCode() ?>
        <dt>
        <?php if( sizeof($this->getMethods()) > 1 ): ?>
            <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if(($this->getSelectedMethodCode()==$_code) || $isFree): ?> checked="checked"<?php endif; ?> />
        <?php else: ?>
            <span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" /></span>
        <?php endif; ?>
            <label for="p_method_<?php echo $_code ?>"><?php echo $_method->getTitle() ?></label>
        </dt>
        <dd>
            <?php echo $this->getChildHtml('payment.method.'.$_code) ?>
        </dd>
    <?php endforeach; ?>
    </dl>
</div>
<script type="text/javascript">
payment.init();
</script>
