<div class="page-content">
    <div class="container">
      <div class="row-fluid">
        <div class="span12">
          <ul class="breadcrumb">
          <li><a href="/">Home</a><span class="divider">/</span></li>
          <li><a href="/checkout">Checkout</a><span class="divider">/</span></li>
          <li><a href="/checkout/shipping">Billing</a></li>          
        </ul>
        </div>
      </div>
      
      <div class="row-fluid">
        <div class="span12 single-item">

<h3>Checkout</h3>
<table class='cart'>
<tr>
  <th>Item</th>
  <th>Quantity</th>
  <th>Subtotal</th>
</tr>
<% @order.line_items.each do |li| %>
  <tr>
    <td><%= li.variant.product.title %><br /><%= li.variant.title %></td>
    <td align='right'><%= li.quantity %></td>
    <td align='right'><%= number_to_currency(li.subtotal) %></td>
  </tr>
<% end %>
<tr>
  <td colspan='2' align='right'>Subtotal</td>
  <td align='right'><%= number_to_currency(@order.subtotal) %></td>
</tr>
<tr>
  <td colspan='2' align='right'>Tax</td>
  <td align='right'><%= number_to_currency(@order.tax) %></td>
</tr>
<tr>
  <td colspan='2' align='right'><a href='/checkout/shipping'>(Edit)</a> <%= @order.shipping_method %> Shipping</td>
  <td align='right'><%= number_to_currency(@order.shipping + @order.handling) %></td>
</tr>
<tr>
  <td colspan='2' align='right'>Discount</td>
  <td align='right'><%= number_to_currency(@order.discount) %></td>
</tr>
<tr>
  <td colspan='2' align='right'>Total</td>
  <td align='right'><%= number_to_currency(@order.total) %></td>
</tr>
</table>

        </div>
      </div>      
      <div class="row-fluid">
        <div class="span12 single-item">
          <div class="row-fluid">            
            <div class="span5" style='width: 230px;'>
            
<h2>Shipping Address</h2>
<%
a = @order.shipping_address
str = "#{a.name}<br />#{a.address1}<br />"
str << "#{a.address2}<br />" if a.address2 && a.address2.strip.length > 0
str << "#{a.city}, #{a.state} #{a.zip}"
%>
<p><%= raw str %></p>
<p><a href='/checkout'>Edit shipping address</a></p>

            </div>
            <div class="span5" style='width: 230px;'>
            
<h2>Shipping Method</h2>
<p><%= @order.shipping_method %> - <%= number_to_currency(@order.shipping) %></p>
<p><a href='/checkout/shipping-method'>Edit shipping method</a></p>

            </div>
            <div class="span5" style='width: 320px;'>

<h2>Billing Information</h2>
<div id='billing_info'>
  <form action='/checkout/billing' method='post' id='billing_form'>
  <table>     
    <tr><td>Card number:      </td><td><input type='text' name='card_num' id='card_num' value='' style='width: 200px;' onkeyup='Checkout.space_card_number();' maxlength="25" /></td>
    <tr><td>Expiration:       </td><td><select name='exp_month' id='exp_month' style='width: 90px;'>
      <option value='01'>01 - Jan</option>
      <option value='02'>02 - Feb</option>
      <option value='03'>03 - Mar</option>
      <option value='04'>04 - Apr</option>
      <option value='05'>05 - May</option>
      <option value='06'>06 - Jun</option>
      <option value='07'>07 - Jul</option>
      <option value='08'>08 - Aug</option>
      <option value='09'>09 - Sep</option>
      <option value='10'>10 - Oct</option>
      <option value='11'>11 - Nov</option>
      <option value='12'>12 - Dec</option>
    </select> / <select name='exp_year' id='exp_year' style='width: 80px;'>
    <% (DateTime.now.year...DateTime.now.year+20).each do |i| %>
    <option value='<%= i-2000 %>'><%= i %></option>
    <% end %>
    </select></td></tr>  
    <tr><td>Security Code:  </td><td><input type='text' name='security_code'    id='security_code'    value='' style='width: 60px;' /></td>
    <tr><td>Address:        </td><td><input type='text' name='billing_address1' id='billing_address1' value='' style='width: 200px;' /></td>
    <tr><td>Address 2:      </td><td><input type='text' name='billing_address2' id='billing_address2' value='' style='width: 200px;' /></td>
    <tr><td>Zip code:       </td><td><input type='text' name='billing_zip'      id='billing_zip'      value='' style='width: 100px;' /></td>  
  </table>
  </form>
</div>

            </div>
          </div>
        </div>
      </div>
      <div class="row-fluid">
        <div class="span12 single-item">
          <div class="row-fluid">
          
<div id='message'></div>
<p>
<input type='button' value='< Back' onclick="window.location='/checkout/shipping';" />
<input type='submit' value='Continue >' onclick="Checkout.save_billing_info(); return false;" />
</p>

<%
#<form accept-charset="UTF-8" action="https://test.authorize.net/gateway/transact.dll" method="post" id='authnet_form' target='authnet_iframe'>
#<form accept-charset="UTF-8" action="https://secure.authorize.net/gateway/transact.dll" method="post" id='authnet_form' target='authnet_iframe'>
#<form accept-charset="UTF-8" action="https://developer.authorize.net/tools/paramdump/index.php" method="post" id='authnet_form' target='authnet_iframe'>
%>
<form accept-charset="UTF-8" action="https://secure.authorize.net/gateway/transact.dll" method="post" id='authnet_form' target='authnet_iframe'>
<%= sim_fields(@sim_transaction) %>
<input type='hidden' name='authenticity_token' value="<%= form_authenticity_token %>" />
<input type="hidden" id="x_invoice_num"       name="x_invoice_num"      value="<%= @order.id %>" /> 
<input type="hidden" id="x_card_num"          name="x_card_num"         value="" />
<input type="hidden" id="x_exp_date"          name="x_exp_date"         value="" />
<input type="hidden" id="x_address"           name="x_address"          value="" />
<input type="hidden" id="x_zip"               name="x_zip"              value="" />
<input type="hidden" id="commit"              name="commit"             value="Purchase" />
</form>
<iframe name='authnet_iframe' id='authnet_iframe' style='display: none;'></iframe>

          </div>
        </div>
      </div>
    </div>
  </div>

<%= content_for :caboose_css do %>
<style type='text/css'>

table.cart { border-collapse: collapse; }
table.cart td { border: #666 1px dotted; padding: 4px 8px; }
table.cart th { font-weight: bold; text-align: center; }

</style>
<% end %>
<%= content_for :caboose_js do %>
<%= javascript_include_tag 'checkout' %>
<script type='text/javascript'>

$(document).ready(function() {
  
});

</script>
<% end %>