$(document).ready(function(){
   //References
	var sections = $("#menu li");
	var loading = $("#loading");
	var content = $("#content");
//show loading bar
function showLoading(){
	loading
		.css({visibility:"visible"})
		.css({opacity:"1"})
		.css({display:"block"})
	;
}
//hide loading bar
function hideLoading(){
	loading.fadeTo(1000, 0);
	content.slideDown(); 
};
hideLoading();
//Manage click events
sections.click(function(){
	//show the loading bar
	showLoading();
	//load selected section
	switch(this.id){
		case "home":
			content.slideUp("slow", function() {
			content.load("external.html #section_profile", hideLoading);
											 });
			break;
		case "community":
			content.slideUp("slow", function() {
			content.load("external.html #section_community", hideLoading);
											 });
			break;
		case "events":
			content.slideUp("slow", function() {
			content.load("external.html #section_events", hideLoading);
											 });
			break;
		case "media":
			content.slideUp("slow", function() {
			content.load("external.html #section_media", hideLoading);
											 });
			break;
		case "portfolio":
			content.slideUp("slow", function() {
			content.load("external.html #section_portfolio", hideLoading);
											 });
			break;
		case "contact":
			content.slideUp("slow", function() {
			content.load("external.html #section_contact", hideLoading);
											 });
			break;
		default:
			content.slideUp("slow", function() {
			content.load("external.html #section_profile", hideLoading);
											 });
			break;
	}
});

});

