/**
 * @author wimlepage
 * based on code by Tim Van Damme
 */


$(document).ready(function() {
	$(".node").hide();
	var queryhash = window.location.hash
	switch (queryhash) {
		case "#about":
			document.title = "Wim Le Page - About";
			showAbout();
			break;
		case "#contact":
			document.title = "Wim Le Page - Contact";
			showContact();
			break;
		case "#networks":
			document.title = "Wim Le Page - Networks";
			showNetworks();
			break;
		default:
			showNetworks();
			break;
	}
	$("h2").hide();
	$("#vcard a").hover(showVcardLabel, hideVcardLabel);
	$("#nav-about a").click(showAbout);
	$("#nav-networks a").click(showNetworks);
	$("#nav-contact a").click(showContact);
});


function showVcardLabel() {
	$("#vcard a span").show();
	$("#vcard a span").animate({
		top: "-40px",
		opacity: 1
	}, 250 );
}

function hideVcardLabel() {
	$("#vcard a span").animate({ 
		top: "-35px",
		opacity: 0
	}, 250 );
	setTimeout("$('#vcard a span').hide();", 250);
	$("#vcard a span").animate({ 
		top: "-45px",
	}, 250 );
}


/*
function initialShowNetworks() {
	$("#content").hide();
	$("#wimlepage").removeClass();
	$("#wimlepage").addClass("networks");
	$(".node").hide();
	$("#networks").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
}

function initialShowAbout() {
	$("#content").hide();
	$("#wimlepage").removeClass();
	$("#wimlepage").addClass("about");
	$(".node").hide();
	$("#about").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
}

function initialShowContact() {
	$("#content").hide();
	$("#wimlepage").removeClass();
	$("#wimlepage").addClass("contact");
	$(".node").hide();
	$("#contact").show();
	setTimeout("$('#content').slideDown('slow');", 1000);
}
*/

function showAbout() {
	if ($("#wimlepage").hasClass("about")){ }
	else {
		document.title = "Wim Le Page - About";
		/*
		$("#content").slideUp(500);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#about').show();", 500);
		$("#content").slideDown(500);
		*/
		
		$(".node").fadeOut('fast');
		$("#content").animate({'height': $('#about').outerHeight()},'fast',function() {
    	setTimeout("$('#about').fadeIn();", 'fast');
  		});
		
		$("#wimlepage").removeClass();
		$("#wimlepage").addClass("about");
	}
}

function showNetworks() {
	document.title = "Wim Le Page - Networks";
	if ($("#wimlepage").hasClass("networks")){ }
	else {
		$(".node").fadeOut('fast');
		$("#content").animate({'height': $('#networks').outerHeight()},'fast',function() {
    	setTimeout("$('#networks').fadeIn();", 'fast');
  		});
		$("#wimlepage").removeClass();
		$("#wimlepage").addClass("networks");
	}
}

function showContact() {
	if ($("#wimlepage").hasClass("contact")){ }
	else {
		document.title = "Wim Le Page - Contact";
		/*
		$("#content").slideUp(500);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#contact').show();", 500);
		$("#content").slideDown(500);
		*/
		
		$(".node").fadeOut('fast');
		$("#content").animate({'height': $('#contact').outerHeight()},'fast',function() {
    	setTimeout("$('#contact').fadeIn();", 'fast');
  		});
		
		$("#wimlepage").removeClass();
		$("#wimlepage").addClass("contact");
	}
}
