

  // cart operations 
  var cartReq = false;
  var carttype = "page";

  jQuery(function(){if(jQuery('span[@id=cartStatic]').length == 1) carttype = "widget";});

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

  function addItemToCart(id)
  {

      if (carttype=="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)
  {
      if (carttype=="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)
  {
     if (carttype=="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
	    });
         }
     }
  }


