
function refreshFavorites(lang, form)
{
  var template_url = '/include/modules/favorites_content.php';

  if(form)
  {
    template_url = '/include/modules/favorites_content_in_form.php';
  }

  template_url = template_url + '?lang=' + lang;

  if(jQuery('#favorites_div_container').css('left') != '0px')
  {
    jQuery('#favorites_div').click();  // apre se chiuso...
  }
  
  jQuery('#inner_fdc').load(template_url, function()
  {
    var found = jQuery('#fav_table');
    
    if(!(found.size() > 0))
    {
      jQuery('#favorites_div').click(); // chiude se vuoto...
    }

    $('#inner_fdc').attr({ scrollTop: $('#inner_fdc').attr('scrollHeight') });
  });
}

function addToFavorites(id, url, lang)
{
  jQuery.get('/webservices/favorites.php?op=addToFavorites&id=' + id + '&url=' + url + '&lang=' + lang, function(data)
  {
    refreshFavorites(lang);
  });
}

function removeFromFavorites(id, lang, form)
{
  jQuery.get('/webservices/favorites.php?op=removeFromFavorites&id=' + id + '&lang=' + lang, function(data)
  {
    refreshFavorites(lang, form);
  });
}

