function solve(id,type)
{
	try
	{
		if(type != 'hint' && type != 'solution')
		{
			throw 'Nieprawidłowy typ!';
			return;
		}				
		$('div#puzzle_'+id+'_'+ (type == 'hint' ? 'hint' : 'solution')).show();
		$('div#puzzle_'+id+'_'+ (type == 'hint' ? 'solution' : 'hint')).hide();
		$('li#solve_'+id+'_'+ (type == 'hint' ? 'hint' : 'solution')+' a').hide();
		$('li#solve_'+id+'_'+ (type == 'hint' ? 'solution' : 'hint')+' a').show();
	}
	catch(e)
	{
		alert('Wystąpił błąd: '+e);
	}
}

function update(id,val)
{
	$('span#label_'+id).html($('span#label_'+id).html()+' ('+val+')');
}

$(document).ready(function()
{
	$('#filter input').click(function()
	{
		//$('div.puzzle').css('display','none');
		$('#filter input').each(function()
		{
			if($(this).is(':checked'))
				$('div.'+$(this).attr('id')).css('display','block');
			else
				$('div.'+$(this).attr('id')).css('display','none');
		});
	});
	
	$('.hint_link').click(function()
	{
		var nr = $(this).parent().attr('class');
		solve(nr,'hint');
		return false;
	});
	
	$('.solve_link').click(function()
	{
		var nr = $(this).parent().attr('class');
		solve(nr,'solution');
		return false;
	});
});