$(function(){
  // add a "rel" attrib if Opera 7+
  if(window.opera) {
    if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
      $("a.jqbookmark").attr("rel","sidebar");
    }
  }   
  $("a.jqbookmark").click(function(event){
    return addthis_sendto('favorites');
  });
  $(".voir-liste").scrollFollow({offset: 25});  
  
  
  $("a.zoom-image").attr('rel', 'gallery').fancybox({
    'titleShow'		: true,
    'transitionIn'	: 'elastic',
    'transitionOut'	: 'elastic',
    'titlePosition'  : 'over',
    'cyclic' : true
  });
  $('.fav').live('click', (function(){
    var fav = $(this);
    query = 'id='+$(this).attr('id')+'&function=add';
    $.get("/favcookies.php",query, function(data){
      fav.removeClass('fav');
      fav.addClass('fav-remove')
      fav.text('Retirer de ma liste |');
      if($('.voir-liste').length == 0){
        $('#content').append('<a href="/liste/" class="voir-liste">Voir ma liste</a>');
        $(".voir-liste").scrollFollow({offset: 25});  
      }
    });
  }));
  $('.fav-remove').live('click', (function(){
    var fav = $(this);
    query = 'id='+$(this).attr('id')+'&function=remove';
    $.get("/favcookies.php",query, function(data){
      fav.removeClass('fav-remove');
      fav.addClass('fav')
      fav.text('Ajouter à ma liste |');
    });
  }));
  $('.fav-remove-from-list-page').click(function(){
    var id = $(this).attr('id').replace('fav-', '');
    query = 'id='+$(this).attr('id')+'&function=remove';
    $.get("/favcookies.php",query, function(data){
      $('#produit-container-'+id).hide();
    });
  });
  
});

