function scrollWinners()
{
	// jscroll
	$('.winners .scroll-pane').jScrollPane({
		showArrows: true,
		verticalDragMinHeight: 24,
		verticalDragMaxHeight: 24
	});
	return false;
}

$(document).ready(function()
{

	// okno
	$('a[rel=external]').click(function()
	{
		window.open(this.href);
		return false;
	});


	// kotwice
	$('a[href^=#]').each(function(i){
		$(this).attr('href', location.href+$(this).attr('href'));
	});


	// colorbox
	$("a[rel='colorbox']").click(function()
	{
		$(this).colorbox({
			current: "{current} ({total})",
			maxWidth: '90%',
			maxHeight: '90%'
		});
	});
	
	
	// jscroll
	if($('.faq .scroll-pane').length)
	{
		$('.faq .scroll-pane').jScrollPane({
			showArrows: true,
			verticalDragMinHeight: 38,
			verticalDragMaxHeight: 38
		});
	}
	
	
	// jscroll
	if($('.winners .scroll-pane').length)
	{
		$('.winners .scroll-pane').jScrollPane({
			showArrows: true,
			verticalDragMinHeight: 24,
			verticalDragMaxHeight: 24
		});
		
		$('.winners  ul.result li .cw1').hide();
	}
	

	//scrollWinners();
	
	// zwyciezcy rozwijanie
	$('.winners ul.result li .small a.more').click(function()
	{
		$(this).parents('ul').find('.cw2').show();
		$(this).parents('ul').find('li .cw1:visible').hide();	
		$(this).parents('li').find('.cw1').slideDown(function()
		{
			$(this).next('.cw2').hide();
	
			// jscroll
			/*
			if($('.winners .scroll-pane').length)
			{
				$('.winners .scroll-pane').jScrollPane({
					showArrows: true,
					verticalDragMinHeight: 24,
					verticalDragMaxHeight: 24
				});
			}
			*/
			
		});
		return false;
	});
	
	// zwyciezcy zwijanie
	$('.winners ul.result li .header a.more').click(function()
	{
		var i = $(this).parents('li').index();
		$(this).parents('ul').find('.cw2').eq(i).show();
		$(this).parents('li').find('.cw1').slideUp();
		return false;
	});
	
	
	// nagroda główna
	$('.award-100 .cw1 .a a').toggle(function()
	{
		$('.award-3 .cw1 .a a.selected').click();
		$(this).addClass('selected');
		$(this).parents('.award-100').find('.cw2').slideDown();
	},function()
	{
		$(this).removeClass('selected');
		$(this).parents('.award-100').find('.cw2').slideUp();
	});
	
	
	// nagrody
	$('.award-3 .cw1 .a a').toggle(function()
	{
		$('.award-100 .cw1 .a a.selected').click();
		$('.award-3 .cw1 .a a.selected').click();
		$(this).addClass('selected');
		
		var i = $(this).parents('.aw').index();

		$('.award-3 .cw2').eq(i-1).slideDown();

	
	},function()
	{
		var i = $(this).parents('.aw').index();
		$('.award-3 .cw2').eq(i-1).slideUp();
		$(this).removeClass('selected');
	});
	
	// scroll To
	$('.contact .form a.call').click(function()
	{
		var target = $($(this).attr('rel'));
		$.scrollTo(target, 800);
		return false;
	});
	
	// topic 
	$('#UserTopic').keyup(function()
	{
		//$(this).val('Bobovita. Zawsze z Tobą mamo!');
	});
	
	// focus
	$('#RecommendTopic').focus(function()
	{
		$('#RecommendContent').focus();
	});
	
	//rozwijanie gry
	$('#expand_game').click(show_hide_game);
});

function show_hide_game()
{
	if($('#game_expander').is(":visible"))
	{
	
		$('#game_expander').slideUp();
	}	
	else
	{
		$('#game_expander').slideDown();
		gemius_hit('bQqV9M8RUQCad6yQACjgcrccrmIkws94zDk3msvC4KX.C7'); 
		_gaq.push(['_trackEvent', 'prezenty', 'gra_1']);
	}	
}
