
	
	
	function onSortMethodChanged()
	{
		curURL = document.getElementById("pageURL").value;
		sortSelection=document.getElementById("sortSelect");
		index = sortSelection.selectedIndex;
		newSort = sortSelection.options.item(index).text.toLowerCase();
		sortCode="0";
		if(newSort=="recency"){
			sortCode=1;
		}
		sortKV = "sort="+sortCode;
		
		if(curURL.indexOf(sortKV)>-1)
			return;//no change in sort
		
		
		
		re=/sort=\w+&/;//search for the current sort
		newURL = curURL.replace(re,sortKV+"&");//replace it with the new sort
		document.location = newURL;
		
	}
	
	function onSearchContent() 
	{
		curURL = document.getElementById("pageURL").value;
		newTerm = encodeURIComponent(document.getElementById("txtSearch").value);
		re=/\/_t_\/.*\?/;
		newURL = curURL.replace(re,"/_t_/"+newTerm+"?");
		re2=/q=.*/
		newURL = newURL.replace(re2,"q="+newTerm);
		document.location = newURL;
	}


	function search_onkeydown(e) 
	{
		if (e.keyCode != 13)
		  return;
		
		e.returnValue = false;
		onSearchContent();	
		return false;
	}
	
	function navigateSearchUsers()
	{
		
		curURL = document.getElementById("pageURL").value;
		newTerm = encodeURIComponent(document.getElementById("txtSearch").value);
		re=/\/_t_\/.*\?/;
		newURL = curURL.replace(re,"/_t_/"+newTerm+"?");
		re2=/q=.*/;
		newURL = newURL.replace(re2,"q="+newTerm);
		
		ageFrom = document.getElementById("age-from");
		re3=/uf=\w+&/;
		txtField = document.getElementById("txtSearch");
		if(!txtField.disabled){
		
			if(!ageFrom.disabled){
				newURL = newURL.replace(re3,"uf=2&");
			}
			else{
				newURL = newURL.replace(re3,"uf=0&");
			}
			
		}
		else
		{
			if(!ageFrom.disabled){
				newURL = newURL.replace(re3,"uf=1&");
			}
		}
		
		
		if(!ageFrom.disabled){
		
			re4=/from=\w+&/;
			newURL = newURL.replace(re4,"from="+ageFrom.value+"&");
			
			re4=/to=\w+&/;
			newURL = newURL.replace(re4,"to="+document.getElementById("age-to").value+"&");
			
			re4=/cnt=[\w\s\,\(\)\+]+&/;
			newURL = newURL.replace(re4,"cnt="+encodeURIComponent(document.getElementById("country-select").value)+"&");
			
			re4=/gen=[\w\s\+]+&/;
			newURL = newURL.replace(re4,"gen="+encodeURIComponent(document.getElementById("gender").value)+"&");
		}
		
		
		document.location = newURL;

	}
	
	
	function onKeyDownNavigateSearchUsers(e)
	{
		
		if (e.keyCode != 13)
		  return;
		  
		navigateSearchUsers();
		
		return false;
		
	}