$(document).ready(function(){

	$('form.search input[type="submit"]').hide();
	$('form.search input[type="text"]').focus(function(){	
		$(this).css('width','140px');
		$('form.search input[type="submit"]').fadeIn();
	});
	

	var $comments = $('#comments.comments-exist');
	if ($comments.length > 0) {
		
		var comments_count = $comments.find('h2.comments .count').text();
		
		$comments
			.find('ol').hide().end()
			.find('h2.comments')
				.addClass('functionable')
				.html('<span>Zobrazit komentáře ('+comments_count+')</span>')
				.end()
			.find('h2.comments.functionable')
				.click(function(){
					$(this)
						.removeClass('functionable')
						.html('Komentáře') //  ('+comments_count+')
						.parent().find('ol').slideDown();
				});
	
	}
	
	$('#comments')
		.find('form').hide().end()
		.find('h2.add-comment')
			.addClass('functionable')
			.html('<span>Přidat komentář</span>')
			.end()
		.find('h2.add-comment.functionable')
			.click(function(){
				$(this)
					.removeClass('functionable')
					.parent().find('form').slideDown();
			});
	
	$('h2.add-consult-question')
		.addClass('functionable')
		
		.parent().find('form')
			.hide();

	$('h2.add-consult-question.functionable')
		.click(function(){
			$(this)
				.removeClass('functionable')
				.parent().find('form').slideDown();
		});
	
	$('li.print span').click(function(){
		window.print();
	});
	
	
	// /MSIE 8-
	if (/MSIE ((5\\.5)|6|7|8)/.test(navigator.userAgent) && navigator.platform == "Win32") {

		$('.hfeed article:nth-child(odd)').addClass('odd').before('<span class="before-odd"></span>');
		
	} 
	
	// /MSIE 7-
	if (/MSIE ((5\\.5)|6|7)/.test(navigator.userAgent) && navigator.platform == "Win32") {

		$('.more a, .pagination .next a').append(' <span class="arrow">→</span>');
		$('.pagination .prev a').prepend('<span class="arrow">←</span> ');
		$('.functionable span').prepend('▼ ');

	} 
});	
