$(function() {
$('a.add_item').click(function(){
var el = $(this);
var token = $(this).attr('rel');
$.ajax({
type: 'POST',
url: '/store/add/',
dataType: 'json',
data: {'token': token},
success: function(data) {
if (data.success) {
el.addClass('none');
el.next('span').removeClass('none');
var price = $('.cart_price').text();
var item_price = $('.item_price').text();
price = parseFloat(price) + parseFloat(item_price);
$('.cart_price').text(price);
} else {
// el.next().next('div').empty();
// $.each(data.errors, function(key, value) {
// el.next().next('div').html('
' + value);
// });
}
},
error: function() {
// el.next().next('div').text('Error');
}
});
return false;
});
$('a[rel="#showCart"]').overlay({
expose: {
color: '#666',
loadSpeed: 200,
opacity: 0.7
},
effect: 'apple',
onBeforeLoad: function(event) {
updateCart();
}
});
$('#flushCart').click(function(e) {
flushCart();
return e.preventDefault();
});
$('.deleteItem').live('click', function(e) {
deleteItem($(this).attr('href'), $(this).attr('rel'));
return e.preventDefault();
});
});
function updateCart()
{
$.ajax({
type: 'POST',
url: '/store/cart/',
dataType: 'json',
success: function(data) {
var cartContent = '';
if (data.length) {
cartContent += '