jQuery(document).ready(function ($) {

    /** Nav Toggle **/
    $('#nav-icon3').click(function(){
        $(this).toggleClass('open');
        $(this).parents('.nav-logo-wrapper').next('nav').toggleClass('show');
    });

    var gride = $('.portfolio-gride').imagesLoaded( function() {
        gride.isotope({
            // options...
            itemSelector: '.portfolio-poste',
            percentPosition: true,
            masonry: {
                columnWidth: '.portfolio-poste'
            }
        });
    });

    // filter items on button click
    $('.portfolio-filter').on( 'click', 'span', function() {
        $('.portfolio-filter span').removeClass('active');
        $(this).addClass('active')
        var filterValue = $(this).attr('data-filter');
        gride.isotope({ filter: filterValue });
    });

    $("[data-fancybox]").fancybox();

    var header_height = $('header').height();
    $(window).scroll(function (){
		if($(this).scrollTop() > header_height+200) {
			$('.fixed-header').addClass('fixed');
		}else{
			$('.fixed-header').removeClass('fixed');
		}
	});

    // fade in #back-top
    $(function () {
        $(window).scroll(function () {
            if ($(this).scrollTop() > 500) {
                $('#return-to-top').fadeIn();
            } else {
                $('#return-to-top').fadeOut();
      
            }
        });


        // scroll body to 0px on click
        $('a#return-to-top').click(function () {
            $('body,html').animate({
                scrollTop: 0
            }, 800);
            return false;
        });
    });    
});