var BASE_HREF = BASE_HREF || '../';

(function($){
	
	$.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; });
	};
	
	$(document).ready(function(){

		// lightbox
		$.fn.kfBox && $('.lightbox').kfBox();

		// specialni odkazy
		$('a.external').click(function(){return !window.open($(this).attr("href"))});
		$("a.print").bind("click", function() { window.print(); return false; });
		
		// Placeholder
		$('#form-q').inputDefaultText({ text: 'Hledaný výraz'});
		
		// normalni prehravac a/v
		$('#jwplayer-full').size() && jwplayer("jwplayer-full").setup({
			flashplayer: BASE_HREF + 'player.swf',
			width: 600,
			height: $('#jwplayer-full').hasClass('audio') ? 23 : 360,
			controlbar: 'bottom',
			file: $('#jwplayer-full').attr("href")
		});

		
		$('table')
			.not('.reset')
			.wrap('<div class="table-wrap"></div>')
			.find('tbody tr:odd')
				.addClass('even')
				.end()
			.find('tr td:first-child, tr th:first-child')
				.addClass('first')
				.end()
			.find('tr td:last-child, tr th:last-child')
				.addClass('last')
				.end();
		
		// cycle		
		if($.fn.cycle)
		{
			$('#intro .slides')
				.cycle({
					fx: 'fade',
					speed: 1500,
					timeout: 10000,
					pause: false,
					next: null,
					prev: null
				});
		}
		
		/* IE */
    	$('.ie6ie7 a .img img')
    		.click(function(){
    			this.parentNode.click()
    		});	
		
	});
	
})(jQuery);

