$(document).ready(function() {
	
	var curPage = "home";
	var tarPage;
	
	$("#nav>li>a").click(function () {
		tarPage = $(this).attr('href').split("#")[1];
		if (tarPage) {
			$("#"+curPage).slideUp('slow', function() {
				curPage = tarPage;
				tarPage = "";
				$("#"+curPage).slideDown('slow');
			});
			$("h1>a>img").animate({
				left: '-29%'
			});
			$("h1").animate({
				left: '29%'
			});
			$("#back").fadeIn('slow');
			
			return false;
		}
	});
	
	$("h1>a").click(function () {
		if (curPage != "home") {
			goingHome();
		}
		return false;
	});
	
	$("#back").click(function () {
		goingHome();
		
		return false;
	});
	
	function goingHome(){
		tarPage = "home";
		$("#"+curPage).slideUp('slow', function() {
			curPage = tarPage;
			$("#"+curPage).slideDown('slow');
		});
		
		$("#back").fadeOut('slow');
		$("h1>a>img").animate({
			left: '0'
		});
		$("h1").animate({
			left: '0'
		});
	}
	
});
