function setUserFilter()
{
	
	var d=document.searchform;
	var index1=d.f_feature_1.selectedIndex;
	var index2=d.f_feature_2.selectedIndex;
	var index3=d.f_feature_3.selectedIndex;
	var index4=d.f_feature_4.selectedIndex;

	var select1=d.f_feature_1.options[index1].value;
	var select2=d.f_feature_2.options[index2].value;
	var select3=d.f_feature_3.options[index3].value;
	var select4=d.f_feature_4.options[index4].value;

	var keyword=trim(d.f_keyword.value);

	if("<?=$a4?>"!='')
	{
		var distributorVal="<?=$a4?>"*1;
	}
	else
	{
		var distributorVal="";
	}

	if((!keyword || keyword=='szukaj produktu...') && select1=='' && select2=='' && select3=='' && select4=='' && distributorVal=='')
	{		
		alert("Nie wybrano żadnych wartości do zapisania w Twoim filtrze!");
	}
	else
	{
		//alert(userid_js);
		//var uid="<?=$_COOKIE['userid']?>";
		var uid=userid_js;

		$.ajax({
		   type: "POST",
		   url:	"/ajax/manage_filter.php",
		   data: "action=addFilter&uid="+uid+"&keyword="+keyword+"&select1="+select1+"&select2="+select2+"&select3="+select3+"&select4="+select4+"&distributorVal="+distributorVal,
		  
			success: function(msg)
			{
				if(msg==1)
				{
					alert("Ustawienia Twojego filtru zostały zapamiętane!");
					if(document.getElementById('btn_search_disc')) document.getElementById('btn_search_disc').id="btn_search_disc_on";
				}
				else alert(msg+" Coś poszło nie tak! Spróbuj jeszcze raz...");
			}
		});

	}
}

function clearUserFilter()
{
	if(confirm("Czy na pewno chcesz usunąć zapamiętany filtr?"))
	{
		
		//var uid="<?=$_COOKIE['userid']?>";
		var uid=userid_js;

		$.ajax({
		   type: "POST",
		   url:	"/ajax/manage_filter.php",
		   data: "action=deleteFilter&uid="+uid,
		  
			success: function(msg)
			{
				 //if(msg==1) alert("Ustawienia filtru zostały usunięte!");
				 //else alert("Coś poszło nie tak! Spróbuj jeszcze raz...");

				 document.location.href=makeLink(linkprefix);
			}

		});
	}


}

function reloadPromptOptions()
{

	window.clearInterval(promptInterval);
	document.getElementById("prompt_counter").value=0;
	document.getElementById("final_counter").value=0;
	promptInterval="";
	
	var txt=trim(document.getElementById("searchfield").value);

	$.ajax({
		   type: "POST",
		   url:	"./ajax/manage_prompt.php",
		   data: "action=getValues&txt="+txt+"&s="+s_js+"&iso="+iso_js,
		  
			success: function(msg)
			{

				//alert(msg);
				var promptfield=document.getElementById('searching_prompt');
				if(msg)
				{	
						promptfield.innerHTML=msg;	
						promptfield.style.display="block";	
				}
				else
				{
						promptfield.innerHTML="";	
						promptfield.style.display="none";
				}
			}
		});
}
