

  // 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();
      if (document.getElementById('ShoppingCart')){ jQuery.scrollTo( '#ShoppingCart' , 800 ) }
         RST.Load('ShoppingCart', RST.context['__storebase'] + '__cartwidget', {
           'verb' : 'ATC',
	   'lid' : id
         }, null , function(){ if (document.getElementById('thumb'+id)) { jQuery.scrollTo('#thumb'+id, 800 ) } } )();
      } else {
         window.location = RST.BuildURL(RST.context['__storebase'] + 'cart', {
	   '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', {
             'verb' : 'DEL',
             'lid' : id
          })();
      } else {
          if (RST.context['__pagename'] == 'cart') {
            RST.Load('InfoM', RST.context['__storebase'] + '__cart', {
               'verb' : 'DEL',
               'lid' : id
            })();
            jQuery('#cartloader').show();
          } else {
            window.location = RST.BuildURL(RST.context['__storebase'] + 'cart', {
	      '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', {
           'verb' : 'UCQ',
           'lid' : id,
           'qty' : qty
         })();
     } else {
         if (RST.context['__pagename'] == 'cart') {
           RST.Load('InfoM', RST.context['__storebase'] + '__cart', {
               'verb' : 'UCQ',
               'lid' : id,
               'qty' : qty
            })();
            jQuery('#cartloader').show();
         } else {
            window.location = RST.BuildURL(RST.context['__storebase'] + 'cart', {
	      'verb' : 'UCQ',
	      'lid' : id,
	      'qty' : qty
	    });
         }
     }
  }

