function redirect(url,absolute)
{
window.location=(absolute ? '':baseUrl)+url;
}



$j(document).ready( 
					function ()
					{
					if ( $j('#selectCategory').attr('value')=='brak') $j('#selectCategory').attr('disabled',1);
					$j('#selectCategoryButton').click(
													function()
													{
													kat=$j('#selectCategory').attr('value');
													ven=$j('#selectVendor').attr('value');
													if (kat!='brak')
													redirect('produkty,lista,prod,'+ven+',kat,'+kat);
													}
													);
					
										
					
					
					$j('#selectVendor').change(
													function()
													{
													
													ven=$j('#selectVendor').attr('value');
													redirect('produkty,lista,prod,'+ven);
													return true;
													
													
													}
													);
					}								
					);


////////galeria w produktach:


var galleryPosition=1;
var galleryPhotosPerPage=4;
var galleryPhotosCount=null;

$j(document).ready( 
		function ()
		{

			galleryPhotosCount=$j('div#photos_mini div.product_image').size();


		
			$j('#moveGalleryLeft').click(
										function()
										{
											if (galleryPosition>=1+galleryPhotosPerPage)
												galleryPosition-=galleryPhotosPerPage;
											else if (galleryPosition>1)
												galleryPosition-=galleryPosition-1;
											
											$j('div#photos_mini div.product_image').each(function(i)
																					{
																					//i - index poczynając od 0
																						if ( i+1>=galleryPosition && i+1<galleryPosition+galleryPhotosPerPage )
																							$j(this).css('display','block');
																						else
																							$j(this).css('display','none');
																							
																					}
																				);
											if (galleryPosition==1)
												$j('#moveGalleryLeft').css('visibility','hidden');
											
											if (galleryPosition+galleryPhotosPerPage<=galleryPhotosCount)
												$j('#moveGalleryRight').css('visibility','visible');
												
										}
										);
		
			$j('#moveGalleryRight').click(
										function()
										{
											if (galleryPosition+galleryPhotosPerPage<=galleryPhotosCount-galleryPhotosPerPage+1)
												galleryPosition+=galleryPhotosPerPage;
											else if (galleryPosition+galleryPhotosPerPage<=galleryPhotosCount)
												galleryPosition+=galleryPhotosCount-galleryPosition-galleryPhotosPerPage+1;
												
											
											$j('div#photos_mini div.product_image').each(function(i)
													{
													//i - index poczynając od 0
														if ( i+1>=galleryPosition && i+1<galleryPosition+galleryPhotosPerPage )
															$j(this).css('display','block');
														else
															$j(this).css('display','none');
															
													}
												);
											
											
											if (galleryPosition>1)
												$j('#moveGalleryLeft').css('visibility','visible');
																						
											if (galleryPosition+galleryPhotosPerPage>galleryPhotosCount)
												$j('#moveGalleryRight').css('visibility','hidden');
											
										}
										);							

		}								
		);
									

				
