function cart_answer(a) {  if (document.documentElement.lang == 'it') {    return a == 1 ? 'ora ce ne è ' + a + ' nel carrello<br /><a href="/carrello/">concludi la spesa?</a>': 'ora ce ne sono ' + a + ' nel carrello<br /><a href="/carrello/">concludi la spesa?</a>';  } else {    return a + ' in your cart<br /><a href="/carrello/">checkout now?</a>';  }}$(document).ready(function() {  $("#insert-in-cart").click(function() {    $("body").addClass('loader');    var id = $(this).attr("name").replace('add-', '');    var amount = $('#amount-input').val();    if (!amount) amount = 0;    $.get('/carrello/aggiorna/' + id + '/' + amount + '/', function(data) { amount = data; });    amount = parseInt(amount);    $('#amount-input').val(amount);    $("#total").html(cart_answer(amount));    $('#minicart').load('/carrello/mini/');    $("body").removeClass('loader');    $("#update-cart-button").hide('fast');  });  $("#insert-1-in-cart").live('click', function() {    $("body").addClass('loader');    var id = $(this).attr("name").replace('add-1-', '');    var amount;    $.ajax({      url: '/carrello/aggiungi/' + id + '/1/',	     success: function(data) { amount = data;},             async: false,             cache: false,             timeout: 30000    });    $('#amount-input').val(amount);    $("#total").html(cart_answer(amount));    $('#minicart').load('/carrello/mini/');    $("body").removeClass('loader');    $("#update-cart-button").hide('fast');  });  $("#cancel-update-cart").live('click', function() {    $("body").addClass('loader');    var id = $(this).attr("name").replace('reset-', '');    var amount;    $.ajax({      url: '/carrello/aggiungi/' + id + '/0/',	     success: function(data) { amount = data;},             async: false,             cache: false,             timeout: 30000    });    $('#amount-input').val(amount);    $("#total").html(cart_answer(amount));    $('#minicart').load('/carrello/mini/');    $("body").removeClass('loader');    $("#update-cart-button").hide('fast');  });  $("#amount-input").live('keydown', function(e) {    if (("0123456789").indexOf(String.fromCharCode(e.which)) > -1 ||	e.keyCode == 8 || e.keyCode == 9 ||	(e.keyCode >= 33 && e.keyCode <= 40) ||	e.keyCode == 45 || e.keyCode == 46 ||	(e.keyCode >= 96 && e.keyCode <= 105)) {      $("#update-cart-button").show('fast');    } else {      e.preventDefault();    }  });});
