function add_to_cart(id)
{
  var qty = $('#qty').val();

  if(!qty)
  {
    qty = 1;
  }

  $.ajax({
    url: '/ajax/add_to_cart.php',
    type: 'POST',
    data: 'cart=' + cart_name + '&pid=' + id + '&qty=' + qty,
    error: function(data)
    {
      alert('Error adding item to basket.');  
    },
    success: function()
    { 
      $.post('/ajax/get_cart_qty.php', {cart: cart_name}, function(data) {
        $('#cart_item_count').html(data);
      });

      $.ajax({
        url: '/ajax/get_cart_details.php',
        type: 'POST',
        data: 'cart=' + cart_name,
        error: function(data)
        {
        },
        success: function(html)
        {
          $('#top_bar_cart_details').html(html);
          $('#top_bar_cart_details').slideDown();
        }
      }); 
    }
  }); 
}

