$(document).ready(function(){

	var queryhash = window.location.hash
	switch (queryhash) {
		case "#about":
			document.title = "Ben Willis - About";
			about();
			break;
		case "#social":
			document.title = "Ben Willis - Social";
			social();
			break;
		case "#blog":
			document.title = "Ben Willis - Blog";
			blog();
			break;
		case "#contact":
			document.title = "Ben Willis - Contact";
			contact();
			break;
		default:
			about();
			break;
	}
	$("#about-menu").click(about);
	$("#social-menu").click(social);
	$("#blog-menu").click(blog);
	$("#contact-menu").click(contact);
			
});

function about () {
	document.title = "Ben Willis - About";
	window.location.hash = "about";
	$("#box").animate({
    	width: "400px"
	});
	$(".current").fadeOut("fast", function(){
		$(this).removeClass("current").parent().find("#about").fadeIn("fast").addClass("current");
		var newHeight = $("#about").height();
		var trueNewHeight = newHeight;
		$("#content").animate({
               height: newHeight
		});
		$("#loading").animate({height: newHeight+188});
	});
}

function social () {
	document.title = "Ben Willis - Social";
	window.location.hash = "social"
	$("#box").animate({
    	width: "400px"
	});
	$(".current").fadeOut("fast", function(){
		$(this).removeClass("current").parent().find("#social").fadeIn("fast").addClass("current");
		var newHeight = $("#social").height();
		var trueNewHeight = newHeight - 40;
		$("#content").animate({
               height: trueNewHeight,
        });
        $("#loading").animate({height: trueNewHeight+188});
	});
}

function blog () {
	document.title = "Ben Willis - Blog";
	window.location.hash = "blog"
	$("#box").animate({
    	width: "800px"
	});
	$(".current").fadeOut("fast", function(){
		$(this).removeClass("current").parent().find("#blog").fadeIn("fast").addClass("current");
		//var newHeight = $("#blog").height();
		//var trueNewHeight = newHeight - 40;
		$("#content").animate({
               height: "400px",
        });
	});
}

function contact(){
	document.title = "Ben Willis - Contact";
	window.location.hash = "contact";
	$("#box").animate({
    	width: "400px"
	});
	$(".current").fadeOut("fast", function(){
		$(this).removeClass("current").parent().find("#contact").fadeIn("fast").addClass("current");
		var newHeight = $("#contact").height();
		var trueNewHeight = newHeight - 40;
		$("#content").animate({
               height: trueNewHeight,
        });
        $("#loading").animate({height: trueNewHeight+188});
	});
}
