// sets or replaces page url-parameter
function replace_page(){

	var page_reg_exp = /\bpage=[0-9]*\b/gi;
	var new_page_string = 'page=' + document.getElementById('goToPage').value;

	if(location.href.match(page_reg_exp)){	
		location.replace(location.href.replace(page_reg_exp,new_page_string)  );
	}else{
		location.replace(location.href+"&"+new_page_string);
	}
}

function replace_number_entries(){

	var entries_reg_exp = /\bnum_entries=[0-9]*\b/gi;
	var new_entries_string = 'num_entries=' + document.getElementById('num_entries').value;

	if(location.href.match(entries_reg_exp)){	
		location.replace(location.href.replace(entries_reg_exp,new_entries_string)  );
	}else{
		location.replace(location.href+"&"+new_entries_string);
	}
}

function replace_sorting(field){

	var sort_reg_exp = /\bsort={1}[a-zA-Z0-9_.]*&{0}\b/gi;
	var new_sort_string = 'sort=' + field;
	
	if(location.href.match(sort_reg_exp)){
		location.replace(location.href.replace(sort_reg_exp,new_sort_string)  );
	}else{
		location.replace(location.href+"&"+new_sort_string);
	}

}

