Startup = {
	
		construct : function () {
		$(document).ready(function() {
			
			$('#categorybox').selectbox();
			$('#shopabc').selectbox({
					onChange: function() { $('#form_shopabc').submit(); }
				});
			$('.chbox > p > input:radio').checkbox({empty: '/inc/gfx/empty.png'});
			$('input:checkbox').checkbox({empty: '/inc/gfx/empty.png', cls:'jquery-filtr-checkbox'});
			
			(function ($) {
				$.fn.vAlign = function(container) {
					return this.each(function(i){
						if(container == null) {
							container = 'div';
						}
						var el = $(this).children(":first");
						var elh = $(el).height();

						if (elh > 0) {
							var ph = $(this).height();
							if (ph > elh) {
								$(this).html("<" + container + ">" + $(this).html() + "</" + container + ">");
								var nh = (ph - elh) / 2;
								el = $(this).children(container + ":first");
								$(el).css('margin-top', nh);
							}
						}
					});
				};
			})(jQuery);
		});
		
	$(window).load(function() {
		$("div.popular_photo").vAlign();
		$("div.product_photo").vAlign();
	});
	},

	toggle_filtr : function () {
		var el;
		el = $('#filtr_hidden');
		
		if (el.css('display') == 'none') {
			el.slideDown(1500);
		}
		else {
			el.hide();
		}
	},
	
	toggle_attributes : function(trait_id) {
		var el, btn;
		el = $('#filtr_hidden_' + trait_id);
		btn = $('#toggle_button_' + trait_id);
		
		if (el.css('display') == 'none') {
			el.slideDown(1000);
			btn.html('Zwiń');
		}
		else {
			el.hide();
			btn.html('Rozwiń');
		}		
	},
	
	slider_init : function(price_min, price_max, range_min, range_max) {
		if (price_min == 0) {
			price_min = range_min;
		}
		if (price_max == 0) {
			price_max = range_max;
		}
		$("#slider-range").slider({
			range: true,
			min: range_min,
			max: range_max,
			values: [price_min, price_max],
			slide: function(event, ui) {
				$("#price_min").val(ui.values[0]);
				$("#price_max").val(ui.values[1]);
			}
		});
		$("#price_min").val($("#slider-range").slider("values", 0));
		$("#price_max").val($("#slider-range").slider("values", 1));
	}
};

Startup.construct();
