
//$('.hidden-text').hide();


var infinUI = function() {
	return {
		fixIEOverflow : function(el) {
			if (!/*@cc_on!@*/0) return; // only apply to IE
			
			if (!el)
				var el = document.getElementsByTagName('*'), i = el.length;
			else
				var el = [el], i = 1;
			
			while (i--)
			{
				if (el[i].scrollWidth > el[i].offsetWidth)
				{
					el[i].style['paddingBottom'] = '20px';
					el[i].style['overflowY'] = 'hidden';
				}
			}
		},

		homepageBubble : function() {
			$('#logo a').bind('mouseover', function()
			{
				$('#homepage-title').text('domovská stránka');
			});
			$('#logo a').bind('mouseout', function()
			{
				$('#homepage-title').html('&nbsp;');
			});
		},

		dictEntries : function() {
			$('.dict-entry a').click(function()
			{
				link = $(this).attr('href');
				container = $(this).parent('.dict-entry'); 
				$(this).toggleClass('rolled-out');
				$(this).trigger('blur');
				if ($(this).hasClass('rolled-out'))
				{
					container.append('<dl></dl>');
					$('dl', container).hide();
					$('dl', container).load(link + ' dt, dd', null, function()
					{
						$(this).slideDown(200, function()
						{
							//	oprava nezadouciho vert. scrollbaru pri overflow
							infinUI.fixIEOverflow($(this).get(0));
						});
					});
				}
				else
				{
					$('dl', container).remove();
				}
				return false;
			});
		},
		
		renderDropdowns : function(url) {
			$('#main-nav dl').each(function(dlId)
			{
				if (!$(this).children().get(0))
					return;
				
				var dropdownId = 'dropdown' + dlId;
				var offset = $(this).children('dd:first').offset();
				
				$('dd', this).css('display', 'none');

				$('#' + dropdownId).remove();
				$('#mainframe').append('<div id="' + dropdownId + '" class="dropdown"><p>Vyberte si&hellip;</p></div>');

				$('dd', this).each(function(id)
				{
					if (url == (link = $('a', this).attr('href')))
					{
						// ...
					}
					
					$('#' + dropdownId).append('<a href="' + $('a', this).attr('href') + '">' + $(this).text() + '</a>');
					$(this).remove();						
				});

				var x = Math.floor(($('body').width() - $('#mainframe').width()) / 2);
			
				$('#' + dropdownId).css('width', $('#main-nav dt').width() - 2);
				$('#' + dropdownId).css('top', offset.top);
				$('#' + dropdownId).css('left', offset.left - x + 8);
			});

			$('.dropdown').mouseover(function()
			{
				$('p', this).addClass('hover');
			});				

			$('.dropdown').mouseout(function()
			{
				$('p', this).removeClass('hover');
			});				

			$('.dropdown p').click(function()
			{
				//$('.droped').removeClass('droped');
				$(this).parent().toggleClass('droped');				
			});
			
			var timer = new Array;

			$('.dropdown').mouseout(function(id)
			{
				timer[id] = setTimeout(function()
				{
					$('.droped').removeClass('droped');
				}, 1000);

				$('.dropdown').mouseover(function(id)
				{
					clearTimeout(timer[id]);
				});
			});
		}
	};
}();







/* LABOROVANI */
/*
	renderDropdowns = function(actualUrl)
	{
		$('#dropdown p').click(function()
		{
			$(this).parent().toggleClass('droped');				
		});
	
		$('#main-nav dl').each(function()
		{
			var i = null;
			var html = '';
			var offset;
			
			$('dd', this).each(function(id)
			{
				if (actualUrl == (link = $('a', this).attr('href')))
				{
					i = id;
					
					$('#dropdown').remove();
					$('#mainframe').append('<div id="dropdown-" class="dropdown"><p>Vyberte si&hellip;</p></div>');
					
					if (!offset)
						offset = $('dl', $(this).parent()).offset();
													
					$('#dropdown').append(html + '<a href="' + $('a', this).attr('href') + '">' + $(this).text() + '</a>');						
					//$('#dropdown').append(html + $(this).text() + '<br />');
					
					//$(this).css('position', 'relative');
					//$(this).replaceWith('<dd id="roller">' + html + text + '<br /></dd>');
	
					//$(this).css('background-color', 'blue');
					
				}
				else
				{
					if (!i)
						html += '<a href="' + $('a', this).attr('href') + '">' + $(this).text() + '</a>';
					else
						$('#dropdown').append('<a href="' + $('a', this).attr('href') + '">' + $(this).text() + '</a>');	
					
					$(this).css('display', 'none');
				}
			});
			
			if (i == null)
				return;
			
			var x = Math.floor(($('body').width() - $('#mainframe').width()) / 2);
			
			$('#dropdown').css('width', $('#main-nav dt').width() - 2);
			$('#dropdown').css('top', offset.top);
			$('#dropdown').css('left', offset.left - x + 8);
			//$('#dropdown').css('height', '140px');
			//$('#dropdown').css('overflow', 'auto');
			//fixIEOverflow($('#dropdown').get(0));
			$('#dropdown').get(0).scrollTop = i * 20;
			
			//offset.left - x
			
			//alert(i);
		});
	});
*/