//show product list with ajax
function showProducts(params, idLink, scrollTo)
{
	if (params == null || params == 0)
		return false;
	var page = baseDir + 'modules/productfilter/product-filter.php?';
	if (idLink != null)
	{
		// block display
		$('#productfilter a').removeClass("current");
		$('#productfilter a#'+idLink).addClass("current");
	}
	$.get(
		page + params,
		{ 'content_only': 1 },
		function(data, textStatus) {
			$('#products_list').fadeOut('fast', function()
			{
				$(this).html(data);

				// add the link to clear the filter
				$('#productfilter_clear').attr('href', document.location.href);

				// change pagination link
				var pageNum, myHref;
				$('#pagination a').each(function(i) {
					if ( params.search(/&p=.*/gi) )
						params = params.replace(/&p=.*/gi, '');
					myHref = this.href;
					pageNum = myHref.match(/p=.*/gi);
					if (pageNum == null)
						pageNum = '';
					else
						pageNum = '&'+pageNum;
					if (idLink != null)
						this.href = "javascript:showProducts('"+params+pageNum+"', '"+idLink+"', true)";
					else
						this.href = "javascript:showProducts('"+params+pageNum+"', null, true)";
				});

				// hide nb_items form
				$('#pagination form').remove();

				$(this).fadeIn('fast');
				if (scrollTo == true)
					$.scrollTo('#products_list', 1200);
			});
		},
		"html"
	);
}

function resetSelect(elt)
{
	var selectId = elt.attr('id');
	$('#productfilter select:not(#'+selectId+') option').each(function(i) {
		$(this).attr('selected', '');
	});
	$('#productfilter select:not(#'+selectId+') option:first-child').attr('selected','selected');
}

