function view_page_results(id,material,page_nr) {
	if(search_criteria.sword == "Søg i kilder eller leksikon") search_criteria.sword = '';
	if(search_criteria.sword == undefined) search_criteria.sword = '';


    var pointer = 0;
    if(page_nr > 0){
        pointer = page_nr -1;
    }

	var params = {
		"tx_indexedsearch[_charset]"			: "utf8",
		"tx_indexedsearch[type]"			: 1,
		"tx_indexedsearch[defOp]"			: 0,	// require all words
		"tx_indexedsearch[sword]"			: search_criteria.sword,
		"tx_indexedsearch[results]"			: 10,
		"tx_indexedsearch[pointer]"			: pointer
	}

	$("#" + id).load(
		"/index.php?id=913&no_cache=1",
		params,
		function() {
			var show_total_pages = $("#show_total_pages").html();

			if(show_total_pages.length == 0) {
				var total_pages = $("#result_total_pages").html();
				var total_results = $("#show_total_results").html();

				if(total_pages == null) total_pages = 0;
				total_pages = total_pages + " resultater i";
				$("#show_total_pages").html(total_pages);
				$("#show_total_results").html(parseInt(total_results) + parseInt(total_pages));
			}
		}
	);
}

function view_material_results(id,material,page_nr) {
	var params = {
		"tx_historysearch_pi1[ajax]"		: 1,
		search_material						: 1,
		"tx_historysearch_pi1[material]"	: material,
		"tx_historysearch_pi1[page]"		: page_nr,
		"tx_historysearch_pi1[sword]" : search_criteria.sword
	}
	var material_name = "";

	if(material == 1) material_name = "article";
	else material_name = "source";
	var search_material = "tx_historysearch_pi1[search_" + material_name + "s]";
	params[search_material] = 1;

    $("#page_browser_"+id).remove();
	$("#" + id).load("/index.php?id=512&no_cache=1",params);
}

/// view a page of a searchresult.
/// the page is fetched via AJAX
function view_page(id,material,page_nr) {
	$("#" + id).html("<img src=\"/fileadmin/templates/grafik/history/ajax-loader.gif\" width=\"16\" height=\"16\" alt=\"S&oslash;ger...\" />");

	if(material == '_indexed') {
		view_page_results(id,material,page_nr);
	} else {
		view_material_results(id,material,page_nr);
	}
}
