$(document).ready(function(){
 		
 		
  	var folioItem = $('.folio-item');	
	
		$.each($('.folio-item-media'), function() {
 			$(this).slideShow(); 
		});
		

		setTimeout(function(){ 	
			
			var i = 0;
	 	 	 		
	 	
		$('#infoColumn').append('<a href="#" onClick="return false;" id="backToTop">To Top ^</a>'); 	
	 		 $('#backToTop').css('display','none');
	 		$('#backToTop').click(function(){
				$('body,html').animate({
					scrollTop: 0
				},
				800);
		});

 		
 		$.each(folioItem, function(i){						 		
  		var postDetails = $(this).find('.post-details');  		
  		if (i >= 2){
 				$(postDetails).fadeOut();	 					
  		} 			
 			i++;			
 		});		
 		
	}, 1000);

	
	var windowHeight = $(window).height();
	
 
	$(window).scroll(function () {	   
	    var _this = $(this)
	    
    
	    $.each(folioItem, function(){
	    	
	    	if ((_this.scrollTop() + windowHeight) >= $(this).position().top){
	    		$(this).find('.post-details').fadeIn(1000);	    		
	    	}	    	
	    	if ((_this.scrollTop() + windowHeight) >= $(this).position().top + 564){	    		
	    		if ($(this).attr('id') === $(folioItem[0]).attr('id')){	    			
	    		}else{
	    			addLink($(this))
	    		}     				  		
	    	}
	    });
	  });
	
	
	
	function addLink(target){	
		
		$('#backToTop').fadeIn(500);
		$('#backToTop').css({
			'position' : 'absolute',
			'top' : (target.position().top) + 564			
		});
	}	

});

		
