/* Author: 
	Mockus.nl, Willem Wigman
*/




(function($){

var currentScroll = 0;

var timer = setInterval(introAnimation,1000);

function introAnimation(){
	clearInterval(timer); 
	
	$('header p').each(function(index){
	
	$(this).delay(index*2000).fadeIn(1000, function(){
			if(index < $('header p').size()-1){
			$('header').delay(1000).animate({ paddingTop:'-=17'}, 1000);
			} else {
				$('nav').fadeIn('slow', function(){
				$('header').delay(1000).animate({ paddingTop:'56'}, 1000);
				$('img.logo').delay(1000).animate({ marginTop: '38'}, 1000);
				$('nav').delay(1000).animate({ bottom : '73'}, 1000);
				})
			}
		})
	
	})

//	$('nav').show('6000');

}
    

$('#next').click(function(e){
	e.preventDefault();
	currentScroll += 1;
	if(currentScroll >= $('article:visible div').size()){
		$('section').scrollTo($('article:visible div').eq(0),1000);
		$('#prev').hide();
		currentScroll = 0;
	} else {
		$('#prev').show();
		$('section').scrollTo($('article:visible div').eq(currentScroll),1000);
	}
})
$('#prev').click(function(e){
	e.preventDefault();
	currentScroll -= 1;
	if(currentScroll <= 1){
		$('#prev').hide();
	}
	$('section').scrollTo($('article:visible div').eq(currentScroll),1000);
})

$('nav a').click(function(e){
	$('nav a.active').removeClass('active');
	$(this).addClass('active');
	e.preventDefault();
	$('#prev').hide();
	$('#next').show();
	$('article:visible').hide();
	$($(this).attr('href')).show('slow');
	currentScroll = 0;
	$('section').scrollTo($('article:visible div').eq(0));
})



})(this.jQuery);
