

  // cart operations 
  var cartReq = false;


  function beginCartAjaxOperation()
  {
    jQuery('#cartwidgetloader').show();
    jQuery('#cartStatic').hide();
     if (cartReq) {
      cartReq.abort();
    } 
  }

  function addItemToCart(id,where)
  {

      if (where=="widget") {
	 beginCartAjaxOperation();
         RST.Load('ShoppingCart', RST.context['__storebase'] + '__cartwidget?', {
           '__template' : RST.context['__template'],
           'verb' : 'ATC',
           'lid' : id
         })();
      } else {
         window.location = RST.context['__storebase'] + 'cart?__template=' + RST.context['__template'] + '&verb=ATC&lid=' + id;
      }

  }

  function removeItemFromCart(id,el,where)
  {
      if (where=="widget") {
          if (typeof(el)!= 'undefined')
	     jQuery(el).hide();
          beginCartAjaxOperation();
          RST.Load('ShoppingCart', RST.context['__storebase'] + '__cartwidget?', {
             '__template' : RST.context['__template'],
             'verb' : 'DEL',
             'lid' : id
          })();
      } else {
          if (RST.context['__pagename'] == 'cart') {
            RST.Load('InfoM', RST.context['__storebase'] + '__cart?', {
               '__template' : RST.context['__template'],
               'verb' : 'DEL',
               'lid' : id
            })();
            jQuery('#cartloader').show();
          } else {
            window.location = RST.context['__storebase'] + 'cart?__template=' + RST.context['__template'] + '&verb=DEL&lid=' + id;
          }
      }
  }

  function updateItemQuantity(id,qty,where)
  {
     if (where=="widget") {
         if (typeof(el)!= 'undefined')
	     jQuery(el).hide();

	 beginCartAjaxOperation();
         RST.Load('ShoppingCart', RST.context['__storebase'] + '__cartwidget?', {
           '__template' : RST.context['__template'],
           'verb' : 'UCQ',
           'lid' : id,
           'qty' : qty
         })();
     } else {
         if (RST.context['__pagename'] == 'cart') {
           RST.Load('InfoM', RST.context['__storebase'] + '__cart?', {
               '__template' : RST.context['__template'],
               'verb' : 'UCQ',
               'lid' : id,
               'qty' : qty
            })();
            jQuery('#cartloader').show();
         } else {
            window.location = RST.context['__storebase'] + 'cart?__template=' + RST.context['__template'] + '&verb=UCQ&lid=' + id + '&qty=' + qty;
         }
     }
  }


