
$(document).ready(function()
{
	var equalizeGalleryItems = function(){
        $('.gallery-list>ul').kfEqualizeColumns({ column: 'li .name' });
	};

    equalizeGalleryItems();
    
	fontSizeListener('#footer', equalizeGalleryItems);

	$.fn.kfBox && $('.lightbox').kfBox();
	
	$('.captcha-box')
		.each(function(){
			$('.spamAnswer', this).val($('.spamHelp', this).val());
		})
		.addClass('out');

	var $carousel = $('.photo-carousel');
	if($carousel.size())
	{
    	var $prevnext = $('<div class="prevnext"><a href="#" id="arr-prev" class="arr-prev">předchozí</a> <a href="#" id="arr-next" class="arr-next">další</a></div>');
    	
    	$carousel.find('h2').after($prevnext);

		$('.photo-carousel .gallery-list').jCarouselLite({
			btnNext: '.arr-next',
	  		btnPrev: '.arr-prev',
	  		easing: "easeOutCubic",
			speed: 1000,
			visible: 6,
			scroll: 4,
			circular: false
		});
	
	}
});

function fontSizeListener($el, callback)
{
	$el = $($el);
	var h = 0;
	var interval = setInterval(function()
	{
		if($el.height() != h){
			h = parseInt($el.height());
			callback();
		}
	}, 200);
};

$.fn.kfEqualizeColumns = function(options)
{
	options = $.extend({
		column: '>li'
	}, options);

	return this.each(function(i)
	{
		var $columns = $(options.column, this);
		var maxHeight = 0;
		$columns
			.height('auto')
			.each(function(){
				var h = $(this).height();
				if(h > maxHeight) maxHeight = h;
			})
			.height(maxHeight);
	});
}
