/* 
	JavaScript by Krzysztof Wolniak
	WWW: http://wolniak.org
	(c) All rights reserved
*/

$(document).ready(function(){

	// Pobieramy jezyk strony
	var lang = $('html').attr('lang');
	
	var language = {
		ce: {
				pl: { collapse: 'zwiń', expand: 'rozwiń', all: 'wszystkie' },
				en: { collapse: 'collapse', expand: 'expand', all: 'all' }
		      }
	};
	
	ceLang = language.ce[lang];
	
	// Efekt na menu
	
	if(jQuery.support.noCloneEvent)
	{
		$('#nav a').hover(function(){
			$(this).fadeTo(0, 0.3, function(){
				$(this).fadeTo("normal", 1);
			});
		});
		
		$('#subnav a').hover(function(){
			$(this).fadeTo(0, 0.3, function(){
				$(this).fadeTo("normal", 1);
			});
		});	
	}
	
	// Menu boczne - Rozwijanie
	
	var nestedUL = $('.sub>ul'); 
	
	nestedUL.hide();
	$('.sub>a').toggle(function(){
		nestedUL.slideDown("slow");
		
	}, function(){
		nestedUL.slideUp("slow");
		
	});
	
	if($('body').is('.rl, .it, .zg, .ee, .ws'))
	{
		nestedUL.show();
		$('.sub>a')[0].lastToggle = 1;
	}
	
	/* -- Listy rozwin/zwin -- */
	
	// Ukrywam opis punktow
	$('.items dd').css('display', 'none');
	
	// Ustawiam kursor na pointer
	// oraz dodaje element wskazujacy ze mozna rozwijac/zwijac
	$('.items dt:not(.ce)').css({
		'cursor' : 'pointer'
	}).append('<span class="expand" title="'+ ceLang.expand +'">&nbsp;</span>');
	
	// Dodaje event klikniecia na box rozwijajacy/zwijajacy
	$('.items dt:not(.ce)').toggle(function(){
		
		$('.items dd').each(function(){
			$(this).hide();
			$(this).prev()[0].lastToggle = 2;
		});
		
		$(this).children('span').removeClass('expand').addClass('collapse').attr('title', ceLang.collapse).text(' ').fadeIn('fast');
		$(this).next().fadeIn('normal');
	}, function(){
		$(this).children('span').removeClass('collapse').addClass('expand').attr('title', ceLang.expand).text(' ').fadeIn('fast');
		$(this).next().hide('normal');
	});
	
	
	/* -- end, Listy rozwin/zwin -- */
	
});
