/// <reference path="jquery-1.3.2.js" />
function aktywny_link(ten)
{
				
				var aktywny = $('.lista_navi .numbers .aktywne').attr('id');
				//aktywny = aktywny.charAt(0);	
				if(aktywny == ten)
				{
					return false;
				}
				tenInt = parseInt(ten);
				var prev_page = tenInt-1;
				var next_page = tenInt;
				var page_count = $('a.numer').length/2-4;
				
				if($('.lista_navi a#'+next_page).is("a"))
					next_page = tenInt+1;
				
				if(tenInt >= 1 && tenInt <= page_count)
				{
					if(tenInt > 1)
						$('.lista_navi a.prev_page').attr('id', (prev_page).toString());
					else
						$('.lista_navi a.prev_page').attr('id', (1).toString());
					if(tenInt < page_count)
						$('.lista_navi a.next_page').attr('id', (next_page).toString());
					else
						$('.lista_navi a.next_page').attr('id', (page_count).toString());
						
				}
					
				
				$('.lista_navi a.numer').removeClass('aktywne');	
				$('.lista_navi a.numer').each(function(){
							if((parseInt($(this).attr('id')) >= tenInt-3 && parseInt($(this).attr('id')) <= tenInt+3) 
															|| $(this).hasClass('last_page') 
															|| $(this).hasClass('first_page')
															|| $(this).hasClass('next_page')
															|| $(this).hasClass('prev_page')
							)
								$(this).css('display', 'inline');
							else
								$(this).css('display', 'none');
								
							if($(this).attr('id') == ten)
							{
								$(this).addClass('aktywne');
							}
						 });
				$('#page_'+ten+' img').each(function(){
							var img_load = $(this).attr('id');
							//alert(product_images[""+img_load+""]);
							//for (key in product_images)
 							//if(img_load==product_images[key])
						 $(this).attr('src',product_images[img_load]);
					});
				$('.lista div.page').eq(aktywny-1).slideUp('normal');
				$('.lista div.page').eq(ten-1).slideDown('slow');//.css('display','block');
				return false;
				
}
$(document).ready(function() {
		//$('.lista div.page').css('display','none');
		
		var recent_page_href = document.location.href;
		var hash = recent_page_href.indexOf('#');
		hash++;
		
		var page = recent_page_href.substring(hash);
	
		ten = '1';
		if(page.length>0)
		{
			if(hash)
			{
				ten = page;
			}
		}
		$('.lista div.page').eq(parseInt(ten)-1).css('display','block');
		
		$('#page_'+ten+' img').each(function(){
			var img_load = $(this).attr('id');
			$(this).attr('src',product_images[img_load]);
		});
	

		$('.lista_navi a.numer').each(function(){
			tenInt = parseInt(ten);
			
			if((parseInt($(this).attr('id')) >= tenInt-3 && parseInt($(this).attr('id')) <= tenInt+3) 
					|| $(this).hasClass('last_page') 
					|| $(this).hasClass('first_page')
					|| $(this).hasClass('next_page')
					|| $(this).hasClass('prev_page')
				)
				$(this).css('display', 'inline');
			else
				$(this).css('display', 'none');
			
			if(parseInt($(this).attr('id')) == tenInt)
					$(this).addClass('aktywne');
		aktywny_link(ten);
		});
				
		$('.lista_navi a.numer').click(function(){
				var ten = $(this).attr('id');
				aktywny_link(ten);	
				return false;
		});
		
		//pokaz/ukryj
		$('.show_all a').toggle(function(){
				$('.lista div.page').css('display','block');
				$('.lista_navi .numbers').css('display','none');
				$('.show_all a').text(powrot_label);
				
				$('.lista div.page img').each(function(){
					var img_load = $(this).attr('id');
					$(this).attr('src',product_images[img_load]);
				});

				return false;
			},function(){
				$('.lista div.page').css('display','none');
				$('.lista div.page').eq(0).css('display','block');
				$('.lista_navi .numbers').css('display','block');
				$('.show_all a').text(zobacz_wszystkie_label);
			});
		
		// karta produktu
		$('.produkt_duzy .img_hrefs a').click(function(){
			var img_this = $(this).text();
			var img_href = $(this).attr('rel');
			$('.produkt_duzy .img_hrefs a').removeClass('aktywne');
			$(this).addClass('aktywne');
			$('.produkt_duzy img').attr('src',img_href).fadeIn('slow');;
			return false;
			});
		
});
		