$(function(){
    $("#tutorialsNav a").click(
        function(event){
            event.preventDefault();
            $(this).parent().find('img').each(
                function(){
                    newp = $(this).attr('src').replace('_selected','_up');
                    $(this).attr('src',newp);
                }
            );
            i = $(this).children('img').eq(0);
            newp = $(i).attr('src').replace('_up','_selected');
            $(i).attr('src',newp);
            
            // hide non-matching elements
            $(".tutorialIndexThumb").show();
            cls = $(this).attr('id').replace('_link','');
            if(cls != 'all'){
                $(".tutorialIndexThumb").not("."+cls).hide();
            }
        }
    );
});

function hideByName(name) {
	var tag = document.getElementById(name);
	
	$(tag).find('img').each(
		function(){
			newp = $(this).attr('src').replace('_selected','_up');
			$(this).attr('src',newp);
		}
	);
	i = $(tag).children('img').eq(0);
	newp = $(i).attr('src').replace('_up','_selected');
	$(i).attr('src',newp);
	
	// hide non-matching elements
    $(".tutorialIndexThumb").show();
	cls = name.replace('_link','');
    $(".tutorialIndexThumb").not("."+cls).hide();
}

