$(document).ready(function(){
	
	// $('#home #logo').css({ 'opacity' : '0' });
	// $('#home #nav').css({ 'opacity' : '0' });
	// $('#home-logo').css({ 'opacity' : '0' });
	// 
	// $('#home-logo').click(function(){
	// 	$('#home-logo').stop(true, true);
	// 	$('#home-logo').animate({ "opacity": 0 }, 400, function(){
	// 		$(this).hide();
	// 	});
	// 	$('#logo').animate({ "opacity": 1 }, 400);
	// 	$('#nav').animate({ "opacity": 1 }, 400);
	// });
	// 
	// // Flickering logo animation
	// $('#home-logo')
	// 	.animate({ "opacity": 0.1 }, 1000)
	// 	.animate({ "opacity": 0.3 }, 100)
	// 	.animate({ "opacity": 0.1 }, 10)
	// 	.animate({ "opacity": 0.1 }, 200)
	// 	.animate({ "opacity": 0.5 }, 50)
	// 	.animate({ "opacity": 0.1 }, 100)
	// 	.animate({ "opacity": 1 }, 100)
	// 	.animate({ "opacity": 0.1 }, 100)
	// 	.animate({ "opacity": 0.1 }, 100)
	// 	.animate({ "opacity": 1 }, 10)
	// 	.animate({ "opacity": 0.1 }, 100)
	// 	.animate({ "opacity": 0.1 }, 200)
	// 	.animate({ "opacity": 1 }, 10)
	// 	.animate({ "opacity": 0.1 }, 50)
	// 	.animate({ "opacity": 1 }, 100)
	// 	.animate({ "opacity": 0.6 }, 50)
	// 	.animate({ "opacity": 1 }, 50)
	// 	.animate({ "opacity": 0.3 }, 100)
	// 	.animate({ "opacity": 1 }, 100)
	// 	.animate({ "opacity": 1 }, 200)
	// 	.animate({ "opacity": 0.4 }, 50)
	// 	.animate({ "opacity": 1 }, 50)
	// 	.animate({ "opacity": 0.1 }, 50)
	// 	.animate({ "opacity": 0.1 }, 500)
	// 	.animate({ "opacity": 0.4 }, 100)
	// 	.animate({ "opacity": 0.1 }, 100)
	// 	.animate({ "opacity": 1 }, 100)
	// 	.animate({ "opacity": 0 }, 200)
	// 	.animate({ "opacity": 1 }, 100)
	// 	.animate({ "opacity": 0.6 }, 50)
	// 	.animate({ "opacity": 1 }, 50)
	// 	.animate({ "opacity": 0.3 }, 100)
	// 	.animate({ "opacity": 1 }, 100)
	// 	.animate({ "opacity": 1 }, 200)
	// 	.animate({ "opacity": 0.4 }, 50)
	// 	.animate({ "opacity": 1 }, 50)
	// 	.animate({ "opacity": 1 }, 1000)
	// 	.animate({ "opacity": 0.4 }, 50)
	// 	.animate({ "opacity": 1 }, 50)
	// 	.animate({ "opacity": 1 }, 2000)
	// 	.animate({ "opacity": 0 }, 2000, 
	// 	function(){
	//		$('#home-logo').hide();
	// 		$('#logo').animate({ "opacity": 1 }, 400);
	// 		$('#nav').animate({ "opacity": 1 }, 400);
	// 	}
	// );
	
	$('#nav li.selected').each(function(){
		if( $(this).find('a').attr('id') == 'nav-work' ){
			$('#nav ul').show();
			$('#nav-contact').parent().addClass('hidden');
			$('#nav-bio').parent().addClass('hidden');
		}
	});
	
	$('#nav #nav-work').click(function(ev){
		if( $(this).parent().attr('class') == 'selected' ){

			$('#nav ul').fadeOut('fast', function(){
				$(this).parent().removeClass('selected');
				$('#nav-contact').parent().fadeIn();
				$('#nav-bio').parent().fadeIn();
				$('#content').fadeOut('fast');
				$('#nav ul li').removeClass('selected');
			});

		} else {
						
			$(this).parent().addClass('selected');
			$('#content').fadeOut('fast');
			$('#nav-contact').parent().removeClass('selected');
			$('#nav-contact').parent().fadeOut('fast');
			$('#nav-bio').parent().removeClass('selected');
			$('#nav-bio').parent().fadeOut('fast', function(){
				$('#nav ul').fadeIn('fast');
			});

		}
		ev.preventDefault();
	});
	
	$('#nav .nav-back').click(function(){
		$('#content').fadeOut('fast');
		$('#nav ul').fadeOut('fast', function(){
			$(this).parent().removeClass('selected');
			$('#nav-contact').parent().fadeIn();
			$('#nav-bio').parent().fadeIn();
			$('#nav li').removeClass('selected');
		});
	});
	
	$('#logo a').click(function(e){
		$('#content').fadeOut('fast');
		$('#nav ul').fadeOut('fast', function(){
			$(this).parent().removeClass('selected');
			$('#nav-contact').parent().fadeIn();
			$('#nav-bio').parent().fadeIn();
			$('#nav li').removeClass('selected');
		});
		e.preventDefault();
	});
	
	$('#nav #nav-bio').click(function(){
		$('#content').fadeIn('fast');
		$(this).parent().addClass('selected');
	});
	
	$('#nav #nav-contact').click(function(){
		$('#content').fadeIn('fast');
		$(this).parent().addClass('selected');
	});
	
	$('#nav #nav-retouching').click(function(){
		$('#content').fadeIn('fast');
		$(this).parent().addClass('selected');
	});

	$('#nav #nav-3d').click(function(){
		$('#content').fadeIn('fast');
		$(this).parent().addClass('selected');
	});
	
	$('#grid a').hover(
		function(){
			$(this).find('span').show();
			$(this).find('span').css( {opacity: 0.4} );
		},
		function(){
			$(this).find('span').hide();
		}
	);
	
	$('.thumbs img').after('<span></span>');
	
	$('.thumbs a').hover(
		function(){
			$(this).find('span').show();
			$(this).find('span').css( {opacity: 0.4} );
		},
		function(){
			$(this).find('span').hide();
		}
	);
	
	$('.extras .credits').hover(
		function(){
			$('ul.credits').fadeIn('fast');
		},
		function(){
			$('ul.credits').fadeOut('fast');
		}
	);
	
	$('.extras .elements').hover(
		function(){
			$('img.elements').fadeIn('fast');
		},
		function(){
			$('img.elements').fadeOut('fast');
		}
	);
	
});