function addToCart(form) {
    if (Ajax.getTransport()) {
        form.down('.use_ajax').value = 1;
        new Ajax.Updater({ success : 'sidebar_cart' }, base_url + 'cart/add', {
            method: 'post',
            postBody: $(form).serialize(),
            onComplete: function() {
                $$('.sidebar_cart_highlighted').each(function(element){
                    element.highlight({ startcolor: '#D2F1F7', duration: 3 });
                });
            }
        });
    } else {
        form.submit();
    }
}

function emptyCart() {
    if (Ajax.getTransport()) {
        new Ajax.Updater({ success : 'sidebar_cart' }, base_url + 'cart/empty_cart', { method : 'post' });
    } else {
        window.location = base_url + 'cart/empty_cart_no_ajax';
    }
}

function removeFromSidebarCart(index) {
    new Ajax.Updater({ success : 'sidebar_cart' }, base_url + 'cart/remove', { method : 'post', parameters : { index : index } });
}

function removeFromCart(index) {
    $(index + '_quantity').value = 0;
    $('cart_form').submit();
}
