var lastItemType = null;
var subTableCountUp = 100;

var maxShownParentLabelsShort = 4; // the number of parents whose labels will be displayed
var maxLengthOfStrShort = 20; // the max size of the string, before it will cut
var shownDotsShort = 3;

var maxShownParentLabelsLong = 5; // the number of parents whose labels will be displayed
var maxLengthOfStrLong = 15; // the max size of the string, before it will cut
var shownDotsLong = 3;

var onlyOneHeader = true;
//++++++++++++++++++++++++++++++

var doc = document;
//auto init search animation
parent.searchHeader.document.open();
parent.searchHeader.document.write('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8">');
belenusHome.includeCSS(parent.searchHeader,"custom/searchresult.css");
//<link type="text/css" rel="stylesheet" href="viewer/custom/searchresult.css">
parent.searchHeader.document.write('</head><body><span id="navDisplay" style="right:0px;top:0px;position:absolute;"><img src="viewer/custom/images/ani_trans.gif" width="62" height="14" border="0" alt="searching..."><img src="viewer/custom/images/i.gif" width="1" height="1"></span></body></html>');
parent.searchHeader.document.close();



function displayEntry(definition, entry) {

	var d = definition;
	var e = entry;

	var createSubTable = false;

	var visibleFieldSufix = "field_";
	var invisibleFieldSufix = "extra_";
	var twoStepSearchFieldSufix = "link_";

	var hasOrderColumn = false; // by default set to false
	for(defs in d.resultNames) if(d.resultNames[defs]=="extra_orderable") { hasOrderColumn=true;break; } //activate orderable column, if the entry exists in the definition

	if(lastItemType != d.name) {
		lastItemType = d.name;
		// and also paint new table header...
		var headerData = "";
		headerData += '<table border="0" cellpadding="0" cellspacing="0"><tr><td>';
		headerData += '<table border="0" cellpadding="0" cellspacing="0" class="table_header_'+belenusHome.cssMapping[d.name]+'">';
		headerData += '<td class="td_'+belenusHome.cssMapping[d.name]+'_jump"><span class="td_'+belenusHome.cssMapping[d.name]+'_jump">&nbsp;</span></td>';
		if(hasOrderColumn) {
			if(belenusHome.shoppingEnabled == true) headerData += '<td class="td_'+belenusHome.cssMapping[d.name]+'_orderable"><span class="td_'+belenusHome.cssMapping[d.name]+'_orderable"><img src="viewer/custom/images/carticon.gif"></span></td>';
			else headerData += '<td class="td_'+belenusHome.cssMapping[d.name]+'_orderable"><span class="td_'+belenusHome.cssMapping[d.name]+'_orderable">&nbsp;</span></td>';
		}
		for(i in d.resultNames) {
			var currentFieldName = d.resultNames[i];
			if(currentFieldName.indexOf(visibleFieldSufix) != -1) {
				var fieldPostfix = currentFieldName.substring(visibleFieldSufix.length,currentFieldName.length);
				headerData+='<td class="td_'+belenusHome.cssMapping[d.name]+'_'+fieldPostfix+'">';
				headerData+='<span class="td_'+belenusHome.cssMapping[d.name]+'_'+fieldPostfix+'" ';
				var tmpTitle = "";
				var setBy = "server"; // server | client
				if(typeof d.tabledefResultNames != "undefined" && typeof d.tabledefResultNames[i] != "undefined") tmpTitle = d.tabledefResultNames[i];
				else if(typeof belenusHome.ld['searchResult_'+fieldPostfix] != "undefined") { tmpTitle = belenusHome.ld['searchResult_'+fieldPostfix]; setBy = "client"; }
				else tmpTitle = fieldPostfix;
				if(tmpTitle!=fieldPostfix) {
					tmpTitle = tmpTitle.indexOf('<') == 0 ? '' : tmpTitle;
					var idX = (setBy=="server" || tmpTitle=="") ? "" : ' id="'+belenusHome.addLKey("x"+Math.random(),(onlyOneHeader == false)? self : parent.searchHeader,"objId,title",'searchResult_'+fieldPostfix)+'"';
					if(setBy=="server")headerData+='><nobr title="'+tmpTitle+'">'+d.tabledefResultNames[i]+'&nbsp;</nobr></span></td>';
					else headerData+='><nobr'+idX+' title="'+tmpTitle+'">'+belenusHome.ld['searchResult_'+fieldPostfix]+'&nbsp;</nobr></span></td>';
				} else {
					headerData+='><nobr title="'+fieldPostfix+'">'+fieldPostfix+'&nbsp;</nobr></span></td>';
				}
			}
		}
		if(definition.pathNames.length > 0) {
			headerData +='<td class="td_'+belenusHome.cssMapping[d.name]+'_itempath"><span class="td_'+belenusHome.cssMapping[d.name]+'_itempath"><nobr id="'+belenusHome.addLKey("x"+Math.random(),(onlyOneHeader == false)? self : parent.searchHeader,"objId,title","searchResult_itempath")+'">'+belenusHome.ld['searchResult_itempath']+'&nbsp;</nobr></span></td>';
		}
		headerData +='</table></td><td style="width:20px"><img src="viewer/custom/images/i.gif" width="20" height="1"></td></tr></table>';

		if(!onlyOneHeader) doc.write(headerData);
		else {
			parent.searchHeader.document.open();
			parent.searchHeader.document.write('<html><head>');
			belenusHome.includeCSS(parent.searchHeader,"custom/searchresult.css");
//			parent.searchHeader.document.write('</head><body>'+headerData+'<span id="navDisplay" style="width:100%;text-align:right;right:0px;top:0px;position:absolute;"><img src="viewer/custom/images/ani_trans.gif" width="62" height="14" border="0" alt="searching..."><img src="viewer/custom/images/i.gif" width="1" height="1"></span></body></html>');
			parent.searchHeader.document.write('</head><body>'+headerData+'<span id="navDisplay" style=""><img src="viewer/custom/images/ani_trans.gif" width="62" height="14" border="0" alt="searching..."><img src="viewer/custom/images/i.gif" width="1" height="1"></span></body></html>');
			parent.searchHeader.document.close();
		}
	}

	doc.write('<table border="0" cellpadding="0" cellspacing="0" class="table_'+belenusHome.cssMapping[d.name]+'">');
		var hovered = belenusHome.getCSSProperty(document, ".linkedHover", "backgroundColor");
		var unHovered = belenusHome.getCSSProperty(document, ".linkedUnHover", "backgroundColor");

		// find a posibile 2StepSearchParam
		var twoStepParam0 = null;
		var twoStepParam1 = null;
		for(tsp in d.resultNames) {
			var tmpF = d.resultNames[tsp];
			if(tmpF.indexOf(twoStepSearchFieldSufix+"search") == 0) twoStepParam1 = e.resultFields[tsp];
			if(tmpF.indexOf(twoStepSearchFieldSufix+"parameter0") == 0) twoStepParam0 = e.resultFields[tsp];
		}
		/////////////////////////////////////////

		if(twoStepParam0 != null && twoStepParam1 != null) {
//			doc.write('<tr class="linkedRow" onmouseover="this.style.backgroundColor=\''+hovered+'\';this.style.cursor=\'hand\'" onmouseout="this.style.backgroundColor=\''+unHovered+'\'"'+
//					'onclick="self.location.href=\'server?command=search&resultid='+belenusHome.getQueryField(location.href,"resultid") + "_link" + '&restart=true'
//					+'&query='+twoStepParam1+'&parameter0='+twoStepParam0+'&jsfile='+belenusHome.getQueryField(location.href,"jsfile")+'&cssfile='+belenusHome.getQueryField(location.href,"cssfile")+'&backjump='+escape(currentResults)+'\'">');

			doc.write('<tr class="linkedRow" onmouseover="this.style.backgroundColor=\''+hovered+'\';this.style.cursor=\'hand\'" onmouseout="this.style.backgroundColor=\''+unHovered+'\'">');

		//} else if(e.path && e.path[0] != "" && e.path.length > 0 && e.path.length < 2) doc.write('<tr class="linkedRow" onmouseover="this.style.backgroundColor=\''+hovered+'\';this.style.cursor=\'hand\'" onmouseout="this.style.backgroundColor=\''+unHovered+'\'" onclick="if(belenusHome.autoTabMinimize) belenusHome.minimizeTab();belenusHome.eventHandler(\'OpenLink\',\'URL=parts:'+e.path[0]+'\');">');
		} else if(e.path && e.path[0] != "" && e.path.length > 0 && e.path.length < 2) doc.write('<tr class="linkedRow" onmouseover="this.style.backgroundColor=\''+hovered+'\';this.style.cursor=\'hand\'" onmouseout="this.style.backgroundColor=\''+unHovered+'\'">');
		else doc.write('<tr>');

		doc.write('<td class="td_'+belenusHome.cssMapping[d.name]+'_jump"><span class="td_'+belenusHome.cssMapping[d.name]+'_jump"><img onclick="if(belenusHome.autoTabMinimize) belenusHome.minimizeTab();belenusHome.eventHandler(\'OpenLink\',\'URL=parts:'+e.path[0]+'\');" src="viewer/custom/images/jump.gif"></span></td>');

		if(hasOrderColumn) {
			// paint basketIconField
			// scanning the result array for the orderable field...
			var orderStr = "a=b&Sender=SearchResult&";
			orderStr += "treepath="+ e.path[0] + "&"
			var orderable = null;
			for(j in d.resultNames) {
				var currentFieldName = d.resultNames[j];
				if(d.resultNames[j].indexOf(visibleFieldSufix) == 0) {
					orderStr += currentFieldName.substring(visibleFieldSufix.length,currentFieldName.length) + "=" + escape(e.resultFields[j]) + "&"
				} else if(d.resultNames[j].indexOf(invisibleFieldSufix) == 0) {
					orderStr += currentFieldName.substring(invisibleFieldSufix.length,currentFieldName.length) + "=" + escape(e.resultFields[j]) + "&"
				}

				if(d.resultNames[j] == invisibleFieldSufix+"orderable") {
					if(e.resultFields[j] == "true") orderable = true;
					else { orderable = false; }
				}
			}
			if(belenusHome.shoppingEnabled == false) orderable = false;

			if(orderable) {
				orderStr = "AddBy=PartData&PartData="+escape(orderStr);
				doc.write('<td class="td_'+belenusHome.cssMapping[d.name]+'_orderable"><span class="td_'+belenusHome.cssMapping[d.name]+'_orderable"><img onclick="belenusHome.eventHandler(\'AddToBasket\',\''+orderStr+'\');" src="viewer/custom/images/carticon.gif" style="cursor:hand"></span></td>');
			} else {
				doc.write('<td class="td_'+belenusHome.cssMapping[d.name]+'_orderable"><span class="td_'+belenusHome.cssMapping[d.name]+'_orderable">&nbsp;</span></td>');
			}
		}

		var results = "";
		for(i in d.resultNames) {
			var currentFieldName = d.resultNames[i];
			if(currentFieldName.indexOf(visibleFieldSufix) != -1) {
                var resultField = e.resultFields[i];
				var field = resultField.replace(/\r\n/, '\n').replace(/\r/, '\n');
				var fieldText = field.replace(/\n/, '<br>');
				var fieldPopup = belenusHome.browserName=="Internet Explorer" ? field : field.replace(/\n/, ' ');
				if(twoStepParam0 != null && twoStepParam1 != null) {
					results+= '<td title="'+fieldPopup+'"'+
					' onclick=\"self.location.href=\'server?command=search&resultid='+belenusHome.getQueryField(location.href,"resultid") + "_link" + '&restart=true'
					+'&query='+twoStepParam1+'&parameter0='+encodeURIComponent(twoStepParam0)+'&jsfile='+belenusHome.getQueryField(location.href,"jsfile")+'&cssfile='+belenusHome.getQueryField(location.href,"cssfile")+'&backjump='+escape(currentResults)+'\'\" '+
					'class="td_'+belenusHome.cssMapping[d.name]+'_'+currentFieldName.substring(visibleFieldSufix.length,currentFieldName.length)+'"><nobr>'+fieldText+'&nbsp;</nobr></td>';
				} else if(e.path && e.path[0] != "" && e.path.length > 0 && e.path.length < 2) {
					results+= '<td title="'+fieldPopup+'" class="td_'+belenusHome.cssMapping[d.name]+'_'+currentFieldName.substring(visibleFieldSufix.length,currentFieldName.length)+'" onclick="if(belenusHome.autoTabMinimize) belenusHome.minimizeTab();belenusHome.eventHandler(\'OpenLink\',\'URL=parts:'+e.path[0]+'\');"><nobr>'+fieldText+'&nbsp;</nobr></td>';
				} else {
					results+= '<td title="'+fieldPopup+'" class="td_'+belenusHome.cssMapping[d.name]+'_'+currentFieldName.substring(visibleFieldSufix.length,currentFieldName.length)+'"><nobr>'+fieldText+'&nbsp;</nobr></td>';
				}
			}
		}

		if(definition.pathNames.length > 0) { // check if any treepath is given
			if(e.path.length > 0) {
				if(e.path.length > 1) { // handle multi treepaths
					createSubTable = true;
					results += '<td class="td_'+belenusHome.cssMapping[d.name]+'_itempath" nowrap style="white-space:nowrap"><nobr>'
					+'<span id="plus'+subTableCountUp+'"><img align="absmiddle" src="viewer/custom/images/plusicon.gif" onclick="openSubTable4('+subTableCountUp+')"></span>'
					+'<span id="minus'+subTableCountUp+'" style="display:none"><img align="absmiddle" src="viewer/custom/images/minusicon.gif" onclick="closeSubTable4('+subTableCountUp+')"></span>'
					+' Exists '+e.path.length+' Pathes</nobr></td>';
				} else { // handle single treepath
					//results += '<td class="td_'+belenusHome.cssMapping[d.name]+'_itempath"><nobr><span class="td_'+belenusHome.cssMapping[d.name]+'_itempath"><a onmouseover="status=\'\';return true;" href="javascript:belenusHome.eventHandler(\'OpenLink\',\'URL=parts:'+e.path[0]+'\');" title="'+e.pathFields[0][0].join(" / ")+'">'+buildHumanReadablePath(e.pathFields[0][0].join("/"),shownDotsShort,maxLengthOfStrShort,maxShownParentLabelsShort)+'</a></nobr></span></td>';
					results += '<td onclick="if(belenusHome.autoTabMinimize) belenusHome.minimizeTab();belenusHome.eventHandler(\'OpenLink\',\'URL=parts:'+e.path[0]+'\');" class="td_'+belenusHome.cssMapping[d.name]+'_itempath"><nobr><span class="td_'+belenusHome.cssMapping[d.name]+'_itempath" title="'+buildHumanReadablePath(e.pathFields[0][0],shownDotsShort,maxLengthOfStrShort,maxShownParentLabelsShort)+'">'+buildHumanReadablePath(e.pathFields[0][0],shownDotsShort,maxLengthOfStrShort,maxShownParentLabelsShort)+'</nobr></span></td>';
				}
			} else {
				results += '<td class="td_'+belenusHome.cssMapping[d.name]+'_itempath">&nbsp;</td>';
			}
		}
		doc.write(results);
		doc.write('</tr>');

	doc.write('</table>');

	doc.write('<table border="0" cellpadding="0" cellspacing="0" id="subTable_'+subTableCountUp++ +'" class="table_'+belenusHome.cssMapping[d.name]+'_sub" style="display:none">');
	for(s in e.path) {
		doc.write('<tr>');
		//doc.write('<td class="table_'+belenusHome.cssMapping[d.name]+'_itempaths"><nobr><span style="width:22px;height:1px"></span><a onmouseover="status=\'\';return true;" href="javascript:belenusHome.eventHandler(\'OpenLink\',\'URL=parts:'+e.path[s]+'\');" title="'+e.pathFields[s][0].join(" / ")+'">'+buildHumanReadablePath(e.pathFields[s][0].join("/"),shownDotsLong,maxLengthOfStrLong,maxShownParentLabelsLong)+'</a></nobr></td>');
		doc.write('<td class="table_'+belenusHome.cssMapping[d.name]+'_itempaths"><nobr><span style="width:22px;height:1px"></span>'+buildHumanReadablePath(e.pathFields[s][0],shownDotsLong,maxLengthOfStrLong,maxShownParentLabelsLong)+'</nobr></td>');
		doc.write('</tr>');
	}
	doc.write('</table>');

}

function csvExportLink() {
	var csvExportLink = "server";
	var xy = parent.searchBody.location.search.split("command=search");
	csvExportLink += xy[0]+"command=searchcsv&";
	if(xy.length>1)	csvExportLink+=xy[1];
	return csvExportLink;
}

var difNavs = new Array();
var displayCountCache = new Array(null,null,null);
var currentResults = "";


function displayCount(pageIndex, pageCount, continuesAfterLast) {
	displayCountCache[0] = pageIndex;
	displayCountCache[1] = pageCount;
	displayCountCache[2] = continuesAfterLast;
}

function displayNavigation(drive, link) {
	if(drive == "currentResults") {
	  currentResults = link;
	} else {
		difNavs[difNavs.length] = new Array(drive, link);
	}
}


function showNavigation() {

  resultNotFound = false;
  backjump = null;
	for(n in difNavs) {
		if(difNavs[n][0] == "resultNotFound") {
		  resultNotFound = true;
		}
		if(difNavs[n][0] == "backjump") {
		  backjump = difNavs[0][1];
		}
	}
  if(resultNotFound) {
		//doc.write(belenusHome.ld["resultNotFound"]);
		var noResultContent  = '';
		noResultContent += '<table border="0" cellpadding="0" cellspacing="0" width="100%" height="95%" class="noResultContent">';
		if(backjump != null) {
			noResultContent += '<tr valign="top"><td>&nbsp;<a href="javascript:parent.searchBody.leavePageFlag=false;parent.searchBody.load(\''+backjump+'\')" ';
			noResultContent += 'onmouseover="belenusHome.status=\''+belenusHome.ld['backForm']+'\';return true;" ';
			noResultContent += 'onmouseout="belenusHome.status=\'\'" ';
			noResultContent += '>';
			noResultContent += '<img src="viewer/custom/images/i.gif" border="0" height="20" width="2" align="absmiddle"><img src="viewer/custom/images/green_back.gif" align="absmiddle" border="0">';
			noResultContent += '<span id="'+belenusHome.addLKey("x01"+Math.random(),self,"objId,title",'backForm')+'" class="normalTxt">'+belenusHome.ld['backForm']+'</span></a></td></tr>';
		}
		noResultContent += '<tr><td width="100%" align="center" valign="middle"><span class="normalTxt" id="'+belenusHome.addLKey("x02"+Math.random(),self,"objId,title",'resultNotFound')+'">'+belenusHome.ld['resultNotFound']+'</span></td></tr><table>';
		document.getElementById('navDisplay2').innerHTML = noResultContent;
		if(onlyOneHeader) {
		  displayBackjump = backjump == null ? "" : "&nbsp;<a href=\"javascript:parent.searchBody.leavePageFlag=false;parent.searchBody.load('" +  backjump + "')\" "+
		  "onmouseover=\"parent.belenusHome.status='"+belenusHome.ld['backForm']+"';return true;\" "+
		  "onmouseout=\"parent.belenusHome.status='';return true;\" "+
		  "title=\""+belenusHome.ld['backForm']+"\" id=\""+belenusHome.addLKey("x03"+Math.random(),parent.searchHeader,"objId,title",'backForm')+"\"><img border=\"0\" src=\"viewer/custom/images/custom_btn.gif\" " +
		    " align=\"absmiddle\"></a>";

		  parent.searchHeader.document.getElementById('navDisplay').innerHTML = displayBackjump;
		    //"<small id=\""+belenusHome.addLKey("x04"+Math.random(),parent.searchHeader,"title",'resultNotFound')+"\"> displayBackjump + "</small>";
		    //"<small id=\""+belenusHome.addLKey("x04"+Math.random(),parent.searchHeader,"objId,title",'resultNotFound')+"\">&nbsp;" + belenusHome.ld["resultNotFound"] + displayBackjump + "</small>";

		}
		//if(parent.belenusHome.useTabManager) setTimeout('belenusHome.TAM.closeTab(belenusHome.activeTab,belenusHome.wObjOfTab);',3500);
		return;
  }


	var navData2 = "";
	if(displayCountCache[0] != null && displayCountCache[1] != null && displayCountCache[2] != null && displayCountCache[1] > 1) {
		var continuesAfterLast = (displayCountCache[2] == true) ? "..." : ""; // before it was [? ",..." : "";]
		navData2 += '<span style="margin:0px;padding:0px;"><span class="dynamicSearchResultCountDisplay" id="countDisplay" style="vertical-align:top">&nbsp;'+displayCountCache[0]+'/'+displayCountCache[1]+continuesAfterLast+'&nbsp;</span>';
	}
	navData2 += '<a id="a_custom_btn" onmouseover="top.status=\'\';return true" style="visibility:hidden"><img src="viewer/custom/images/custom_btn.gif" border="0" title="'+belenusHome.ld['backForm']+'" ';
	navData2 += 'id="'+belenusHome.addLKey("custom_btn",(onlyOneHeader == false)? self : parent.searchHeader,"title",'backForm')+'"></a>';
	navData2 += '<a id="a_back" onmouseover="top.status=\'\';return true" ><img src="viewer/custom/images/back_dis.gif" border="0" id="back"></a>';
//	navData2 += '<img src="viewer/custom/images/i.gif" border="0" height="1" width="5" id="space" align="top">';
	navData2 += '<a id="a_next" onmouseover="top.status=\'\';return true" style="margin-left:5px;"><img src="viewer/custom/images/forward_dis.gif" border="0" id="next"></a>';
	if(typeof belenusHome.csvExportActive != "undefined" && belenusHome.csvExportActive == true)
		navData2 += '<img src="viewer/custom/images/csv_save.gif" valign="top" border="0" onclick="parent.belenusHome.frames.mrhidden.location.href=\''+csvExportLink()+'\'" title="'+belenusHome.ld['export']+'" id="'+belenusHome.addLKey('csv_export_btn',parent.searchHeader,"title",'export')+'" style="margin-left:2px;cursor:hand;margin-right:1px;">';
	navData2 += '</span>';



	if(!onlyOneHeader) {
		document.getElementById('navDisplay2').innerHTML = navData2;
		parent.searchHeader.document.getElementById('navDisplay').style.display = "none";
	} else {
		parent.searchHeader.document.getElementById('navDisplay').innerHTML = navData2;
		document.getElementById('navDisplay2').style.display="none";
	}


	for(nn in difNavs) {
		if(difNavs[nn][0] == "nextResults" && difNavs[nn][1] != null) {
			if(!onlyOneHeader) { // header and body are in the same window
				document.getElementById('next').setAttribute("src","viewer/custom/images/forward.gif");
				document.getElementById('a_next').setAttribute("title", belenusHome.ld['nextResults']);
				document.getElementById('a_next').setAttribute("href","javascript:leavePageFlag=false;load('"+escape(difNavs[nn][1])+"')");
			} else { // header and body are in separated windows
				parent.searchHeader.document.getElementById('next').setAttribute("src","viewer/custom/images/forward.gif");
				parent.searchHeader.document.getElementById('a_next').setAttribute("title", belenusHome.ld['nextResults']);
				parent.searchHeader.document.getElementById('a_next').setAttribute("href","javascript:parent.searchBody.leavePageFlag=false;parent.searchBody.load('"+escape(difNavs[nn][1])+"')");
			}
			void(belenusHome.addLKey("a_next",(onlyOneHeader == false)? self : parent.searchHeader,"title",'nextResults'));
		}

		if(difNavs[nn][0] == "previousResults" && difNavs[nn][1] != null) {
			if(!onlyOneHeader) { // header and body are in the same window
				document.getElementById('back').setAttribute("src","viewer/custom/images/back.gif");
				document.getElementById('a_back').setAttribute("title", belenusHome.ld['previousResults']);
				document.getElementById('a_back').setAttribute("href","javascript:leavePageFlag=false;load('"+escape(difNavs[nn][1])+"')");
			} else { // header and body are in separated windows
				parent.searchHeader.document.getElementById('back').setAttribute("src","viewer/custom/images/back.gif");
				parent.searchHeader.document.getElementById('a_back').setAttribute("title", belenusHome.ld['previousResults']);
				parent.searchHeader.document.getElementById('a_back').setAttribute("href","javascript:parent.searchBody.leavePageFlag=false;parent.searchBody.load('"+escape(difNavs[nn][1])+"')");
			}
			void(belenusHome.addLKey("a_back",(onlyOneHeader == false)? self : parent.searchHeader,"title",'previousResults'));
		}

		if(difNavs[nn][0] == "backjump" && difNavs[nn][1] != null) {
			if(!onlyOneHeader) { // header and body are in the same window
				document.getElementById('custom_btn').style.visibility = "visible";
				document.getElementById('a_custom_btn').setAttribute("href","javascript:leavePageFlag=true;load('"+escape(difNavs[nn][1])+"')");
			} else { // header and body are in separated windows
				parent.searchHeader.document.getElementById('custom_btn').style.visibility= "visible";
				parent.searchHeader.document.getElementById('a_custom_btn').setAttribute("href","javascript:parent.searchBody.leavePageFlag=false;parent.searchBody.load('"+escape(difNavs[nn][1])+"')");
			}
		}

	}


}
var leavePageFlag = "reset";
function leavePage() {
	if(leavePageFlag == "reset") { // do... server?command=search&restart=true

	}
}

function load(url) { self.location.href=url }

function buildHumanReadablePath(labels, shownDots, maxLengthOfStr, maxShownParentLabels) {
	var label = "";
//	if(labels.length > 0) {
//		labels = labels.split("/");
//	}
	for(var i = maxShownParentLabels, j = labels.length; i > 0 && j >= 1; i--, j--) {
		if(labels[(j-1)]) {
			var tmpL = labels[(j-1)];
	        if(tmpL.length > maxLengthOfStr && j != labels.length ) {
	            tmpL = tmpL.substring(0, (maxLengthOfStr-shownDots));
	            for(var d = 0; d < shownDots; d++) {
	              tmpL += ".";
	            }
	        }
		}
		//if(j == 1 && belenusHome.displayRoot == false) label+=""; // wird nicht ben?tigt in der dyn Suche, da der Root-Knoten nie mitgegeben wird
		if(false) label+="";
		else if(label == "") label = tmpL;
		else label = tmpL + " / " + label;
	}
	return label;

	var returningString = "";
	returningString += '<a href="javascript:belenusHome.eventHandler(\'OpenLink\',\'URL=parts:'+treepath+'\');" title="'+labels+'">short label</a>';
	return returningString;
}

function openSubTable4(IDNum) {
	document.getElementById('minus'+IDNum).style.display = "inline";
	document.getElementById('plus'+IDNum).style.display = "none";
	document.getElementById('subTable_'+IDNum).style.display = "block";
}

function closeSubTable4(IDNum) {
	document.getElementById('minus'+IDNum).style.display = "none";
	document.getElementById('plus'+IDNum).style.display = "inline";
	document.getElementById('subTable_'+IDNum).style.display = "none";
}

var x=false;
function X() {
	try {
		parent.searchHeader.document.getElementById("navDisplay").style.right = "0px";
		if(x)
		parent.searchHeader.document.getElementById("navDisplay").style.width = "200px";
		else
		parent.searchHeader.document.getElementById("navDisplay").style.width = "201px";
		x = !x;
	} catch(e) {}
}
//setInterval("X()",125);