function product_information_imgSwap(img)
{
	var curImg = $('product_information_large_image_tag').src;
	var new_img = img.src;
	
	$('product_information_large_image_tag').src = new_img.replace('thumb', 'small');
	
	img.src = curImg.replace('small', 'thumb');	
}

function toggle_long_description(ref)
{
	$('product_information_long_description').toggle();
	$('product_show_more').destroy();
}

function toggle_filter(filter_id, unit_id, ref)
{
	new Request({
			url: '/productfilter/'+filter_id+'/'+unit_id+'/'+ref.checked+'/toggle.html',
			onRequest: function()
			{
						$$('.category_table').each(function(el) {
							el.addClass('loading');
						});			
			
			},
			onComplete: function()
				{	
					if(this.response.text == 0)
					{
						update_category();
					}
				}
			
		}).send();

}
function toggle_sort(sort_field)
{
	new Request({
			url: '/productfilter/'+sort_field+'/sort.html',
			onRequest: function()
			{
						$$('.category_table').each(function(el) {
							el.addClass('loading');
						});			
			
			},
			onComplete: function()
				{	
					if(this.response.text == 0)
					{
						update_category();
					}
				}
			
		}).send();
}
function clearFilters()
{
	new Request({
			url: '/clearproductfilter/clear.html',
			onRequest: function()
			{
						$$('.category_table').each(function(el) {
							el.addClass('loading');
						});			
			
			},			
			onComplete: function()
				{	
					if(this.response.text == 0)
					{
						update_category();
						resetFilterForm();
					}
				}
			
		}).send();
}
function resetFilterForm()
{
	$$('.filtercheckbox').each(function(el) {
		el.checked = false;
	});		

	$$('.slider_minmax_maxKnobA').each(function(el) {
		el.setStyle('left', '125px');
	});		
	$$('.slider_minmax_minKnobA').each(function(el) {
		el.setStyle('left', '0px');
	});			
	$$('.slider_bkg_img').each(function(el) {
		el.setStyle('clip', 'rect(0px, 138px, 10px, 10px)');
	});		
		

}
/*
function toggle_range_filter(filter_id, range_id, ref)
{
	new Request({
			url: '/productfilter/'+filter_id+'/'+range_id+'/'+ref.checked+'/range.html',
			onRequest: function()
			{
						$$('.category_table').each(function(el) {
							el.addClass('loading');
						});			
			
			},
			onComplete: function()
				{	
					if(this.response.text == 0)
					{
						update_category();
					}
				}
			
		}).send();

}*/
function update_category()
{
	new Request({
			url: '/productfilter/update.html',
			onComplete: function()
				{	
					$('main_container').innerHTML = this.response.text;
				}
			
		}).send();

}

