$(function(){
	/*$("a.open_slideshow").fancybox({
		'hideOnContentClick': true,
		'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'width'				: 580,
		'height'			: 360,
		'padding'			: '0'
	});*/
	
	$("a.open_slideshow").bind('click', function(){
		$('#slideshow_popup a.thumbnail_notitle:first').trigger('click');
		
		return false;
	});
	
	
	
	$('a.thumbnail').fancybox({
		'titlePosition'	:	'over'
	});
	
	setTimeout(function(){
		$('.GalleryThumbnail a.thumbnail').each(function(i, item){
			var $a = $(item);
			var $img = $a.find('img');
			if($img.width() > $img.height() && $img.width() && $img.height() > 0){
				var new_margin = ($a.height() - $img.height()) / 2;
			}
			
			if(new_margin > 0){
				console.log(i, $a.height(),'-',$img.height(),'/2 =',new_margin);
				$img.css({'margin-top': new_margin+'px'});
			}
			
			$a = null;
			$img = null;
			new_margin = null;
		});
	}, 200);
	
	$('a.thumbnail_notitle').fancybox({
		'titlePosition'	:	'over',
		'onComplete'	:	function() {
			$("#fancybox-title").hide();
		}
	});
	
	$('h2 .album_title').bind('click', function(){
		$(this).parents('h2').next('.gallery_images,.thumbs').toggle('slow', function(){
			$('.yscroll').jScrollPane({dragMaxHeight: 10, showArrows: true, scrollbarWidth: 16});
		});
		
		return false;
	});
	
	$('.yscroll').jScrollPane({dragMaxHeight: 10, showArrows: true, scrollbarWidth: 16});
});

