﻿$(function() {

	var $b = ( $.browser.webkit ) ? $( 'body' ) : $( 'html' ),
		$p = $('.page:not(#home)'),
		$h = $('#home'),
		$c = $('.container', $p),
		$n = $('.navi a'),
		$w = $(window);

	$w.bind('resize.site', function() {
		var h = $w.height();
		if (h < 750) {
			h = 750;
		}
		$h.height(h);
		$c.css('height', 'auto').each(function() {
			var $t = $(this);
			if ($t.parent().height() < h ) {
				$t.parent().height( h );
			}
			$t.height( $t.parent().height() );
		});	
	}).trigger('resize.site');

	$p.each(function() {
		var $d = $('.description', this),
			$n = $('.navi', this);

		$d.vpSticker({
			padding: {
				top: 0,
				bottom: 10 + $n.outerHeight()
			}
		});
		$n.vpSticker({
			bottom: 0,
			padding: {
				top: 10 + $d.outerHeight(),
				bottom: 0
			}
		});
	});

	$n.bind('click.site', function() {
		$b.animate({
			'scrollTop': $( $( this ).attr( 'href' ) ).offset().top
		}, {
			duration: 1500,
			easing: 'easeInOutQuart'
		});
		return false;
	});
});
