function FFSuggest(){var pRequest;var pLayer;var pDebug=false;var pInstanceName="";var pSearchURL="";var pQueryInput;var pSuggest;var pLastQuery;var pCurrentSelection=0;var pCellSpacing=0;var pHighlightBgColor="#D1DBF1";var pHighlightTextColor="#303030";var pStandardBgColor="#FFFFFF";var pStandardTextColor="#000000";var pSuggestQueryStyle="font-weight: bold; padding: 2 15 2 8px;";var pSuggestTypeStyle="padding: 2 5 2 8px;";var pmSh="";var pLayerName="ajaxresultate";var pFormname="Suchbegrifflinks";var pQueryParamName="query";this.init=function(searchURL,formname,queryParamName,divLayername,instanceName,debugMode,Texthead){pSearchURL=searchURL;pFormname="Suchbegrifflinks";pQueryParamName=queryParamName;pLayerName="ajaxresultate";pInstanceName=instanceName;pDebug=debugMode;pTexthead=Texthead;if(pSearchURL==""){if(pDebug){alert("no searchurl defined")}return null}else{if(pInstanceName==""){if(pDebug){alert("no instancename defined")}return null}else{if(pFormname==""){if(pDebug){alert("no formname defined")}return null}else{if(pQueryParamName==""){if(pDebug){alert("no queryparamname defined")}return null}else{if(pLayerName==""){if(pDebug){alert("need a layer for output")}}}}}}pQueryInput=document[pFormname][pQueryParamName];pQueryInput.onkeyup=handleKeyPress;pQueryInput.onfocus=showLayer;pQueryInput.onblur=hideLayer;document[pFormname].onsubmit=handleSubmit};this.setHighlightColors=function(highlighBackgroundColor,highlighTextColor){pHighlightBgColor=highlighBackgroundColor;pHighlightTextColor=highlighTextColor};this.setStandardColors=function(standardBackgroundColor,standardTextColor){pStandardBgColor=standardBackgroundColor;pStandardTextColor=standardTextColor};this.setCellspacing=function(cellspacing){pCellSpacing=cellspacing};function handleSubmit(){if(pSuggest){if(pSuggest[pCurrentSelection]!=undefined){document[pFormname][pQueryParamName].value=pSuggest[pCurrentSelection].split("###")[0];return self.suche_alarm_links()}else{return suche_alarm_links()}}else{return suche_alarm_links()}}this.handleClick=function(){var pCurrentSelection_hier=pCurrentSelection+1;var WRITE=document.getElementById("pufferausgabe"+pCurrentSelection_hier);Inhalt=WRITE.firstChild.nodeValue;document[pFormname][pQueryParamName].value=Inhalt;return self.suche_alarm_links()};this.handleMouseOver=function(pos){var tblCell=getTableCell(pos);unmarkAll();if(tblCell!=null){highlightSuggest(tblCell);pCurrentSelection=pos}};this.handleMouseOut=function(pos){var tblCell=getTableCell(pos);if(tblCell!=null){unmarkSuggest(tblCell);pCurrentSelection=-1}};function handleKeyPress(evt){evt=(evt)?evt:((event)?event:null);var keyCode=evt.keyCode;if(keyCode==38){moveSelection("up")}else{if(keyCode==40){moveSelection("down")}else{if(pQueryInput.value==""){hideLayer();if(pLayer!=null){pLayer.innerHTML=""}return null}tmpqu=0;var tmpqu=pQueryInput.value.length;if(tmpqu>1){if(pLastQuery!=pQueryInput.value){startAjax()}}else{pLayer=self.document.getElementById(pLayerName);if(pLayer!=null){pLayer.innerHTML=""}return null}pLastQuery=pQueryInput.value}}}function moveSelection(direction){var pos=pCurrentSelection;if(direction=="up"){pos--}else{pos+=1}if(pos<0){unmarkAll();pQueryInput.focus();pCurrentSelection=-1}else{var tblCell=getTableCell(pos);if(tblCell!=null){unmarkAll();highlightSuggest(tblCell);pCurrentSelection=pos}}var query=pQueryInput.value;pQueryInput.value="";pQueryInput.focus();pQueryInput.value=query}function startAjax(){var query=pQueryInput.value;var requestURL=pSearchURL+"?"+pQueryParamName+"="+query+"&ajax=1";try{if(window.XMLHttpRequest){pRequest=new XMLHttpRequest()}else{if(window.ActiveXObject){pRequest=new ActiveXObject("Microsoft.XMLHTTP")}else{if(pDebug){alert("")}}}pLayer=document.getElementById(pLayerName);if(pLayer!=null){if(query!=""){pRequest.open("GET",requestURL,true);pRequest.onreadystatechange=callbackAjax;pRequest.send(null)}else{hideLayer()}}else{if(pDebug){alert("no layer for output found")}}}catch(ex){hideLayer();if(ex==undefined){if(pDebug){alert("Error: "+ex.getmessage)}}else{if(pDebug){alert("Error: "+ex)}}}}function hideLayer(){if(pLayer!=null){pLayer.style.display="none"}}this.hideLayerOutsideCall=function(){if(pLayer!=null){pLayer.style.display="none"}};function showLayer(){if(pLayer!=null&&pSuggest!=null&&pSuggest.length>=1){pLayer.style.display="block"}}function callbackAjax(){if(pRequest.readyState==4){if(pRequest.status!=200){hideLayer();if(pDebug){alert("Error ("+pRequest.status+"): "+pRequest.statusText)}}else{handleResponse(pRequest.responseText)}}}function handleResponse(text){pCurrentSelection=-1;pSuggest=new Array();pSuggest=text.split("\n");var outputText='<table cellpadding="0" cellspacing="0" class="livesuche" border="0" onMouseDown="'+pInstanceName+'.handleClick();">';outputText+='<tr height=18><td nowrap="nowrap" colspan="2" class="livesuche_header"> '+Texthead+"<td></tr>";var pNewSuggest=new Array();for(var i in pSuggest){var firstChar=pSuggest[i].charCodeAt(0);if(firstChar!=13&&firstChar!=10&&pSuggest[i].length>=1){pNewSuggest.push(pSuggest[i]);var WRITE=self.document.getElementById("pufferausgabe"+i);WRITE.firstChild.nodeValue=pSuggest[i].split("###")[0]}}pSuggest=pNewSuggest;for(var i in pSuggest){pSuggestParts=new Array();pSuggestParts=pSuggest[i].split("###");var query=pQueryInput.value;outputText+='<tr  id="'+pLayerName+"_"+i+'" style="background-color: '+pStandardBgColor+'; padding: 2 2 2 0px;cursor:pointer;" onMouseOver="'+pInstanceName+".handleMouseOver("+i+');" onMouseOut="'+pInstanceName+".handleMouseOut("+i+');"><td nowrap="nowrap" style="'+pSuggestQueryStyle+';">'+pSuggestParts[0]+'</td><td nowrap="nowrap" align="right" style="'+pSuggestTypeStyle+'">'+pSuggestParts[2]+"</td></tr>"}outputText+="</table>";if(pSuggest.length>=1){showLayer();pLayer.innerHTML=outputText}else{hideLayer();pLayer.innerHTML=""}moveSelection("down")}function highlightSuggest(tblCell){tblCell.style.backgroundColor=pHighlightBgColor;tblCell.style.color=pHighlightTextColor}function unmarkSuggest(tblCell){tblCell.style.backgroundColor=pStandardBgColor;tblCell.style.color=pStandardTextColor}function unmarkAll(){var tblCell;for(var i in pSuggest){tblCell=getTableCell(i);if(tblCell!=null){unmarkSuggest(tblCell)}}}function getTableCell(pos){var tblCell;tblCell=document.getElementById(pLayerName+"_"+pos);return tblCell}};


