$(function(){
		$('.section:not(.active)').css('cursor', 'pointer');
		$('.toSection').each(function(){$(this).attr('href', '#'+$(this).attr('rel'))});
		
	 $('ul.items li img').hover(
		function(){
			$(this).css('opacity', 0.8);
		},
		function(){
			$(this).css('opacity', 1);
		}
	 );
	 
	 $('a[href^=#]').click(function(){$('#container div#'+$(this).attr('href').substr(1, $(this).attr('href').length)).click()});
					 
	 var running = false;
	 var speed = 770;
	 if ($.browser.msie && ($.browser.version.substr(0, 1) == '6' || $.browser.version.substr(0, 1) == '7')){
	 	speed = 10;
	 }
	 
   $('#container div.section').click(function(){
			if(!running && !$(this).hasClass('.active')){
			  running = true;
				
			  $('.active').stop().animate({ "width": '45px' }, speed, "swing", null);
			  $(this).stop().animate({ "width": '660px' }, speed, "swing", function(){ 
			  																$('.active').removeClass('active');
			  																$(this).addClass('active');
																		 	running = false; 
																		 });
				
			  $('.active').css('cursor', 'pointer');
				$('.active').removeClass('active');
			  $(this).addClass('active');
				$(this).css('cursor', 'default');
			}
   });
	 
	 $('#painting .content').append("<div id='image_details'></div>");
	 
	 $('#painting ul.items li a').click(function(){
			var imageDetails = $(this).siblings('.image_details').html();
			
			$('#painting .content #images').fadeOut('slow', function(){ 
																												 	 $('#image_details').html(imageDetails);
																												 	 $('#image_details').fadeIn('fast');
																												 	 $('#image_details a.to_painting').click(function(){
																																																		 	  $('#image_details').fadeOut('slow', function(){ $('#images').fadeIn('fast'); });
																																																	    })
																												 });
	 });

 
	 $('#photography .content').append("<div id='picture_details'></div>");
	 
	 $('#photography ul.items li a').click(function(){
			var pictureDetails = $(this).siblings('.picture_details').html();
			
			$('#photography .content #pictures').fadeOut('slow', function(){ 
																												 	 $('#picture_details').html(pictureDetails);
																												 	 $('#picture_details').fadeIn('fast');
																												 	 $('#picture_details a.to_photography').click(function(){
																																																		 	  $('#picture_details').fadeOut('slow', function(){ $('#pictures').fadeIn('fast'); });
																																																	    })
																												 });
	 });
	 
 
	 $('#drawings .content').append("<div id='paper_details'></div>");
	 
	 $('#drawings ul.items li a').click(function(){
			var paperDetails = $(this).siblings('.paper_details').html();
			
			$('#drawings .content #papers').fadeOut('slow', function(){ 
																												 	 $('#paper_details').html(paperDetails);
																												 	 $('#paper_details').fadeIn('fast');
																												 	 $('#paper_details a.to_drawings').click(function(){
																																																		 	  $('#paper_details').fadeOut('slow', function(){ $('#papers').fadeIn('fast'); });
																																																	    })
																												 });
	 });


	 
})
