function remove_from_cart(pk, event_root_pk)
{
    Ext.Msg.show(
    {
        title: 'Please wait...',
        msg: 'Updating your shopping cart...<br/>',
        width: 240,
        closable: false
    });

    var params = new Object();

    params['pk']            = pk;
    params['event_root_pk'] = event_root_pk;
    params['func']          = 'remove_from_cart';

    Ext.Ajax.request(
    {
        url: '/events/ajax/shopping_cart.php',
        success: function(o)
        {
            if (false == o.responseText)
            {
                Ext.Msg.hide();
                Ext.Msg.alert('Error', 'There was an error removing this item from your cart.');
            }
            else
            {
                var el = Ext.get('cart-contents');
                
                if (el) 
                {
                    var mgr = el.getUpdater();
                    
                    mgr.update("/events/ajax/shopping_cart.php", "event_root_pk="+event_root_pk+"&func=get_cart");
                }
                
                Ext.Msg.hide();
            }
        },
        params: params
    });
}

function add_to_cart(pk, event_root_pk)
{
    Ext.MessageBox.show({title: 'Please wait...', msg: 'Updating your shopping cart...<br/>', width:240, closable:false});

    var params = new Object();

    params['pk']            = pk;
    params['event_root_pk'] = event_root_pk;
    params['func']          = 'add_to_cart';

    Ext.Ajax.request({
        url: '/events/ajax/shopping_cart.php',
        success: function(o)
        {
            if (false == o.responseText || 'duplicate' == o.responseText || 'schedule conflict' == o.responseText 
                || 'not enrollable' == o.responseText)
            {
                Ext.MessageBox.hide();
                switch (o.responseText)
                {
                    case 'duplicate':
                        Ext.MessageBox.alert('Error', 'The item is already in the cart.');
                        break;
                    case 'schedule conflict':
                        Ext.MessageBox.alert('Error', 'There is a schedule conflict with the item in the cart.');
                        break;
                    case 'not enrollable':
                        Ext.MessageBox.alert('Error', 'The selected item is not enrollable at this time.');
                        break;
                    default:
                        Ext.MessageBox.alert('Error', 'There was an error adding this item to your cart.');
                }
            }
            else
            {
                var el = Ext.get('cart-contents');
                
                if (el) 
                {
                    var mgr = el.getUpdater();
                    
                    mgr.update("/events/ajax/shopping_cart.php", "event_root_pk="+event_root_pk+"&func=get_cart");
                }
                
                Ext.Msg.hide();
            }
        },
        params: params
    });
}