var HOME = 'http://www.arnaud-k.fr';

jQuery(function( $ ){
	
	if($('#slider').is(':visible'))
	{
		presentationCycle.init();
	}
	
	if($('#portfolio').is(':visible'))
	{
		$('#photo img').not(':first').hide();
	
		$('#pagination a').hover( function() { $('p#legende').text($(this).attr('rel')) } , function() { $('p#legende').text('') });
		
		$('#pagination a').click( function(e) {
			e.preventDefault();
			var nb = 	$('#pagination a').index(this);
			nb++;
			
			$('#photo img.active').fadeOut('slow').removeClass('active');
			$('#photo img:nth-child('+nb+')').fadeIn('slow').addClass('active');
			
			$('#description div:visible').fadeOut('fast', function() { 
				$('#description div.active').removeClass('active').addClass('hidden');
				$('#description div:nth-child('+nb+')').fadeIn('slow').addClass('active').removeClass('hidden');
			});
			
			$('#pagination a.active').removeClass('active');
			$(this).addClass('active');
		});
		
		$('p.more-photos a').click( function(e) {
			e.preventDefault();
			
			if(!$(this).hasClass('grey'))
			{
				var $this = $(this);
				$('#photo img.active').fadeOut('slow', function() {
					$('#photo img.active').attr('src' , 'im/captures/'+$this.attr('rel') ).load( function() {
						$(this).fadeIn('slow');
					});
				});
				
				$(this).siblings().removeClass('grey');
				$this.addClass('grey');
			}
		});
	}
	
});
