<h2>My Cart</h2>
{% if cart.item_count == 0 %}
    <p>Your Cart is currently empty. why not start here...</p>

{% include 'collection-listing' %}


{% else %}
<script type="text/javascript">
  function remove_item(id) {
      document.getElementById('updates_'+id).value = 0;
      document.getElementById('cartform').submit();
  }
</script>
<form action="/cart" method="post" id="cartform">
	<table id="basket">
    <thead>
	    <tr>
        	<th class="nomob">Item Image</th>
			<th>Item Title</th>
			<th>Price</th>
			<th style="text-align: center">Qty</th>
			<th>Delete</th>
			<th>Total</th>
		</tr>
    </thead>
    <tbody>
    {% for item in cart.items %}
		<tr>
        <td class="nomob">
            <a href="{{ item.product.url }}" title="{{ item.product.title | escape }}">
              {% assign found = false %}
              {% for img in item.product.images %}
                {% if found == false and item.variant.title contains img.alt %}
                  <img src="{{ img | product_img_url: 'small' }}"  alt="{{ item.alt | escape }}" />
                  {% assign found = true %}
                 {% endif %}
              {% endfor %}
              {% if found == false %}
                <img src="{{ item.product.featured_image | product_img_url: 'small' }}"  alt="{{ item.product.featured_image.alt | escape }}" />
              {% endif %}           
            </a>
        </td>
			<td>
				<p><a href="{{ item.product.url }}">{{ item.title }}</a></p>
			</td>
          <td><p><span class="money">{{ item.price | money }}</span>{% if item.variant.compare_at_price > item.price %} / <del><span class="money">{{ item.variant.compare_at_price | money }}</span></del>{% endif %}</p></td>
			<td><input type="text" size="4" name="updates[{{ item.id }}]" id="updates_{{ item.variant.id }}" value="{{ item.quantity }}" onfocus="this.select();"/></td>
			<td><a href="#" onclick="remove_item({{ item.variant.id }}); return false;">Remove</a></td>
          <td><span class="money">{{ item.line_price | money }}</span></td>
		</tr>{% endfor %}
    </tbody>
	</table>
	<div id="basket-right">
      <h3>Subtotal <span class="money">{{ cart.total_price | money }}</span></h3>
        <input type="submit" name="update" id="update-cart" value="Update"/>
        <input type="submit" name="checkout" id="checkout" value="Checkout"/>
        <div class="clear"></div>
            {% if additional_checkout_buttons %}
            <div class="additional-checkout-buttons">
              {{ content_for_additional_checkout_buttons }}
            </div>
            {% endif %}
	</div>  


</form>{% endif %}



