//GF_Debug.s_iLevel = GF_Debug.LEVEL_ALL; // Linijka do usuniecia, gdy zakonczone zostana prace.

$(document).ready(function() {
	
	// LISTA NEWSOW
	$('#content ul.newslist.collapsible').accordion({
		header: 'li h3',
		autoHeight: false,
		clearStyle: true
	});
	
	$('#content ul.newslist.collapsible a').click(function() {
		if ($(this).parent().hasClass('ui-state-active')) {
			window.location = $(this).attr('href');
		}
		else if ($(this).parent().is('small')) {
			window.location = $(this).attr('href');
			return false;
		}
	});
	
	// OPCJE WYSZUKIWANIA
	$('#search .go-to-options a').click(function() {
		$(this).toggleClass('active');
		$('#search-options').slideToggle(100);
		return false;
	});
	
	// ROZWIJANIE SUBMENU
	$('#navigation li:has(ul)').mouseenter(function(e) {
		$(this).children('ul').stop(true, true).slideDown(200);
	}).mouseleave(function(e) {
		$(this).children('ul').stop(true, true).slideUp(75);
	}).find('ul').css('display', 'none');
	
	// ZAKLADKI W HELPIE
	$('.help .categories').parent().tabs({
		fx: {
			opacity: 'toggle',
			duration: 150
		}
	});
	
	// FAQ
	$('.faq dd').css('display', 'none');
	$('.faq dt').click(function() {
		$(this).closest('dl').find('dt').removeClass('active');
		$(this).addClass('active');
		$('.faq-description').empty().append('<h4>' + $(this).text() + '</h4>').append($(this).next('dd').html());
	}).css('cursor', 'pointer').hover(function() {
		$(this).css('text-decoration', 'underline');
	}, function() {
		$(this).css('text-decoration', 'none');
	});
	$('.faq dt.active').click();
	
	// SLICZNE SELECTY
	$('select').each(function() {
		if ($(this).parents('.account, .filter, .find-user, .forum-form, .search-form').length) return;
		$(this).parent().append('<span class="faux">' + $(this).find('option:selected').text() + '</span>');
		$(this).change(function() {
			$(this).parent().find('.faux').text($(this).find('option:selected').text());
		});
	});
	
	// SLIDER
	if ($('#slider').length) {
		new GF_Slider($('#slider'));
	}
	$('#breadcrumbs ol').append($('<li></li>').append($('.submenu .active a').clone()));
	if($(".panel-contents").find("h3").text()!=""){
	$(".left-section h3").text($(".panel-contents").find("h3").text());
	}
	//$('#breadcrumbs ol').append($('<li></li>').append($('.submenu .active a').clone()));
	//$("#register_member_form").addClass("panel-contents");
});
