$(document).ready(function() {

    $('div.portfolioNav ul li').each(function() { 
        if ($(this).hasClass('hideit')) { // hide all hideits
			$(this).hide();
		}
	});
        
    $('div.portfolioNav ul li img').each(function() {
        $(this).css('cursor', 'pointer');
        $(this).click(function() {
        
        	if ($(this).parent().hasClass('hideit')) {
        		return;
        	}
        	
            $('div.projectList div').hide();
            $('div.projectList div#menuID'+$(this).attr('categoryID')).fadeIn('slow');
            
            var _org = $(this).attr('src');
            
            $('div.portfolioNav ul li').each(function(e) { 
            	
            	if ($(this).hasClass('hideit')) { // hide all hideits
					$(this).hide();
				} else {
					$(this).show();
				}
				if ($(this).hasClass('hideit') && _org == $(this).find('img').attr('src')) {
					$(this).show();
            	}
            });
           	
           	$(this).parent().hide();
           	
        });
    });
    
    $('div.portfolioNav ul li img').each(function(){
		if ($(this).hasClass('start')) {
			if ($(this).hasClass('swap')) {
				$(this).parent().hide();
			} else {
				$(this).parent().show();
			}
		}
    });
     
    $('div.projectList li a.showAll').click(function(){
    	$(this).parent().hide();
    	
    	var _tmp = $(this).parent().parent();
    	
    	$(_tmp).children('li').each(function(){
    		if ($(this).hasClass('hide')) {
    			$(this).fadeIn('slow');
    		}
    	});
    	
    	return false;
    });
    
    //$('div.portfolioNav ul li img[categoryID=1]').click();

    
});
