$(document).ready(function(){
	// We can use this object to reference the panels container
	var panelContainer = $('div#entry');
	
	// Determine which tab should show first based on the URL hash
	var panelLocation = location.hash.slice(1);
	if(panelLocation){
		var panelNum = panelLocation;
	}else{
		var panelNum = '1';
	}
	// Hide all panels
	panelContainer.find('div.tab_content').hide();
	// Display the initial panel
	panelContainer.find('div.tab_content:nth-child(' + panelNum + ')').fadeIn('slow');
	// Change the class of the current tab
	$('dl#tabs').find('dd:nth-child(' + panelNum + ') a.tab').removeClass().addClass('active');
	
	// What happens when a tab is clicked
	// -- Loop through each tab
	$('dl#tabs').find('a').each(function(n){
		// For each tab, add a 'click' action
		$(this).click(function(){
			// Hide all panels
			panelContainer.find('div.tab_content').hide();
			// Find the required panel and display it
			panelContainer.find('div.tab_content:nth-child(' + (n+1) + ')').fadeIn('slow');
			// Give all tabs the 'tab' class
			$(this).parent().parent().find('a').removeClass().addClass('tab');
			// Give the clicked tab the 'active' class
			$(this).removeClass().addClass('active');
		});
	});
});
