function addToCart(itemId) { showBlackWall(); $('#blackWall').bind('click', function () { hideBlackWall(); $('#shoppingCartAjax').remove(); }); $.ajax({ type: 'POST', url: '/ajax.php', data: 'action=addToShoppingCart&isProject=1&id=' + itemId, success: function (strHtml) { $('body').append(strHtml); setElementPosition('shoppingCartAjax', 'center'); $('#shoppingCartAjax').fadeIn(); $('#addToShoppingCartButton').bind('click', function () { var quantity = parseInt($('#itemQuantity').val()); if (quantity > 0) { $.getJSON('/ajax.php?action=addToShoppingCartSave&isProject=1&goodId=' + itemId + '&quantity=' + quantity, function (JSONData) { if (JSONData.status == 'OK') { redirect('/index.php?display=shopping_cart'); } else { alert('not ok'); } }); } }); } }); } function deleteItem(itemId) { showBlackWall(); $('#blackWall').bind('click', function () { hideBlackWall(); hideMessage(); }); $.ajax({ type: 'POST', url: '/ajax.php', //data: 'action=showMessage&isProject=1&type=' + 1, data: 'action=showMessage&type=' + 1, success: function (strHtml) { $('body').append(strHtml); setElementPosition('alertMessage', 'center'); $('#alertMessage').fadeIn(); $('#noButton').bind('click', function () { hideBlackWall(); hideMessage(); }); $('#yesButton').bind('click', function () { $.getJSON('/ajax.php?action=deleteFromShoppingCart&isProject=1&id=' + itemId, function (JSONData) { if (JSONData.status == 'OK') { redirect('/index.php?display=shopping_cart'); } else { alert('not ok'); } }); }); } }); }