Cufon.replace('.menu li', {
    fontFamily: 'Bebas',
    hover:true
});

$(document).ready(function(){
    
    
    $('.menu').css({
        rotate:'-6deg'
    });

    $('#contact-form').forms({
        ownerEmail:'info@develup.it'
    })

    $("area[data-gal^='prettyPhoto']").prettyPhoto();
    $("a[data-gal^='prettyPhoto'],a.allargaImmagine").prettyPhoto({
        animation_speed:'normal',
        slideshow:10000,
        hideflash: true
    });
    
    // lightbox image
    $(".lightbox-image").append("<span></span>");
    $(".lightbox-image").hover(function(){
        $(this).find("img").stop().animate({
            opacity:0.5
        }, "normal")
    }, function(){
        $(this).find("img").stop().animate({
            opacity:1
        }, "normal")
    });

    // slide in homepage
    $('.slider')._TMS({
        prevBu:'.prev',
        nextBu:'.next',
        playBu:'.play',
        duration:888,
        easing:'none',
        preset:'diagonalExpand',
        pagination:true,
        slideshow:6000,
        numStatus:false,
        banners:false,
        bannerShow:function(banner){
            banner
            .hide()
            .fadeIn(800)
        },
        bannerHide:function(banner){
            banner
            .show()
            .fadeOut(800)
        }
    })

    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    if(sPage == 'foto')
        sPage = 'servizi';
    $('nav .menu li a[href="'+sPage+'"]').addClass('active');
    

    $('.elencoProgetti.border-bot').last().removeClass('border-bot');

    // pagina servizi
    if($('#diagram').length){
        o.init();
    }

    // pagina foto
    if($('#am-container').length){        

        var $container 	= $('#am-container'),
        $imgs		= $container.find('img').hide(),
        totalImgs	= $imgs.length,
        cnt		= 0;

        $imgs.each(function(i) {
            var $img	= $(this);
            $('<img/>').load(function() {
                ++cnt;
                if( cnt === totalImgs ) {
                    $imgs.show();
                    $('#loaderFoto').hide();
                    $container.montage({
                        fillLastRow     : false,
                        alternateHeight : true,
                        alternateHeightRange	: {
                            min	: 100,
                            max	: 200
                        },
                        margin:3
                    });
                }
            }).attr('src',$img.attr('src'));
        });
    }

    Cufon.now();
})
