$(document).ready(function() {

    //############# ANIMAZIONE MENU ####################################################
    if ($('#menu-cappello').hasClass('menu')) {
        var bg = "-980px";
    };

    if ($('#menu-cappello').hasClass('menu chisiamo')) {
        var bg = "0px";
    };

    if ($('#menu-cappello').hasClass('menu mission')) {
        var bg = "-245px";
    };

    if ($('#menu-cappello').hasClass('menu volontari')) {
        var bg = "-490px";
    };

    if ($('#menu-cappello').hasClass('menu codice')) {
        var bg = "-735px";
    };

    // ----- CHI SIAMO ----- //
    $('.Chi-siamo a').mouseover(function() {
        $('.menu').css('backgroundPosition', '0 0px');
    }).mouseout(function() {
        $('.menu').css('backgroundPosition', '0 ' + bg);
    });

    // ----- MISSION ----- //
    $('.Mission a').mouseover(function() {
        $('.menu').css('backgroundPosition', '0 -245px');
    }).mouseout(function() {
        $('.menu').css('backgroundPosition', '0 ' + bg);
    });

    // ----- VOLONTARI ----- //
    $('.Volontari a').mouseover(function() {
        $('.menu').css('backgroundPosition', '0 -490px');
    }).mouseout(function() {
        $('.menu').css('backgroundPosition', '0 ' + bg);
    });

    // ----- CODICE DEONTOLOGICO ----- //
    $('.Codice a').mouseover(function() {
        $('.menu').css('backgroundPosition', '0 -735px');
    }).mouseout(function() {
        $('.menu').css('backgroundPosition', '0 ' + bg);
    });

    // ----- ANIMAZIONE MANI ----- //
    $(".slide-board").delay(400).animate({
        marginTop: "-300px",
        opacity: "1"
    },
    300);
    $(".slide-board-contenuto").delay(400).animate({
        marginTop: "-530px",
        opacity: "1"
    },
    300);

    //############# ANIMAZIONE PULSANTE HOME ############################################
    $("div#home-ribbon").hover(function() {
        $(this).stop().animate({
            marginTop: "-20px"
        },
        "fast");
    },
    function() {
        $(this).stop().animate({
            marginTop: "-40px"
        },
        "slow");
    });

    //############# FANCY BOX ############################################
    $("a.group").fancybox({
        'hideOnContentClick': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 250,
        'speedOut': 200,
        'overlayShow': true,
        'centerOnScroll': true
    });

    //############# ANIMAZIONE FIORE ####################################################
    $("#Fiore").rotate({
        bind: {
            click: function() {
                $(this).rotate({
                    duration: 2000,
                    angle: 0,
                    animateTo: 360,
                })
            }
        }
    });

});
