jQuery(function( $ ){
	
	/**
	 * Restart the scroll position to ( 0, 0 ) (Firefox doesn't reset it)
	 * could use $(target).scrollTo( 0, {axis:'xy'));
	 * but this needs to be quick(synchronous), to reset before $.localScroll.hash() begins
	 */
	$('#body').attr({scrollTop:0,scrollLeft:0});
	
	// Scroll initially if there's a hash (#something) in the url 
	setTimeout(function() {
	$.localScroll.hash({
		queue:true,
		duration:400,
		onBefore:function( e, anchor, $target ){ //'this' is the clicked link
			render_page(e, anchor, $target);
		},
		onAfter:function( anchor ){
		}
	});
	}, 1000);
	
	var $last = $([]); //save the last link
	var placeholder = '<div style="height:1000px;"></div>';
	
	$.localScroll({
		queue:true,
		duration: 400,
		hash:true,
		onBefore:function( e, anchor, $target ){ //'this' is the clicked link
			render_page(e, anchor, $target);
		},
		onAfter:function( anchor ){
		}
	});
	
	
	function render_page ( e, anchor, $target ) {
		$('#body').css('height','1600px');
		$('.block a').addClass('blur');
		// $('.block a').css('color','#aaa').css('background-position','0 -600px');
		$('#inc_home').hide();
		$('#inc_services').hide();
		$('#inc_clients').hide();
		$('#inc_company').hide();
		$('#inc_contact').hide();
		
		if (anchor.id=="services") {
			// $('#inc_services').fadeIn(400);
			$('#inc_services').show();
			$('#services a').removeClass('blur');
			$('#services a').addClass('active');
		}
		if (anchor.id=="clients") {
			// $('#inc_clients').fadeIn(400);
			$('#inc_clients').show();
			$('#clients a').removeClass('blur');
			$('#clients a').addClass('active');
		}
		if (anchor.id=="company") {
			// $('#inc_company').fadeIn(400);
			$('#inc_company').show();
			$('#company a').removeClass('blur');
			$('#company a').addClass('active');
		}
		if (anchor.id=="contact") {
			// $('#inc_contact').fadeIn(400);
			$('#inc_contact').show();
			$('#contact a').removeClass('blur');
			$('#contact a').addClass('active');
		}
	}
	
			
});


