

function addToBasket(id){
  $('button'+id).value = ('Adding to basket');
  new Ajax.Request('/index.php/basket/add/id/'+id+'.html', {
    method: 'get',
    asynchronous:true,
    onSuccess: function(transport) {
      basket = transport.responseJSON;
      if(basket.success){
        $('shoppingCartCount').update(basket.total);
        message = $('messageId'+id);
       // message.update('Item added to basket');
        $('button'+id).value = ('Added to basket');
        //new Effect.Appear(message, { duration: 1, afterFinish: function(obj){new Effect.Fade(message, { duration:5.0})}});
        new Effect.Pulsate('shoppingCartCount', {duration:5});
        new Effect.Highlight('shoppingCart', { startcolor: '#ffffff', endcolor: '#6c7170' });
      }else{
        $('button'+id).value = ('Item in basket');
        //message = $('messageId'+id);
        message.update('Item in basket');
        //new Effect.Appear(message, { duration: 1, afterFinish: function(obj){new Effect.Fade(message, { duration:5.0})}});
        new Effect.Pulsate('shoppingCartCount', {duration:3});
        new Effect.Highlight('shoppingCart', { startcolor: '#ffffff', endcolor: '#6c7170;' });
      }
    }
  });
}


function removeFromBasket(id){
  $('button'+id).value = ('Removing from basket');
  $('gbutton').update('Please wait while your basket is updated');
  new Ajax.Request('/index.php/basket/remove/id/'+id+'.html', {
    method: 'get',
    asynchronous:true,
    onSuccess: function(transport) {
      basket = transport.responseJSON;
      if(basket.success){
        if(basket.total > 0)
          $('shoppingCartCount').update(basket.total);
        else
          $('shoppingCartCount').update('no');
        new Effect.Pulsate('shoppingCartCount', {duration:5});
        new Effect.Highlight('shoppingCart', { startcolor: '#ffffff', endcolor: '#6c7170;' });
        $('gbutton').update(basket.gbutton);
        if(basket.itemCount == 0)
          Effect.DropOut('catalogue'+id);
        else{
          $('catalogueTitleQuantity'+id).update(basket.itemCount);
          $('catalogueQuantity'+id).update(basket.itemCount);
        }
         
        
      }
    }
  });
  
}


