function ReplaceQueryParam( url, p, v ) {
	url = RemoveQueryParam( url, p );
	url = AddQueryParam( url, p, v );
	return url;
}

function AddQueryParam( url, p, v ) {
	if( url.indexOf('?')>=0 ) {
		url = url+'&';
	} else {
		url = url+'?';
	}
	url=url+p+'='+v;
	return url;
}

function RemoveQueryParam( url, p ) {
	// Removes only one Param of this that Name yet!
	pos1 = url.indexOf(p+'=');
	if( pos1>0 ) {
		pos2 = url.indexOf('&',pos1);
		if( pos2<0 ) {
			url=url.substring(0,pos1);
		} else {
			url=url.substring(0,pos1)+url.substring(pos2+1,url.length);
		}
      var lastChar=url.substring(url.length-1,url.length);
		if(lastChar=='&' || lastChar=='?'){
			url=url.substring(0,url.length-1);
		}
		if( url.indexOf('?')>=0 && url.indexOf('=')<0 ) {
			url=url.substring(0,url.length-1);
		}
	}
	return url;
}
function ReadQueryParam( url, p ) {
	// Removes only one Param of this that Name yet!
	var pos1 = url.indexOf(p+'=');
	if(pos1<0) return '';
	var pos2 = url.indexOf('&',pos1);
	if(pos2<0) return url.substring(pos1+p.length+1);
   return url.substring(pos1+p.length+1,pos2);
}

function submitSearch(param,pagenr){
   if(document.SEARCH){
      document.SEARCH.action=ReplaceQueryParam(document.SEARCH.action,param,pagenr);
      document.SEARCH.submit();
   }else{
      location.href = ReplaceQueryParam(location.href,param,pagenr);
   }
}
