function OutputResults(Contents)
{
	$('result_content').update(Contents);
	new Effect.Fade('product_ajax_loader', {duration : 0.5});
	new Effect.Appear('result_content', {duration : 0.5});
}

function FilterResults(Url, NedstatPath)
{
	new Effect.Fade('result_content', {duration : 0.5});
   	new Effect.Appear('product_ajax_loader', {duration : 0.5});
	
   	new Ajax.Request('/ajax'+Url, 
	{
		onSuccess: function(transport)
		{
       		Response = EvalResponse(transport);
       		if (Response.status && 'ok' == Response.status)
       		{
       			if (Response.filters)
       			{
       				$('filters').update(Response.filters);
			  		sitestat(NedstatPath);
       			}
       			if (Response.listing)
       			{
       				OutputResults(Response.listing);
       			}
       		}
		},
		onFailure: function(transport, jsonreponse)
		{
			OutputResults('<br /><p>Your request has taken longer than normal to load. <a href="' + Url + '">Click here to continue</a>.</p>');
		},
		onException: function()
		{
			OutputResults('<br /><p>Your request has taken longer than normal to load. <a href="' + Url + '">Click here to continue</a>.</p>');
		}
	});
	
	return false;
}

function UpdateTopHeader(Type)
{
	if(false == window.RunAsPanelModule)
	{
		new Effect.Opacity('header', { duration : 0.5, from : 1.0, to : 0});
		new Ajax.Request(window.BaseUrl + '/updateheader/' + Type,
		{
			onComplete: function(transport)
			{
		  		$('header').update(transport.responseText);
		  		new Effect.Opacity('header', { duration : 0.5, from : 0, to : 1.0});
			}
		});
	}
}

function ToggleSort(Index)
{
	if($('lnk_sort-by-div'+Index).hasClassName('lnk_sort-by-active'))
	{
		HideSort(Index);
	}
	else
	{
		OpenSort(Index);
		
	}
}

function OpenSort(Index)
{
	if($('lnk_sort-by-div'+Index).hasClassName('lnk_sort-by-inactive'))
	{
		$('lnk_sort-by-div'+Index).removeClassName('lnk_sort-by-inactive');
	}
	$('lnk_sort-by-div'+Index).addClassName('lnk_sort-by-active');
}

function HideSort(Index)
{
	if($('lnk_sort-by-div'+Index).hasClassName('lnk_sort-by-active'))
	{
		$('lnk_sort-by-div'+Index).removeClassName('lnk_sort-by-active');
	}
	$('lnk_sort-by-div'+Index).addClassName('lnk_sort-by-inactive');
}