// Put all your lovely jQuery / Javascript goodies right down here.

$(function(){
      
      var $container = $('#posts');

      $container.isotope({
        itemSelector : '.post'
      });
      
      //infinite scroll
      
      $container.infinitescroll({
				navSelector  : '#page_nav',    // selector for the paged navigation 
				nextSelector : '#page_nav a',  // selector for the NEXT link (to page 2)
				itemSelector : '.post',     // selector for all items you'll retrieve
				donetext  : 'No more pages to load.',
				loadingImg : 'http://i.imgur.com/qkKy8.gif',
				debug: false,
				errorCallback: function(){
					$('#infscr-loading').animate({opacity: .8},2000).fadeOut('normal'); 
				}
				},
				// call Isotope as a callback
				function( data ) {
					$container.isotope( 'appended', $( data ) ); 
	});
      
      //Post filters.
      
      var $optionSets = $('#options .option-set'),
          $optionLinks = $optionSets.find('a');

      $optionLinks.click(function(){
        var $this = $(this);
        // don't proceed if already selected
        if ( $this.hasClass('selected') ) {
          return false;
        }
        var $optionSet = $this.parents('.option-set');
        $optionSet.find('.selected').removeClass('selected');
        $this.addClass('selected');
  
        // make option object dynamically, i.e. { filter: '.my-filter-class' }
        var options = {},
            key = $optionSet.attr('data-option-key'),
            value = $this.attr('data-option-value');
        // parse 'false' as false boolean
        value = value === 'false' ? false : value;
        options[ key ] = value;
        if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
          // changes in layout modes need extra logic
          changeLayoutMode( $this, options )
        } else {
          // otherwise, apply new options
          $container.isotope( options );
        }
        
        return false;
      });




	//Fancybox image library
	
	$("a.fancyphotos").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});


});






