$(document).ready(function() {

	$('.incr_item, .decr_item, .del_item').live('click', function() {
		var link = $(this);
		$.ajax({
			url: this,
			success: function(){
				update_basket();
			},
			error: function(){
				link.parents('.basket-row')
					.prepend('<p class="qty-error">Additional stock of this item is unavailable</p>')
					.delay(500)
					.find('.qty-error').fadeOut(2000);
			}
		});
		return false;
	})

	function update_basket() {
		$.ajax({
			url: '/basket/basket/ajax',
			cache: false,
			success: function(html){
				$('#body-container').html(html);
			}
		});
	}

});
