﻿
/* navigation */

var navigation = function()
{
	var	pos		= 0;
	var	dist	= $( '.way' ).height() + 90;
	var	offset	= 0;

	$( 'a.next, a.prev' ).click( function()
	{
		offset	= $( this ).offset().top;

		if( this.className == 'next' )
			pos = offset + dist;
		else
			pos = $( '#' + this.id + '-item' ).offset().top - 40;

		$( 'html, body' ).animate( { scrollTop: pos }, 4000 );

		return false;
	});


	$( 'a#to-top' ).click( function()
	{
		$( 'html, body' ).animate( { scrollTop: 0 }, 1000 );

		return false;
	});
};

$( window ).load( navigation );



/* lazy load initiation */

var lazyLoadINIT = function()
{
	$( 'img' ).lazyload(
	{
		 effect : "fadeIn"
	});
};

$( window ).load( lazyLoadINIT );



/* content auto load */

var curPaper = 2;

var autoLoad = function()
{
	if( $( window ).scrollTop() > $( document ).height() - $( window ).height() - 300 )
	{
		$( '#content-' + curPaper + '-way' ).show();
		$( '#content-' + curPaper + '-item' ).show();
		curPaper += 1;
	}
};

$( window ).scroll( autoLoad );

