var cartCount;
function doSlideCart(id) {
  doCart(id, function(data) {
    updateCartText(data.cartCount);  
    photos['photo-'+id].inCart = (data.action == 'added'?1:0);
    if ($('#slide-'+id).hasClass('shown')) {
      writePhotoInfo($('#slide-'+id).index());
    }
  });
}

function doThumbCart(id) {
  doCart(id, function(data) {
    updateCartText(data.cartCount);
    $('#thumb-'+id+' .info a').html(data.text);
    if (data.action == 'added') {
      $('#thumb-'+id+' .info a').addClass('remove');
    } else {
      $('#thumb-'+id+' .info a').removeClass('remove');
    }
  });
}

function doCart(id, callback) {
  $.post('cart.php', { action: 'cart', id: id }, callback, "json");
}

function updateCartText(count) {
  cartCount = parseInt(count);
  $('.cartCount').html(count);
}
