/**
 * @author webmaster
 */

function show_category($category_name){
	
	// remove the 'active' class from all other links 
	$('#project_nav_list li').removeClass('active');
	
	// set current link to 'active'
	$('#'+ $category_name +'_link').addClass('active');
	
	// hide all of the project image groups
	$('#project_images div').hide();
	
	
	// display the category project image group
	$('#'+ $category_name + '_images').show();
	
	if($category_name != 'default'){
	
		// get the project id of the first project in that category
		$first_image_id = $('#' + $category_name + '_images img:first').attr('id');
		
		// show the first project in that category
		show_image($first_image_id);
	
	}
			
	// Hide all project categories
	$('.project_category').hide();
			
	// Show currently selected category
	$('#' + $category_name + '_category').show();
	
}

function show_image($image_id){
	
	// hide all project image groups
	$('#project_images div').hide();
	
	// hide all project images
	$('#project_images img').hide();
	
	// show current group
	$('#' + $image_id).parent().show();
	
	// show current project image
	$('#' + $image_id).show();
}

jQuery(document).ready(function(){
	
	// Add the click event for each item in the text-based navigation
	$('#project_nav_list li').each(function(){
		$(this).click(function(){
			
			// get the category name from the id
			$category_name = $(this).attr('id');
			// remove the '_link' from the category name
			$category_name = $category_name.replace(/_link/, "");
			
			show_category($category_name);
			
		
		})
		
	});
	
	$('.projects li').mouseover(function(){
		$project_id = $(this).attr('id');
		show_image($project_id + '_image');
	});
	
	
	// Add the click event for each item in the thumbnail-based navigation
	/*
	$('#project_nav_thumbs a').each(function(){
		$(this).click(function(){
			
			// get the category name from the id
			$category_name = $(this).attr('id');
			
			// remove the '_anchor' from the category name
			$category_name = $category_name.replace(/_anchor/, "");
			
			show_category($category_name);
			
		
		})
		
	});
	*/
	
	
})
