Cufon.replace('h1, #slogan, .side-box h2');

$(document).ready(function()
{
	$.fn.kfBox && $('.lightbox').kfBox();

	$('table tr:nth-child(even)').addClass('even');
	$('table tr td:first-child').addClass('firstcol');

	$('a.external').click(function(){return !window.open($(this).attr("href"))});

	$('#q').inputDefaultText({ text: 'Hledaný výraz'});

	/* vkládání flashe */

	$('.flash-banner').each(function(){
		flashsize = $(this).find('a').attr('data-flashsize');
		flashsize = flashsize.split("x");
		$(this).flash(
		{
			src: $(this).find('a').attr('href'),
			width: flashsize[0],
			height: flashsize[1],
			wmode: 'opaque',
			flashvars: {}
		});
		$(this).find('.alt').css("display","none");
	});

	/* vkládání mp3 */
	$('.flash-player').each(function(){
 		$(this).flash(
          {
               src: BASE_HREF + 'flash/player.swf',
               width: 350,
               height: 20,
               wmode: 'opaque',
               flashvars: {file: $(this).find('a').attr('href'), searchbar: 'false', autostart: 'false', frontcolor: '0x666666', image: $(this).find('img').attr('src')}
          }
     	);
     	// nebudeme zobrazovat alt
     	$(this).find('.alt').css("display","none");
	});

});

$.fn.inputDefaultText = function(options)
{
	options = $.extend({
		text: 'Hledany vyraz'
	}, options);

	return this
		.val(options.text)
		.bind('focus', function(){ if(this.value == options.text) this.value = ''; })
		.bind('blur', function(){ if(this.value == '') this.value = options.text; });
};

$(window).bind('load', function()
{
	fontSizeListener('#footer', equalizeHeights);

});

$.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);
	});
}

function fontSizeListener($el, callback)
{
	$el = $($el);
	var h = 0;
	var interval = setInterval(function()
	{
		if($el.height() != h){
			h = parseInt($el.height());
			callback();
		}
	}, 200);
};

var equalizeHeights = function()
{
	$('.signpost>ul').kfEqualizeColumns({ column: '.inner' });
};

