$(document).ready(function() {
	var pathname = document.URL;
	init();
	$('#tab_menu_list a').click(function(){
		// clears tab highlights
		resetLinks();
		
		var toLoad = pathname+' #all_content div'+$(this).attr('href');
		
		// sets clicked tab to highlight
		$(this).addClass("current-nav-link");
		loadSection($(this).attr('href'));
		function resetLinks() {
			var parent = document.getElementById("tab_menu_list");
			var childCount = parent.getElementsByTagName("li").length;
			for(var i = 0;i<childCount;i++) {
				var thisLink = "#tab_menu_list #link0" + (i+1) + " a";
				$(thisLink).removeClass("current-nav-link");	
			}
		}
		return false;
	});
	function init() {
		$("#main_content_block #section01").toggle();
	}
	function hideAll() {
		$("#main_content_block #section01").hide();
		$("#main_content_block #section02").hide();
		$("#main_content_block #section03").hide();
		$("#main_content_block #section04").hide();
	}
	function loadSection(thisSection) {
		var toLoad = "#main_content_block "+thisSection; // section to load
		var displayMode = $(toLoad).css("display"); // current mode of section clicked
		
		// loads content only if section clicked is not equal to the current section already loaded
		if(displayMode === "none") {
			hideAll();
			$(toLoad).fadeIn();
		}
	}
});
