$(document).ready(function() {
						  
	$(".sidenav-button").hover(function() { //On hover...

		//Animate the image to 0 opacity (fade it out)
		$(this).find(".sidenav-button-highlight").stop().fadeTo('normal', 0.5 );
	} , function() { //on hover out...
		//Fade the image to full opacity 
		$(this).find(".sidenav-button-highlight").stop().fadeTo('normal', 0);
	});

	
	
	function metapixelPichover() {					  

	$(".pic-hover").hover(function() { //On hover...

		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

		//Set a background image(thumbOver) on the <a> tag - Set position to bottom
		$(this).find('.pic-hover-background').css({'background' : 'url(' + thumbOver + ') no-repeat right top'});

		//Animate the image to 0 opacity (fade it out)
		$(this).find("span").stop().fadeTo('normal', 0 );
	} , function() { //on hover out...
		//Fade the image to full opacity 
		$(this).find("span").stop().fadeTo('normal', 1).show();
	});
	}
	metapixelPichover();
	
	//Masonry
	var $containerMasonry = $('.container-masonry');
    $containerMasonry.masonry({
        itemSelector: '.item-masonry',
        columnWidth: 240,
		isAnimated: true
    });
	
	//InfiniteScroll
	var $containerIs = $('.container-is');
    
    $containerIs.infinitescroll({
    	navSelector  : '#page-nav',    // selector for the paged navigation 
    	nextSelector : '#page-nav-right a',  // selector for the NEXT link (to page 2)
      	itemSelector : '.item-is',     // selector for all items you'll retrieve
      	loading: {
          finishedMsg: 'No more pages to load.',
          img: 'http://i.imgur.com/6RMhx.gif'
        }
    },
    // trigger Masonry as a callback
    function( newElements ) {
        var $newElems = $( newElements );
        // ensure that images load before adding to masonry layout
        $containerMasonry.masonry( 'appended', $newElems, true );
		metapixelPichover(); 

    });

});
