function update_order_form_values() {
  total_value = 0;
  quantity_count = 0;

  $j('input.quantity').each(function() {
    id = this.id.split(/-/)[1];
    item_area = $j('#item_display-'+id);
    quantity 	 = $j('#item_quantity-'+id).val();

    prices = item_prices['item_'+id];
    $j.each(prices, function(i, price) {
      if (quantity >= price[0] ) {
        item_price = price[1];
      }
    });

    row_value  = item_price * quantity;

    item_area.find('.quantity').text(quantity);
    item_area.find('.unit_price').text(number_to_currency(item_price));
    item_area.find('.total_price').text(number_to_currency(row_value));

    if (quantity > 0) {
      item_area.show();
    } else {
      item_area.hide();
    }

    quantity_count += quantity;
    total_value += row_value;
  });

  if (total_value == 0 || total_value >= 40) {
    shipping = 0;
  } else { 
    shipping = 3.75; 
  }
  
  $j('#shipping .currency').text(number_to_currency(shipping));
  total_value += shipping;

  if (quantity_count > 0) {
    $j('#shipping').show();
    $j('#nothing_ordered').hide();
  } else{
    $j('#shipping').hide();
    $j('#nothing_ordered').show();
  }
  $j('#full_total').text(number_to_currency(total_value));
}

function number_to_currency(number) {
  return '$' + number_with_precision(number);
}
function number_with_precision(number, precision) {
  if (precision === undefined) { precision = 2; }
  return Number(number).toFixed(precision);
}

