function buildDynamicSearchInputMask(winRef) {
	var d = winRef.document;
	d.write('<table border="0" class="dynamicSearchInputMask" cellpadding="0" cellspacing="0">');
	d.write('<tr>');
	if(searchBelowSelectedTreeEntry != null) 
		d.write('<td valign="middle"><img title="'+belenusHome.ld['s_belowFolder']+'" id="'+belenusHome.addLKey("a88",winRef,"title","s_belowFolder")+'" src="'+belenusHome.getPath('custom/images/treebelow_tt_'+((belenusHome.searchBelowSelectedTreeEntryState == true) ? 'on' : 'off')+'.gif')+'" height="16" width="36" align="absmiddle" vspace="0" hspace="0" border="0" onclick="belenusHome.searchBelowSelectedTreeEntryState=!belenusHome.searchBelowSelectedTreeEntryState;this.src=belenusHome.getPath(\'custom/images/treebelow_tt_\'+((belenusHome.searchBelowSelectedTreeEntryState == true) ? \'on\' : \'off\')+\'.gif\')"></td>');			
	d.write('<td class="dynamicSearchInputDropdown" width="1" valign="bottom">');
	d.write('<select id="SDD" onchange="belenusHome.search_showSearchOption(self,this.options[this.selectedIndex].value)">');
	for(sd in dynamic_searchFields) {
		var label = (belenusHome.ld[dynamic_searchFields[sd][0]]) ? belenusHome.ld[dynamic_searchFields[sd][0]] : dynamic_searchFields[sd][0];
		d.write('<option value="'+dynamic_searchFields[sd][1]+'" id="'+belenusHome.addLKey("a55"+sd+""+Math.random(),winRef,"",dynamic_searchFields[sd][0])+'">'+label+'</option>');
	}
	d.write("</select>");
	d.write('</td>');
	
	d.write('<td class="dynamicSearchInputFields" width="1">');
	for(sd in dynamic_searchFields) {
		var maxLength = (getQueryField(dynamic_searchFields[sd][1], "maxlength")) ? getQueryField(dynamic_searchFields[sd][1], "maxlength") : "40";
		var inputCheck = (getQueryField(dynamic_searchFields[sd][1], "inputCheck")) ? getQueryField(dynamic_searchFields[sd][1], "inputCheck") : "notEmpty";
		d.write('<span id="'+dynamic_searchFields[sd][1]+'" style="display:none"><input type="text" size="15" value="" style="width:110px" inputCheck="'+inputCheck+'"  maxlength="'+maxLength+'" id="'+dynamic_searchFields[sd][1]+'_0"></span>');
	}
	d.write('</td>');
	d.write('<td class="dynamicSearchInputButton" width="1">');
	d.write('<table border="0" cellpadding="0" cellspacing="0"><tr>');
	var standardSearchIMG = 	""
	d.write('<td nowrap class="jag_a">');
	d.write('<a onmouseover="top.status=\''+belenusHome.ld['nav_search']+'\';return true;"'+
	' onmouseout="top.status=\'\';return true;" id="'+belenusHome.addLKey("a56",winRef,"","submitBtn")+'" onclick="belenusHome.search_startSearch(self)" href="javascript://">'+
	belenusHome.ld['submitBtn']+'</a></td>');
	d.write('<td><img src="'+belenusHome.getPath('custom/images/i.gif')+'" width="8"></td>');
	d.write('</tr></table>');
	d.write('</td>');	
	d.write('</tr>');
	d.write('</table>');
}

function dynamicStartSearchUndo(winRef) {
	searchID = (belenusHome.useTabManager) ? searchID+1 : searchID; 
	var treePath = belenusHome.currentTreePath;
	var treeID = treePath.split("/");
	if(treeID.length >= 1 && belenusHome.searchBelowSelectedTreeEntryState == true) {
		if(treeID.length >4) 
			treeID = treeID[4];
		else {
			treeID.reverse();
			treeID = treeID[0];
		}
	} else {
	  treeID = "";
	  treePath = "";
	}

	var searchRequestStr = "resultid="+ searchID +"&restart=true&treeid=" + treeID + "&treepath=" + treePath;
	// set display js libary
	searchRequestStr += "&jsfile=";
	searchRequestStr += (belenusHome.searchDisplayFn != null) ? belenusHome.searchDisplayFn : "js/dyn_search.js";
	// set display css libary
	searchRequestStr += "&cssfile=";
	searchRequestStr += (belenusHome.searchDisplayCSS != null) ? belenusHome.searchDisplayCSS : "custom/searchresult.css";
	
	var value = belenusHome.id(winRef.document,search_currentChoice+"_0").value;
	if(value == "") { 
		winRef.alert(belenusHome.ld['s_uncompleted']);
		search_showSearchOption(winRef,search_currentChoice);
		return;		
	}	
	var cTy = belenusHome.id(winRef.document,search_currentChoice+"_0").getAttribute('inputCheck'); // checkType
	if(!belenusHome.usrInputCheck(winRef,belenusHome.id(winRef.document,search_currentChoice+"_0").getAttribute('inputCheck'),value)) {
		if(cTy == "notEmpty" || cTy == "alphaNum") winRef.alert(belenusHome.ld['s_uncompleted']);
		search_showSearchOption(winRef,search_currentChoice);
		return;
	}
	if(value.indexOf("#")!=-1||value.indexOf("&")!=-1||value.indexOf("=")!=-1||value.indexOf("?")!=-1)
		searchRequestStr += "&parameter0="+escape(value);
	else
		searchRequestStr += "&parameter0="+value;
	var caption = "&tabCaption=";
	var label = "";
	var labelKey = "";
	for(i in dynamic_searchFields) {
		if(dynamic_searchFields[i][1] == search_currentChoice) {
			label = (belenusHome.ld[dynamic_searchFields[i][0]]) ? belenusHome.ld[dynamic_searchFields[i][0]] : escape(dynamic_searchFields[i][0]);
			labelKey = (belenusHome.ld[dynamic_searchFields[i][0]]) ? dynamic_searchFields[i][0] : "";
			break;
		}
	}
	caption += escape("longTabCaption=belenusHome.ld['nav_search']+' ( '+belenusHome.ld[\""+labelKey+"\"]+': "+((value.indexOf("&")!=-1 || value.indexOf("=")!=-1)?escape(value):value)+" )'&shortTabCaption=belenusHome.ld['nav_search']+' ( "+((value.indexOf("&")!=-1 || value.indexOf("=")!=-1)?escape(value):value)+" )'");
	searchRequestStr += caption;
		
	var multipleSearchs = false;
	for(i2 in dynamic_searchFields) {
		if(dynamic_searchFields[i2][1] == search_currentChoice) {
			if(typeof dynamic_searchFields[i2][3] != "undefined" && typeof dynamic_searchFields[i2][3] == "object") {
				multipleSearchs = ""+i2;
				break;
			}
		}
	}
	if(!multipleSearchs) {
		if(belenusHome.useTabManager == false || belenusHome.Windows['searchX'][5] == "") 
			try {
				if(belenusHome.WM.getWindowReference('searchX').closed == false) belenusHome.WM.closeWindow('searchX');	 
			} catch(e) {}
		belenusHome.WM.openWindow('searchX',searchRequestStr+"&"+search_currentChoice,false);		
	} else {
		if(belenusHome.useTabManager) {
			belenusHome.WM.openWindow('searchX',searchRequestStr+"&"+search_currentChoice,false);		
			for(multiSearch in dynamic_searchFields[multipleSearchs][3]) {
				belenusHome.WM.openWindow('searchX',searchRequestStr+"&"+dynamic_searchFields[multipleSearchs][3][multiSearch],false);				
			}
		} else alert("TabManager is inactive, can't start multiple searchs!");
	}
}