//questo codice carica tutti gli addthis trovati nella pagina
$(function(){
    $('.addthis_toolbox_cms a').each(function(){
        $(this).attr('addthis:url',$(this).attr('href'));
        $(this).attr('addthis:title',$(this).attr('title'));
    });
    function initAddThis(){ 
        addthis.init();
        reload_addthis();
        addthis.addEventListener('addthis.menu.close',reload_addthis);
    }
    initAddThis();
});

function reload_addthis(evt){
    //$('#at20mc').remove();
    //per ogni gruppo di bottoni carico la specifica configurazione
    $('.addthis_toolbox_cms').each(function(){
        $(this).children('a').each(function(){
            //per ogni singolo a
        });
        var config={};

        if($(this).children('.compact').length>0){
            config['services_compact'] =  $(this).children('.compact').eq(0).html();
        }
        if($(this).children('.exclude').length>0){
            config['services_exclude'] =  $(this).children('.exclude').eq(0).html();
        }
        //config['ui_cobrand']='Simplit CMS';
        addthis.toolbox(this,config,{});
        addthis.counter($(this).children('.addthis_button_compact').get(0),config,{});
    });
}


