$(document).ready(function(){
	//References
	var sections = $("#menu li");
	var loading = $("#loading");
	var content = $("#content2");
	
	//Manage click events
	sections.click(function(){
		//show the loading bar
		showLoading();
		//load selected section
		switch(this.id){
			case "modular":
				content.fadeOut();
				content.load("sections_toolset.html #section_modular", hideLoading);
				content.fadeIn();
				break;
			case "point":
				content.fadeOut();
				content.load("sections_toolset.html #section_point", hideLoading);
				content.fadeIn();
				break;
			case "action":
				content.fadeOut();
				content.load("sections_toolset.html #section_action", hideLoading);
				content.fadeIn();
				break;
			case "central":
				content.fadeOut();
				content.load("sections_toolset.html #section_central", hideLoading);
				content.fadeIn();
				break;		
			case "applicationdeployment":
				content.fadeOut();
				content.load("sections_toolset.html #applicationdeployment", hideLoading);
				content.fadeIn();
				break;
			default:
				//hide loading bar if there is no selected section
				hideLoading();
				break;
		}
	});

	//show loading bar
	function showLoading(){
		loading
			.css({visibility:"visible"})
			.css({opacity:"1"})
			.css({display:"block"})
		;
	}
	//hide loading bar
	function hideLoading(){
		loading.fadeTo(1000, 0);
	};
});