$(document).ready(function() {
	$('a.box').find('.label').css('opacity', 0);
	
	$('a.box').mouseover( function() {
		var $right = $(this).find('.exhibition-right');
		if($right.css('width') != 255)
		{
			$right.stop(true, false);
			$right.animate({width: '255px'}, 300, function() {
				$(this).find('.label').removeClass('hidden').animate({opacity: 1}, 300);
			});
		}
	});
	
	$('a.box').mouseout( function(ev) {
		if($(ev.relatedTarget).parents('.box').size() == 0 || $(ev.relatedTarget).parents('.box').get(0) != $(this).get(0))
		{
			$(this).find('.exhibition-right').stop(true, false);
			$(this).find('.label').animate({opacity: 0}, 300, function() {
				$(this).addClass('hidden');
				$(this).parent().animate({width: '135px'}, 300);
			});
		}
	});
	
	$('a.fancybox').fancybox({
		'transitionIn'		: 'linear',
		'transitionOut'	: 'linear',
		'speedIn'			: 600, 
		'speedOut'			: 200, 
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000000',
		'titlePosition'	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts)
		{
			return '<span id="fancybox-title-over">' + (typeof title != 'undefined' ? title + '<br />' : '')  + '<span class="small italic">Foto ' + (currentIndex + 1) + ' z ' + currentArray.length + '</span></span>';
		}
	});
});
