
// ------------------------------------- Textsuche ---------------------------------------- //
var navSearch;
function dgsearchText(){
		if(typeof navSearch === "undefined"){
			navSearch = new dgSearch('navSearch');
			initNavSearch(navSearch);
		}
	var text = document.getElementById('navInput2Text').value;
	localStorage.setItem(searchSession, text);	
	highlight();
	$("#searchList").html('');
		if (text.length > 0) {
		var res = navSearch.find(text, false);
		var lis = new Array();
		if(res.length<1){
			$('#searchList').append("No results found");
		}
		for(var i =0; i <= res.length;i++){
			var page = navSearch.pages[res[i]];
			if(typeof page != 'undefined'){
				var li = document.createElement('li');
				var a = document.createElement('a');
				a.setAttribute('data-ajax','false');
				a.setAttribute('rel','external');
				a.setAttribute('href',page[1]);
				a.innerHTML=page[0];
				li.appendChild(a);
				lis.push(li);
				$('#searchList').append(li);	
			}
		}
		
		localStorage.setItem(searchResultSession, $('#searchList').html());	
	}
}

function highlight(){
		var term = localStorage.getItem(searchSession)+" ";
		if(term!==" ")
			highlightSearch(term);
	}

// ------------------------------------- Indexsuche ---------------------------------------- //
var navIndex;
function dgsearchIndex(){
	if(typeof navIndex === "undefined"){
		navIndex = new dgIndex('navSearch');
		initNavIndex(navIndex);
	}
	var text = document.getElementById('navInput1Text').value;
	$("#searchListIndex").html('')
		if (text.length > 0) {
		searchIndex(text);
	}
}

// Führt die Indexsuche durch
function searchIndex(text) {
    if (text.length > 0) {
        var entry = navIndex.entryForName(text, true, true, true);
        if (entry != null) {
            navIndex.sel(entry.idx);
        }
    }
}