var tori = function(){
	
	// window position
	var winPos = 0;
	function calcParallax(tileheight, speedratio, scrollposition) {
	  return ((tileheight) - (Math.floor(scrollposition / speedratio) % (tileheight+1)));
	}
	window.onscroll = function() {
		winPos = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.pageYOffset;
		toriFly();
	}
	
	// 鳥たち
	var toriFly = function() {
		$('#tori li').each(function(){
			var flyPos = $(this).data('fly');
			if(winPos >= flyPos){
				flying( $(this) );
			} else {
				landing( $(this) );
			}
		});
	}
	
	// 飛び立つ
	var flying = function( tgt ){
		var tori = tgt.children('p');
		tori.stop().animate({
			top: '-1500px'
		},1650,"easeInOutCubic",
			function(){
				tgt.attr('data-status','flying');
			}
		);
	}

	// 降り立つ
	var landing = function( tgt ){
		var tori = tgt.children('p');
		tori.stop().animate({
			top: '0'
		},1450,"easeOutExpo",
			function(){
				tgt.attr('data-status','landing');
			}
		);
	}


}

$(function(){
	
	tori();
	$("a[rel^='prettyPhoto']").prettyPhoto();

});


