
$(document).ready(
	function()
	{
		 
		$("#gridView").click(function () {
			document.location = "/category/switchview/viewStyle/grid";
			
		});
		$("#listView").click(function () {
			document.location = "/category/switchview/viewStyle/list";
		});
		$("#orderByNameDesc").click(function () {
			document.location = "/category/order/orderBy/nameDesc";
		});
		$("#orderByNameAsc").click(function () {
			document.location = "/category/order/orderBy/nameAsc";
		});
		$("#orderByPriceDesc").click(function () {
			document.location = "/category/order/orderBy/priceDesc";
		});
		$("#orderByPriceAsc").click(function () {
			document.location = "/category/order/orderBy/priceAsc";
		});
		
		
		
		$("#manufacturerSelectBox").change(function() {
			if (!this.value) {
				$("#collectionBox").fadeOut('slow');
				$("#collectionBox").html('');
				return false;
			}
			
			$.getJSON("/manufacturer/seriesajax", { manufacturerId: this.value, categoryId: $("#categoryId").val()},
				
				function(data) {
					
					if (data.length > 0) {
						
						var select = '';
						select += '<select name="traits[collection]" id="collection" style="width:130px;">\n';
						select += '<option value="0">--wybierz</option>'
						for (i in data) {
							option = '<option value="' + data[i].id + '">' + data[i].name + '</option>';
							select += option + "\n";
						}
						select += '</select>';
						
						$("#collectionBox").html(select);
						$("#collectionBox").fadeIn('slow');
					} else {
						
						$("#collectionBox").fadeOut('slow');
						$("#collectionBox").html('');
						
					}
					return false;
				});
			
			
			
			});
		
		
		$("#producenciTab").click(function() {
			
			$("#producenciTab").removeClass("producenciInactive").addClass("producenciActive");
			$("#asortymentTab").removeClass("asortymentActive").addClass("asortymentInactive");
			
			
			$("#asortymentContainer").fadeOut('slow', function() {
				$("#producenciContainer").fadeIn('slow');
			});
			
			
		});
		
		$("#asortymentTab").click(function() {
			
			$("#producenciTab").removeClass("producenciActive").addClass("producenciInactive");
			$("#asortymentTab").removeClass("asortymentInactive").addClass("asortymentActive");
			
			$("#producenciContainer").fadeOut('slow', function() {
				$("#asortymentContainer").fadeIn('slow');
			});
			
			
		});
		
     }
);  

