$(document).ready(function(){
	//References
	var sections = $("#side_menu li a");
	var loading = $("#loading");
	var content = $("#ajax_content");
	
	//Manage click events
	sections.click(function(){
		//show the loading bar
		showLoading();
		//load selected section
		switch(this.id){
			case "home":
				content.slideUp();
				content.load("homepage_sections.html #section_home", hideLoading);
				content.slideDown();
				break;
			case "national":
				content.slideUp();
				content.load("homepage_sections.html #section_national", hideLoading);
				content.slideDown();
				break;
			case "SUPER_SELF_DEFENCE_SEMINAR":
				content.slideUp();
				content.load("homepage_sections.html #section_SUPER_SELF_DEFENCE_SEMINAR", hideLoading);
				content.slideDown();
				break;
			case "POOMSE_SEMINARS_IN_NEW_ZEALAND_A_SUCCESS":
				content.slideUp();
				content.load("homepage_sections.html #section_POOMSE_SEMINARS_IN_NEW_ZEALAND_A_SUCCESS", hideLoading);
				content.slideDown();
				break;
			case "WORLD_YOUTH_OLYMPIC_GAMES":
				content.slideUp();
				content.load("homepage_sections.html #section_WORLD_YOUTH_OLYMPIC_GAMES", hideLoading);
				content.slideDown();
				break;
				
			case "NEW_ZEALAND_TRIP_FOR_MASTER_CARMELA_HARTNETT":
				content.slideUp();
				content.load("homepage_sections.html #section_NEW_ZEALAND_TRIP_FOR_MASTER_CARMELA_HARTNETT", hideLoading);
				content.slideDown();
				break;
			case "GRADING_PHOTO":
				content.slideUp();
				content.load("homepage_sections.html #section_GRADING_PHOTO", hideLoading);
				content.slideDown();
				break;
				
			case "STA_NATIONALS_PHOTO":
				content.slideUp();
				content.load("homepage_sections.html #section_STA_NATIONALS_PHOTO", hideLoading);
				content.slideDown();
				break;
				
			case "BRITISH_INTERNATIONAL_OPEN_CHAMPIONSHIPS":
				content.slideUp();
				content.load("homepage_sections.html #section_BRITISH_INTERNATIONAL_OPEN_CHAMPIONSHIPS", hideLoading);
				content.slideDown();
				break;	
				
			case "WORLD_CHAMPIONSHIP_SELECTIONS":
				content.slideUp();
				content.load("homepage_sections.html #section_WORLD_CHAMPIONSHIP_SELECTIONS", hideLoading);
				content.slideDown();
				break;	

			case "8th_INTERNATIONAL_CLUBS_CHAMPIONSHIP":
				content.slideUp();
				content.load("homepage_sections.html #section_8th_INTERNATIONAL_CLUBS_CHAMPIONSHIP", hideLoading);
				content.slideDown();
				break;	
				
			case "WA_INVITATIONAL_CHAMPIONSHIPS":
				content.slideUp();
				content.load("homepage_sections.html #section_WA_INVITATIONAL_CHAMPIONSHIPS", hideLoading);
				content.slideDown();
				break;	

			case "GRAND_MASTER_SEMINAR":
				content.slideUp();
				content.load("homepage_sections.html #section_GRAND_MASTER_SEMINAR", hideLoading);
				content.slideDown();
				break;	

			case "JULIE_TO_REPRESENT_AT_US_OPEN":
				content.slideUp();
				content.load("homepage_sections.html #section_JULIE_TO_REPRESENT_AT_US_OPEN", hideLoading);
				content.slideDown();
				break;	

			case "OCEANIA_CHAMPIONSHIPS_SUCCESS":
				content.slideUp();
				content.load("homepage_sections.html #section_OCEANIA_CHAMPIONSHIPS_SUCCESS", hideLoading);
				content.slideDown();
				break;	

			case "WORLD_POOMSE_CHAMPIONSHIPS":
				content.slideUp();
				content.load("homepage_sections.html #section_WORLD_POOMSE_CHAMPIONSHIPS", hideLoading);
				content.slideDown();
				break;	

			case "DAN_GRADING_RESULTS":
				content.slideUp();
				content.load("homepage_sections.html #section_DAN_GRADING_RESULTS", hideLoading);
				content.slideDown();
				break;	

			
				
			case "Oh_Do_Kwan_Referee_For_World_Event":
				content.slideUp();
				content.load("news_sections.html #section_Oh_Do_Kwan_Referee_For_World_Event", hideLoading);
				content.slideDown();
				break;

			case "December_Dan_Grading":
				content.slideUp();
				content.load("news_sections.html #section_December_Dan_Grading", hideLoading);
				content.slideDown();
				break;
				
			case "National_Team_Recognition_Awards":
				content.slideUp();
				content.load("news_sections.html #section_National_Team_Recognition_Awards", hideLoading);
				content.slideDown();
				break;
						
			case "2007_STATE_OPEN_AND_NOVICE_CUP_CHAMPIONSHIPS":
				content.slideUp();
				content.load("news_sections.html #section_2007_STATE_OPEN_AND_NOVICE_CUP_CHAMPIONSHIPS", hideLoading);
				content.slideDown();
				break;

				
			case "Oh_Do_Kwan_New_High_Dans":
				content.slideUp();
				content.load("news_sections.html #section_Oh_Do_Kwan_New_High_Dans", hideLoading);
				content.slideDown();
				break;

			case "OH_DO_KWAN_SUCCESS_AT_2007_NATIONAL_CHAMPIONSHIPS":
				content.slideUp();
				content.load("news_sections.html #section_OH_DO_KWAN_SUCCESS_AT_2007_NATIONAL_CHAMPIONSHIPS", hideLoading);
				content.slideDown();
				break;
				
			case "Carmela_Hartnett_Elected_President_of_Taekwondo_Western_Australia":
				content.slideUp();
				content.load("news_sections.html #section_Carmela_Hartnett_Elected_President_of_Taekwondo_Western_Australia", hideLoading);
				content.slideDown();
				break;

			case "2007_National_Taekwondo_Championships":
				content.slideUp();
				content.load("news_sections.html #section_2007_National_Taekwondo_Championships", hideLoading);
				content.slideDown();
				break;
				
			case "Catherine_wins_Bronze":
				content.slideUp();
				content.load("news_sections.html #section_Catherine_wins_Bronze", hideLoading);
				content.slideDown();
				break;

			case "Success_At_World_University_Games":
				content.slideUp();
				content.load("news_sections.html #section_Success_At_World_University_Games", hideLoading);
				content.slideDown();
				break;

			case "7th_INTERNATIONAL_CLUBS_TAEKWONDO_CHAMPIONSHIPS":
				content.slideUp();
				content.load("news_sections.html #section_7th_INTERNATIONAL_CLUBS_TAEKWONDO_CHAMPIONSHIPS", hideLoading);
				content.slideDown();
				break;





			case "Maddington_Headquarters":
				content.slideUp();
				content.load("ClubLocations_sections.html #section_Maddington_Headquarters", hideLoading);
				content.slideDown();
				break;

			case "Other_Locations":
				content.slideUp();
				content.load("ClubLocations_sections.html #section_Other_Locations", hideLoading);
				content.slideDown();
				break;
				
			case "Country_Locations":
				content.slideUp();
				content.load("ClubLocations_sections.html #section_Country_Locations", hideLoading);
				content.slideDown();
				break;
				
				case "Queensland":
				content.slideUp();
				content.load("ClubLocations_sections.html #section_Queensland", hideLoading);
				content.slideDown();
				break;
				
			case "Our_Instructors":
				content.slideUp();
				content.load("OurInstructors_sections.html #section_Our_Instructors", hideLoading);
				content.slideDown();
				break;
				
			case "1980_1984":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_1980_1984", hideLoading);
				content.slideDown();
				break;
				
			case "1985_1989":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_1985_1989", hideLoading);
				content.slideDown();
				break;

			case "1990_1992":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_1990_1992", hideLoading);
				content.slideDown();
				break;

			case "1993_1995":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_1993_1995", hideLoading);
				content.slideDown();
				break;
				
			case "1996_1997":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_1996_1997", hideLoading);
				content.slideDown();
				break;

		
			case "1998_1999":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_1998_1999", hideLoading);
				content.slideDown();
				break;
				
			case "2000_2003":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_2000_2003", hideLoading);
				content.slideDown();
				break;
				
			case "2004_2006":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_2004_2006", hideLoading);
				content.slideDown();
				break;
				
			case "2007_2009":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_2007_2009", hideLoading);
				content.slideDown();
				break;
				
			case "2009_2010":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_2009_2010", hideLoading);
				content.slideDown();
				break;

			case "2011_2011":
				content.slideUp();
				content.load("PhotoHistory_sections.html #section_2011_2011", hideLoading);
				content.slideDown();
				break;

				
			case "videos":
				content.slideUp();
				content.load("videos_sections.html #section_videos", hideLoading);
				content.slideDown();
				break;

			case "Taekwondo_Links":
				content.slideUp();
				content.load("internetLinks_sections.html #section_Taekwondo_Links", hideLoading);
				content.slideDown();
				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);
	};
});
