if(typeof gFSUGGEST=="undefined"){
    var gFSUGGEST="defined";
    var gFSuggestInstanceCounter=0;
    var gFSuggestInstances=new Array;
    bodySelect=true;
    blockHide=false;
    var geoMap = null;
    var prattr = '';
    function stringComparison(a, b)	{
        var astring = a.value;
        var bstring = b.value;
        a = astring.toLowerCase();
    	a = astring.replace(/ä/g,"a");
    	a = astring.replace(/ö/g,"o");
    	a = astring.replace(/ü/g,"u");
    	a = astring.replace(/ß/g,"s");

    	b = bstring.toLowerCase();
    	b = bstring.replace(/ä/g,"a");
    	b = bstring.replace(/ö/g,"o");
    	b = bstring.replace(/ü/g,"u");
    	b = bstring.replace(/ß/g,"s");

    	return(a==b)?0:(a>b)?1:-1;
    }

    function FSuggest(a){
        gFSuggestInstances[gFSuggestInstanceCounter]=this;
        this.instance=gFSuggestInstanceCounter++;
        this.currentInput="";
        this.timer=null;
        this.clickSel=0;
        this.scrollSel=0;
        this.userInput="";
        this.params=null;
        this.field=null;
        this.selectType=false;
        this.favorites=false;
        this.newJSONRequest=false;
        this.suggestMode=true;
        this.reenableButton;
        this.useTopFavorites=true;
        this.topMatches = 0;
        this.cookieMatches = 0;
        this.showSuggestionList = false;
        this.useperi = false;
        this.geoMap = null;

        this.getSuggestFunctionality = function (){
             var value = "";
             if(document.cookie) {
                 this.suggestMode = SLs.getCookieValue(document.cookie,"db4-suggestMode=",";");
                 if(this.suggestMode != "") {
                     if(this.suggestMode == "false") {
                         this.showEnableButton();
                         this.params.useSuggest = false;
                     }

                 }
             }
        };
        this.showEnableButton = function (){
              var field = this.field;
              var parameter = this;
              var instance = this.instance;

              this.reenableButton = document.createElement("input");
                         var decay = 1000 * 60 * 60 * 24 * 365;
                         var now = new Date();
                         var timeout = new Date(now.getTime() + decay);
                         this.reenableButton.className = 'suggestButton';
                         this.reenableButton.title = (typeof t_suggestionson != 'undefined')?t_suggestionson:'Enable Suggestions';
                         this.reenableButton.onclick = function(){
                            this.disabled = true;
                            this.style.display = 'none';
                            parameter.params.useSuggest = true;
                            document.cookie = "db4-suggestMode=" + parameter.params.useSuggest + "; expires=" + timeout.toGMTString() + ";";
                            field.focus();
                            for(var j=0;j < gFSuggestInstanceCounter; j++) {
                                 gFSuggestInstances[j].reenableButton.parentNode.removeChild(gFSuggestInstances[j].reenableButton);
                                 gFSuggestInstances[j].field.style.width = (parseInt(gFSuggestInstances[j].field.style.width) + 10) + 'px';
                                 gFSuggestInstances[j].params.useSuggest = true;
                                 SLs.inputField = field;
                            }
                            if(!SLs.container){
                                if(field.value != '') {
                                    fieldIndex = instance;
                                    document.getElementsByTagName("body")[0].appendChild(SLs.erzeugen(instance))
                                    this.newJSONRequest = true;
                                    SLs.getJS(field.value+"?",instance);
                                }
                            }
                         };
                         this.field.style.width = (parseInt(this.field.style.width) - 10) + 'px';
                         this.field.parentNode.insertBefore(this.reenableButton,this.field.nextSibling);
                         SLs.delete_SLs();
         };
         this.toggleSuggestMode = function(){
            var decay = 1000 * 60 * 60 * 24 * 365;
            var now = new Date();
            var timeout = new Date(now.getTime() + decay);
            var field = this.field;
            var parameter = this.params;
            var suggestvalue;
            if(this.params.useSuggest == true) {
                this.params.useSuggest = false;
            }else{
                this.params.useSuggest = true;
            }
            for(var j=0;j < gFSuggestInstanceCounter; j++) {
                gFSuggestInstances[j].showEnableButton();
                gFSuggestInstances[j].params.useSuggest=false;
            }
            document.cookie = "db4-suggestMode=" + parameter.useSuggest + "; expires=" + timeout.toGMTString() + ";";
            this.field.focus();
            this.params.useSuggest = suggestvalue;
        };

        this.changeOnSubmitOfMyFormular=function(){
               var f=this.field;
               while(f!=null){
                   if(f.nodeName=="FORM"){
                       submitFunction=f.onsubmit;
                       f.onsubmit=new Function("ereignis","return gFSuggestInstances["+this.instance+"].cbonsubmit(ereignis);");
                       return
                   }
                   f=f.parentNode}
        };

        this.cbonsubmit=function(){
                 if(SLs.container){
                      if(typeof(hideWaitIcon)=="function"){
                            hideWaitIcon()
                      }
                      SLs.inputField.focus();
                      return false
                  }else{
                           this.resetHafasSuggest();
                           if(typeof(submitFunction)=="function"){
                               submitFunction()
                           }
                           return true}
                  };



                  this.cbonkeyup=function(g){
                      SLs.inputField = this.field;
                      blockHide = false;
                      test=this.field;currentKC=(g)?g.keyCode:window.event.keyCode;
                      if(this.timer){
                          window.clearTimeout(this.timer)
                      }
                      if(test.value.length<this.params.minChar && test.value.length > 0 && this.params.useSuggest == true){
                          if(currentKC!=40&&currentKC!=38&&currentKC!=9&&currentKC!=13){
                              SLs.lastSLSlist = null;
                              var f=this.instance;
                              fieldIndex=f;
                              SLs.inputField=this.field;
                              SLs.delete_SLs();
                              SLs.inputField=this.field;
                              if(!SLs.container){}
                              SLs.fillWithCookieValues(this)
                          }else{
                              this.suggestion(currentKC)
                          }
                      }else{
                          if(test.value.length == 0) {
                              SLs.cachedSuggestions = null;
                              SLs.stopWaiting();
                          }
                          if(currentKC!=40&&currentKC!=38&&currentKC!=9&&currentKC!=13 && currentKC!=44 && currentKC!=17 && test.value.length != 0){
                              if(SLs.checkUpdate(currentKC)){
                                  if(this.params.useSuggest == true) {
                                      SLs.waiting();
                                  }
                                  this.timer=window.setTimeout("gFSuggestInstances["+this.instance+"].suggestion(test, currentKC)",this.params.stopDelay)
                              }
                              else{
                                  SLs.delete_SLs();
                                  SLs.showSuggestion();
                              }
                           }else{
                              if(currentKC!=44&&currentKC!=17) {
                                  this.suggestion(currentKC)
                              }
                          }
                      }
                 };
                 this.cbonfocus=function(g){
                     test=this.field;
                     var actObj = this;
                     if(this.timer){
                         window.clearTimeout(this.timer)
                     }
                     if(test.value.length<this.params.minChar){
                         if(SLs.container){
                             window.setTimeout("SLs.delete_SLs()",100);
                             var f=this.instance;
                             fieldIndex=f;
                             SLs.inputField=this.field;
                             window.setTimeout(function(){
                                 SLs.fillWithCookieValues(actObj);
                             },200);
                         }else{
                           var f=this.instance;
                           fieldIndex=f;
                           SLs.inputField=this.field;
                           SLs.fillWithCookieValues(this)
                         }
                     }
                 };
                 this.cbonclick=function(f){
                     if(SLs.container){
                         SLs.delete_SLs()
                     }
                     currentField=(f)?f.target:window.event.target;
                     if(currentField.value.length<this.params.minChar && this.params.useSuggest == true){
                         SLs.fillWithCookieValues(this)
                     }
                 };
                 this.suggestion=function(f){
                     var g=this.instance;
                     fieldIndex=g;
                     SLs.inputField=this.field;
                     if((f==40)&&(SLs.container)){
                         this.moveSelection(1);
                     }else{
                         if((f==38)&&(SLs.container)){
                            this.moveSelection(0);
                         }else{
                             if(f!=9&&f!=16&&f!=13){
                                 this.userInput=this.field.value;
                                 if(SLs.container){
                                     SLs.delete_SLs();
                                     SLs.countList=-1
                                 }
                                 if((this.field.value!="")&&(this.params.useSuggest)){
                                     var suggestContainer = document.getElementsByTagName("body")[0].appendChild(SLs.erzeugen(fieldIndex));
                                     if(this.params.requestType=="ajax"){
                                         SLs.holen(this.field.value+"?",fieldIndex)
                                     }else{
                                         this.newJSONRequest = true;
                                         SLs.getJS(this.field.value+"?",fieldIndex)
                                     }
                                 }
                             }else{
                                 if(f==13){
                                     if(SLs.container){
                                         if((SLs.countList>-1) && (SLs.container.getElementsByTagName("div")[SLs.countList].className != 'furtherMatchesselected') && (SLs.container.getElementsByTagName("div")[SLs.countList].className != 'infoLabel')){
                                             var content = SLs.clearHTMLTags(SLs.container.getElementsByTagName("div")[SLs.countList].lastChild.innerHTML);
                                             content = SLs.checkPR(content);
                                             this.setSLSInput(SLs,content,SLs.container.getElementsByTagName("div")[SLs.countList].id)
                                         }else{
                                             if(this.field.value.length > 0 && SLs.container.getElementsByTagName("div")[(SLs.container.getElementsByTagName("div").length-1)].className == 'furtherMatchesselected') {
                                                 SLs.showAllSuggestions();
                                             }else{
                                               SLs.countList = 0;
                                               while(SLs.container.getElementsByTagName("div")[SLs.countList].className == 'infoLabel'){
                                                  SLs.countList++;
                                               }
                                               var content = SLs.clearHTMLTags(SLs.container.getElementsByTagName("div")[SLs.countList].lastChild.innerHTML);
                                               content = SLs.checkPR(content);
                                               this.setSLSInput(SLs,content,0);
                                             }
                                         }
                                         SLs.inputField.focus();
                                         SLs.delete_SLs()
                                         SLs.stopWaiting();
                                    }
                                 }

                              }
                         }
                     }
                 };
                 this.leaveInputField=function(){
                     if(SLs.container){
                         if(this.scrollSel&&this.scrollSel==1&&!this.clickSel){
                                 SLs.inputField.focus();
                                 this.scrollSel=0
                         }else{
                             if(this.clickSel==1){
                                 SLs.inputField.focus();
                                 this.clickSel=0
                             }else{
                                 if(SLs.countList>-1){
                                      var content = SLs.clearHTMLTags(SLs.container.getElementsByTagName("div")[SLs.countList].lastChild.innerHTML);
                                      this.setSLSInput(SLs,SLs.inputField.value,SLs.countList)
                                 }else{
                                     SLs.delete_SLs();
                                 }
                             }
                             //alert(SLs.extendedSearch);
                             if(SLs.extendedSearch != true) {
                                 window.setTimeout("SLs.delete_SLs();",200)

                             }
                          }

                     }

                 };
                 this.resetHafasSuggest=function(){};
                 this.setInputFieldValue=function(g,f){
                        if(typeof g.inputField!="undefined"){
                                g.inputField.value=f
                        }
                 };

                 this.moveSelection=function(mode){
                         // Alte Selektion auflösen
                         if(SLs.countList != -1) {
                             if(SLs.container.getElementsByTagName("div")[SLs.countList].className != 'infoLabel') {
                                SLs.container.getElementsByTagName("div")[SLs.countList].className=SLs.classSelect(SLs.container.getElementsByTagName("div")[SLs.countList].className,"selected");
                             }
                         }
                         if((mode==0) && (SLs.countList>0)) { SLs.countList--; }
                         else if((mode==1) && (SLs.container.getElementsByTagName("div")[SLs.countList+1])) { SLs.countList++; }
                         if(SLs.countList != -1) {
                         while((SLs.container.getElementsByTagName("div")[SLs.countList].className == 'infoLabel')) {
                             if(mode==0) {
                                 if(SLs.container.getElementsByTagName("div")[0].className != 'infoLabel'){
                                    SLs.countList--;
                                 }else{
                                    SLs.countList++;
                                 }
                             }else if(mode==1) {
                                 SLs.countList++;
                             }
                         }
                         if(SLs.countList==-1){
                             this.setSLSInput(SLs,this.userInput,SLs.countList)
                         }else{
                             if(mode==0) {
                                 if(((SLs.countList)*20 < SLs.container.scrollTop) && (SLs.container.scrollTop != 0)) {
                                    SLs.container.scrollTop=SLs.container.scrollTop-20;
                                 }
                             }else if(mode==1){
                                 if((SLs.countList+1)*20 > SLs.container.clientHeight) {
                                    SLs.container.scrollTop=SLs.container.scrollTop+20; 
                                 }
                             }
                            // if(mode==0) {
                            //     SLs.container.scrollTop=SLs.currentTop*13;
                            //     if(SLs.countList<=SLs.currentTop+1){
                            //        SLs.container.scrollTop=SLs.container.scrollTop-15;
                            //        SLs.currentTop--;
                            //        SLs.currentBottom--
                            //     }
                            // }else if(mode==1){
                            //     SLs.container.scrollTop=SLs.currentTop*15;
                            //     if(SLs.currentTop != 0){
                            //        SLs.container.scrollTop=SLs.container.scrollTop+15;
                            //     }
                            //     if(SLs.countList>=SLs.currentTop+1){
                            //        SLs.currentTop++;
                            //        SLs.currentBottom++;
                            //     }
                            // }
                             if(SLs.container.getElementsByTagName("div")[SLs.countList].className != 'infoLabel'){
                                     SLs.container.getElementsByTagName("div")[SLs.countList].className=SLs.container.getElementsByTagName("div")[SLs.countList].className + "selected";
                                 }else{
                                     SLs.countList++;
                                     SLs.container.getElementsByTagName("div")[SLs.countList].className=SLs.container.getElementsByTagName("div")[SLs.countList].className + "selected";
                                 }
                             }
                         }
                 };
                 this.setSLSInput=function(j,g,h){
                        this.setInputFieldValue(j,g);
                        var f="";
                        var k="";
                        if(typeof j.sls.suggestions[h]!="undefined"){
                               if(typeof j.sls.suggestions[h].id!="undefined"){
                                    this.setTripleId(j.sls.suggestions[h].id);
                                    j.sls.suggestions[h].id.match(/L=(\d+)/);
                                    k=RegExp.$1
                               }
                               if(typeof j.sls.suggestions[h].type!="undefined"){
                                    this.setLocationType(j.sls.suggestions[h].type);
                                    f=j.sls.suggestions[h].type
                               }
                               if(typeof this.params.selectCallback!="undefined"){
                                    this.params.selectCallback(j.sls.suggestions[h].ycoord,j.sls.suggestions[h].xcoord,k,
                                                               j.sls.suggestions[h].value,
                                                               j.sls.suggestions[h].type,
                                                               j.sls.suggestions[h].prodClass,
                                                               j.sls.suggestions[h].weight,
                                                               j.sls.suggestions[h].id);
                               }
                         }else{
                              if(typeof favHash.suggestions[h].id!="undefined"){
                                    this.setTripleId(favHash.suggestions[h].id);
                                    favHash.suggestions[h].id.match(/L=(\d+)/);
                                    k=RegExp.$1
                               }
                         }
                 };


                 this.setTripleId=function(h){
                        if(typeof this.params.type!="undefined"){
                               if(this.field.name.charAt(this.field.name.length-1)=="G"){
                                     var f=this.field.name.replace(/G$/,"ID")
                               }else{
                                     var f="REQ0JourneyStops"+this.params.type+"ID"
                               }
                                     var g=null;
                                     if(document.getElementsByName(f)){
                                          g=document.getElementsByName(f)[0]
                                     }
                                     if(g==null||typeof g=="undefined"){
                                          g=document.createElement("input");
                                          g.type="hidden";
                                          g.name=f;
                                          this.field.parentNode.insertBefore(g,this.field.nextSibling)
                                     }
                                          g.value=h
                      }else{
                         var f=this.field.id+"ID";
                         if(document.getElementById(f)){
                             g=document.getElementById(f);
                         }
                         g.value=h;
                      }
                 };
                 this.setLocationType=function(g){
                        if((typeof this.params.type!="undefined")&&((this.field.name.match(/G$/)!=null)||(this.field.name=="S")||(this.field.name=="Z"))){
                                 if(this.field.name=="S"){
                                         f="REQ0JourneyStopsS0A"
                                 }else{
                                        if(this.field.name=="Z"){
                                              f="REQ0JourneyStopsZ0A"
                                        }else{
                                              var f=this.field.name.replace(/G$/,"A")
                                        }
                                 }
                                 var h=document.getElementsByName(f)[0];
                                 if((h!=null)&&((h.nodeName=="SELECT")||((h.value!=7)&&(h.value!=255)))){
                                        h.value=g
                                 }else{
                                        if(h!=null){
                                                var i=document.getElementById("ignoreTypeCheck");
                                                if((i==null)||(typeof(i)=="undefined")){
                                                         i=document.createElement("input");
                                                         i.type="hidden";
                                                         i.name="ignoreTypeCheck";
                                                         i.id="ignoreTypeCheck";
                                                         i.value="yes";
                                                         this.field.parentNode.insertBefore(i,this.field)
                                                }
                                        }else{
                                                var i=document.createElement("input");
                                                i.type="hidden";
                                                i.name=f;
                                                i.value=g;
                                                this.field.parentNode.insertBefore(i,this.field)
                                        }
                                  }
                              }
                    };
                    if(this.instance==0){
                             document.body.onmousedown=function(){
                                 if(document.getElementById("suggestion")&&bodySelect){
                                       SLs.delete_SLs()
                                       SLs.extendedSearch = true;

                                 }
                                 bodySelect=true
                             }
                    }
                    this.params={
                             loc:a.loc,type:a.type,minChar:a.minChar,requestURL:a.requestURL,cookiename:a.cookiename,stopDelay:a.stopDelay,requestType:a.requestType,useSuggest:a.useSuggest,useMaps:a.useMaps,useProducts:false,useWrap:false,minMatch:1,selectCallback:a.selectCallback,onProductButton:a.onProductButton,onMapButton:a.onMapButton,width:a.width,onShow:a.onShow,minimizeList:true
                    };
                    if(typeof a.useHash != 'undefined') {
                        this.useTopFavorites = a.useHash;
                    }
                    if(typeof(this.params.requestType)=="undefined"){
                             this.params.requestType="js"
                    }
                    if(typeof(this.params.useSuggest)=="undefined"){
                             this.params.useSuggest=true
                    }

                    if(typeof this.params.loc!="undefined"&&typeof document.getElementById(this.params.loc)!="undefined"){
                             this.field=document.getElementById(this.params.loc);
                             var b=true;
                             for(var c=0;c<this.instance;c++){
                                   if(gFSuggestInstances[c].field.form==this.field.form){
                                               b=false
                                   }
                             }
                             if(b){
                                   this.changeOnSubmitOfMyFormular()
                             }

                             this.field.setAttribute("autocomplete","off");
                                   this.field.onfocus=function(){
                                   currentInput=this.value
                             };
                             this.field.onkeyup=new Function("ereignis","gFSuggestInstances["+this.instance+"].cbonkeyup(ereignis);");
                             this.field.onfocus=new Function("ereignis","gFSuggestInstances["+this.instance+"].cbonfocus(ereignis);");
                             this.field.onblur=new Function("ereignis","window.clearTimeout(gFSuggestInstances["+this.instance+"].timer);gFSuggestInstances["+this.instance+"].leaveInputField();");
                             if(this.params.setFocus=="yes"&&(this.instance==0)){
                                     var d=this.field;
                                     var e=true;
                                     while(d){
                                         if((d.tagName=="BODY")||(d.tagName=="HTML")){
                                                 break
                                         }
                                         if((d.style.display=="none")||(d.style.visibility=="hidden")){
                                                 e=false;
                                                 break
                                         }
                                         d=d.parentNode
                                     }
                                     if(e){
                                         this.field.focus()
                                     }
                             }
                         }
                         this.getSuggestFunctionality();
     }
}
var SLs={
    container:null,currLocation:null,ajax:false,div_breite:"auto",div_hoehe:170,countList:-1,currentTop:0,currentBottom:9,inputField:null,pos_x:0,pos_y:0,sls:null,lastSLSlist:null,topCities:null,minimap:null,cachedSuggestions:null,extendedSearch:false,erzeugen:function(a){
        this.topCities =  { "suggestions": []};
        SLs.container=document.createElement("div");SLs.container.id="suggestion";
        if(navigator.userAgent.toLowerCase().indexOf("opera")>-1){
            SLs.container.style.minWidth="148px"
        }
        if(typeof gFSuggestInstances[fieldIndex].params.width != 'undefined') {
            SLs.container.style.width = gFSuggestInstances[fieldIndex].params.width + 'px';
        }else{
                SLs.container.style.width=SLs.inputField.offsetWidth + 'px';
        }
        SLs.container.style.height="auto";
        SLs.pos_x=SLs.getPosX(SLs.inputField)+0;
        SLs.pos_y=SLs.getPosY(SLs.inputField)+16;
        SLs.container.style.left=SLs.pos_x+"px";
        SLs.container.style.top=SLs.pos_y+"px";
        SLs.container.onmousedown=new Function("ereignis","bodySelect=false;if((navigator.userAgent.toLowerCase().indexOf('msie')>-1)||(navigator.userAgent.toLowerCase().indexOf('safari')>-1))gFSuggestInstances[fieldIndex].scrollSel=1;");
        return SLs.container
    },speichern:function(userInput, liste){

          if(this.cachedSuggestions == null) {
              this.cachedSuggestions = new Array();
              this.cachedSuggestions[userInput] = liste;
          }else{
              if(this.cachedSuggestions[userInput] == null) {
                 this.cachedSuggestions[userInput] = liste;
                 return true;
              }else{
                  return false;
              }
          }
    },waiting:function(){
        if(typeof document.getElementById('waiting') == 'undefined' || document.getElementById('waiting') == null) {
            var waitingscreen = document.body.appendChild(document.createElement("div"));
            SLs.pos_x=SLs.getPosX(SLs.inputField)+1;
            SLs.pos_y=SLs.getPosY(SLs.inputField)+20;
            waitingscreen.style.left=SLs.pos_x - 3 + "px";
            waitingscreen.style.top=SLs.pos_y+ 7 +"px";
            waitingscreen.style.position = 'absolute';
        }else{
           document.getElementById('waiting').style.display = 'block';
           SLs.pos_x=SLs.getPosX(SLs.inputField)+1;
           SLs.pos_y=SLs.getPosY(SLs.inputField)+20;
           document.getElementById('waiting').style.left=SLs.pos_x -3 + "px";
           document.getElementById('waiting').style.top=SLs.pos_y + 7 + "px";
        }

    },stopWaiting: function(){
         if(document.getElementById('waiting')!=null) {
            document.getElementById('waiting').style.display = 'none';
         }
    },laden:function(input){
         if(this.cachedSuggestions != null) {
             return this.cachedSuggestions[input];
         }

    },holen:function(input,fieldIndex){
         try{
             SLs.ajax=new XMLHttpRequest()
         }catch(w3c){
             try{
                 SLs.ajax=new ActiveXObject("Msxml2.XMLHTTP")
             }catch(msie){
                 try{SLs.ajax=new ActiveXObject("Microsoft.XMLHTTP")
             }catch(msie_alt){
                 SLs.delete_SLs();
                 for(var i=0;i<gFSuggestInstances.length;i++){
                     var f=document.getElementById(gFSuggestInstances[i].params.loc);
                     if(f){
                         f.onfocus=null;
                         f.onkeyup=null;
                         f.onblur=null;
                         f.onclick=null
                     }
                 }
                 return false
             }
             }
        }
        var tempURL=gFSuggestInstances[fieldIndex].params.requestURL+input+"&";
        var typeSelectName=gFSuggestInstances[fieldIndex].field.name.replace(/G$/,"A");
        var typeSelectbox=document.getElementsByName(typeSelectName)[0];
        if((typeSelectbox!=null)&&(typeSelectbox.nodeName=="SELECT")){
            var replaceTypeRegExp=/REQ0JourneyStopsS0A=(\d+)&/;
            tempURL=tempURL.replace(replaceTypeRegExp,"REQ0JourneyStopsS0A="+typeSelectbox.value+"&");
            gFSuggestInstances[fieldIndex].selectType=true
        }
        if(gFSuggestInstances[fieldIndex].params.locType&&document.getElementById(gFSuggestInstances[fieldIndex].params.locType+"_hidden")){
            var currentLocType=document.getElementById(gFSuggestInstances[fieldIndex].params.locType+"_hidden").value;
            tempURL=tempURL+gFSuggestInstances[fieldIndex].params.requestURL2+currentLocType+"&"}SLs.ajax.open("GET",tempURL,true);
            SLs.ajax.setRequestHeader("Content-Type","text/xml");
            SLs.ajax.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
            SLs.ajax.send(null);
            SLs.ajax.onreadystatechange=function(){
                if(SLs.ajax.readyState==4){
                    if(SLs.ajax.status!=200){
                        SLs.delete_SLs();return false
                    }
                    if(SLs.ajax.responseText){
                        eval(SLs.ajax.responseText);
                        return SLs.showSuggestion()
                    }
                    var nicht_gefunden=document.createTextNode("No suggestions for your input '"+input+"'.");
                    SLs.container.appendChild(nicht_gefunden);return false
                }
            }
         },getBoldCharacters:function(word,suggestion,j){
                 j++;
                 var matches = 0;
                 word = this.removeSpecialChars(word);
                 if(word!="" && word!="<" && word != ">") {
                     //var regex = new RegExp(">([^<]*)?("+searchTerms[i]+")([^>]*)?<","ig");
                     var exp = new RegExp("(?!<"+word+")?!>","g");
                     //var exp = new RegExp("<b(>.|\\n)*?<\\/b>" + word,"g");
                     //var exp = new RegExp("((?:[^<]*?<[^>]+?>)*?[^<]*?)"+word,"g","$1"+word.bold());

                     var replace = new RegExp(word);
                     var found = suggestion.search(exp,"<b>"+word+"</b>");
                     if(found != -1) { matches++; }
                     suggestion = suggestion.replace(exp,"<b>"+word+"</b>");
                     exp=new RegExp(word.toUpperCase());
                     found = suggestion.search(exp,word.toUpperCase());
                     if(found != -1) { matches++; }
                     suggestion = suggestion.replace(exp,"<b>"+word.toUpperCase()+"</b>");
                     var uppercaseFirst = this.upperCaseFirst(word);
                     exp=new RegExp(uppercaseFirst);
                     found = suggestion.search(exp,uppercaseFirst);
                     if(found != -1) { matches++; }
                     suggestion = suggestion.replace(exp,"<b>"+uppercaseFirst+"</b>");
                     if(matches == 0) {
                         if(j < word.length - 1) {
                                 suggestion = this.getBoldCharacters(word.substr(0,word.length-j),suggestion,j);
                                 suggestion = this.getBoldCharacters(word.substr(j,word.length-j),suggestion,j);
                         }
                     }
                 }
                 return suggestion;

         },removeSpecialChars:function(word){
               // reservierte RegExp löschen ?{}.
               word = word.replace(/\./g, ""); // .
               word = word.replace(/,/g, "");  // ,
               word = word.replace(/\$/g,"");  // $
               word = word.replace(/\?/g,""); // ?
               word = word.replace(/[\)]/g,"");  // )
               word = word.replace(/[\(]/g,"");  // (
               word = word.replace(/[\+]/g,"");  // +
               word = word.replace(/[\*]/g,"");  // *
               word = word.replace(/[\[]/g,"");  // [
               word = word.replace(/[\]]/g,"");  // ]
               word = word.replace(/\\/g, "");  // \
               word = word.replace(/\|/g, "");  // |
               word = word.replace(/\^/g, ""); // ^
               word = word.replace(/\</g, "");
               word = word.replace(/\>/g, "");
               return word;
         },upperCaseFirst:function(str){
              var f = str.charAt(0).toUpperCase();
              for(var j=1; j < str.length;j++) {
                 f += str.charAt(j).toLowerCase();
              }
              return f;

         },addMenu:function(){
             // Hauptmenüleiste
             var labelSuggestions = document.createElement("div");
             labelSuggestions.style.textAlign = 'right';
             var closeButton = document.createElement("a");
             closeButton.className = 'closeButton';
             labelSuggestions.id = 'suggestionMenu';
             closeButton.innerHTML = (typeof t_suggestionsoff != 'undefined')?t_suggestionsoff:'Disable Suggestions';
             closeButton.onclick = function(){
                 gFSuggestInstances[fieldIndex].toggleSuggestMode();
             }
             labelSuggestions.appendChild(closeButton);
             labelSuggestions.className = 'infoLabel';

             if(typeof Map != 'undefined') {
                 var labelMapArea = document.createElement("div");
                 labelMapArea.className = 'infoLabel';
                 var labelPeri = document.createElement("label");
                 labelPeri.innerHTML = (typeof t_limitSearchMap != 'undefined')?t_limitSearchMap:'Limit search to map content';
                 labelMapArea.appendChild(labelPeri);
                 labelMapArea.style.textAlign = 'right';
                 this.pericheckbox = document.createElement("input");
                 this.pericheckbox.type = 'checkbox';
                 this.pericheckbox.name = 'REQ0JourneyStopsF0A';
                 this.pericheckbox.checked = gFSuggestInstances[fieldIndex].useperi;
                 labelMapArea.appendChild(this.pericheckbox);
                 this.pericheckbox.onchange = function(){
                      SLs.selPerimParams(this);
                      gFSuggestInstances[fieldIndex].useperi = this.checked;
                      SLs.delete_SLs();
                      SLs.getJS(gFSuggestInstances[fieldIndex].field.value+"?",fieldIndex);

                 }
                 SLs.container.appendChild(labelMapArea);


             }
             if(gFSuggestInstances[fieldIndex].params.useMaps == true) {
             var separator = document.createElement("span");
             separator.innerHTML = ' | ';
             labelSuggestions.appendChild(separator);

                 var closeMap = document.createElement("a");
                 closeMap.className = 'closeButton';
                 if(gFSuggestInstances[fieldIndex].params.useMaps) {
                     closeMap.innerHTML = (typeof t_minimapoff != 'undefined')?t_minimapoff:'Disable mini-map';
                 }else{
                     closeMap.innerHTML = (typeof t_minimapon != 'undefined')?t_minimapon:'Enable mini-map';
                 }
                 closeMap.onclick = function(){
                     if(document.getElementById('geomap')==null) {
                         SLs.createGeoBox();
                     }

                     if(gFSuggestInstances[fieldIndex].params.useMaps == true){

                        this.innerHTML = ' ' + (typeof t_minimapon != 'undefined')?t_minimapon:'Enable mini-map';
                         document.getElementById('geomap').style.display = 'none';
                         gFSuggestInstances[fieldIndex].params.useMaps = true;
                     }else{

                         document.getElementById('geomap').style.display = 'block';
                         this.innerHTML = ' ' + (typeof t_minimapoff != 'undefined')?t_minimapoff:'Disable mini-map';
                         gFSuggestInstances[fieldIndex].params.useMaps = false;
                        }

                     gFSuggestInstances[fieldIndex].params.useMaps = !(gFSuggestInstances[fieldIndex].params.useMaps);
                 }
                 labelSuggestions.appendChild(closeMap);

             }
             SLs.container.appendChild(labelSuggestions);
         },checkPR:function(str){
            if(str.indexOf(' P&R station') != -1) {
               prattr = ' P&R station';
               str = str.substr(0,str.length - prattr.length);
            }
            return str;
         },showSuggestion:function(){
             if(!SLs.container){
                  document.getElementsByTagName("body")[0].appendChild(SLs.erzeugen(fieldIndex))
             }
            // SLs.addMenu();
             //
             gFSuggestInstances[fieldIndex].topMatches = 0;
             if(gFSuggestInstances[fieldIndex].useTopFavorites == true) {
                topcities = this.addTopCities();
             }
             gFSuggestInstances[fieldIndex].params.requestURL.match(/REQ0JourneyStopsS0A=(\d)/);
             var d=RegExp.$1;
             if(navigator.userAgent.indexOf("Safari")>-1){
                 var e="right: 18px;"
             }else{
                 if(navigator.userAgent.indexOf("MSIE")>-1){
                     var e="right: 0px;"
                 }else{
                     var e="right: 0px;"
                 }
              }
             SLs.lastSLSlist = SLs.sls.suggestions;
             if(gFSuggestInstances[fieldIndex].newJSONRequest) {
                 var saved = SLs.speichern(gFSuggestInstances[fieldIndex].field.value,SLs.sls.suggestions);
             }
             gFSuggestInstances[fieldIndex].newJSONRequest = false;
             var c=new Array();
             var addedSuggestions = 0;
             //
             //var labelSuggestions = document.createElement("div");
             //labelSuggestions.style.textAlign = 'right';
             //labelSuggestions.innerHTML = '<div class="infoLabel" style="height:2px";></div>';
             //labelSuggestions.className = 'infoLabel';
             //SLs.container.appendChild(labelSuggestions);
             var maxSuggestions;
             if(typeof topcities != 'undefined' && topcities != 0){
                  maxSuggestions = SLs.sls.suggestions.length - (topcities-1);
             }
             else{
                  maxSuggestions = SLs.sls.suggestions.length;
             }
             for(var b=0;b<maxSuggestions ;b++){
                  if(SLs.container){

                      if(SLs.checkForMatches("substr",gFSuggestInstances[fieldIndex].field.value,SLs.sls.suggestions[b].value) || gFSuggestInstances[fieldIndex].showSuggestionList == true || gFSuggestInstances[fieldIndex].params.minimizeList==true) {

                          c[b]=SLs.container.appendChild(document.createElement("div"));
                          c[b].id=addedSuggestions;
                          addedSuggestions++;
                          if(SLs.sls.suggestions[b].typeStr == '[POI]' || SLs.sls.suggestions[b].type == "4") {
                              c[b].className = 'poi';
                          }else if(SLs.sls.suggestions[b].typeStr == '[Adr]' || SLs.sls.suggestions[b].type == "2"){
                              c[b].className = 'adr';
                          }
                          if(((d==7)||(d==255) || (d==5))&&(typeof(SLs.sls.suggestions[b].typeStr)!="undefined")&&(!gFSuggestInstances[fieldIndex].selectType)){
                              var a=SLs.sls.suggestions[b].typeStr
                          }else{
                              var a=""
                          }
                          if(gFSuggestInstances[fieldIndex].params.useProducts == true && typeof SLs.sls.suggestions[b].prodClass != 'undefined') {
                              var product = SLs.getProductIcon(SLs.sls.suggestions[b].prodClass,SLs.sls.suggestions[b].value);
                          }

                          /*if(typeof SLs.sls.suggestions[b].prodClass != 'undefined' && SLs.sls.suggestions[b].type=="1") {
                              var weight;
                              weight = SLs.getWeightIcon(SLs.sls.suggestions[b].weight);
                          }*/
                          var tmpSuggestion = SLs.sls.suggestions[b].value;
                          var userInput = gFSuggestInstances[fieldIndex].field.value;
                          tmpSuggestion = SLs.replaceSpecialChars(tmpSuggestion);
                          var wordlength = gFSuggestInstances[fieldIndex].field.value.length;
                          var matchedWordStart = tmpSuggestion.toUpperCase().indexOf(userInput.toUpperCase());
                              var inputTokens = new Array();
                              inputTokens = userInput.split(" ");
                              /*for(var k=0; k < inputTokens.length; k++) {
                                  if(inputTokens[k] != "") {
                                      tmpSuggestion = this.getBoldCharacters(inputTokens[k],tmpSuggestion,0);


                                  }
                              }*/
                          resultString = tmpSuggestion;
                          var iconsRight = '';
                          var wrapStyle = '';
                          if(gFSuggestInstances[fieldIndex].params.useWrap) {
                              wrapStyle = ' style="height:auto;word-wrap:break-word;display:block;width:233px;white-space:pre-wrap"';
                          }
                          var realResult = resultString;
                          if(typeof SLs.sls.suggestions[b].infotexts != 'undefined'){
                             for(var l=0;l < SLs.sls.suggestions[b].infotexts.length;l++) {
                                 if(SLs.sls.suggestions[b].infotexts[l].code == 'CM') {
                                     resultString += ' (' + SLs.sls.suggestions[b].infotexts[l].text + ')';
                                 }
                             }
                             
                          }
                          iconsRight = SLs.addIcons(SLs.sls.suggestions[b].xcoord,SLs.sls.suggestions[b].ycoord,SLs.sls.suggestions[b].value);
                          c[b].innerHTML="<span style='margin-right:3px;display: inline;float:right;color:#4d4d4d;font-style:italic;"+e+"'><span id='pr_"+ b+"'></span>" + iconsRight + (typeof weight!='undefined' && weight != 0?weight:'') + "</span><span" + wrapStyle + ">"+ resultString + "</span><span style='display:none'>"+realResult+"</span>";
                          //<span style='display:none'>"+realResult+"</span>
                         if(typeof product != 'undefined' && SLs.sls.suggestions[b].type == 1) {
                                if((typeof product != 'string') && (typeof document.getElementById('pr_' + b) != 'undefined')) {
                                    document.getElementById('pr_' + b).appendChild(product);
                                }
                          }
                         c[b].onclick=function(){
                               gFSuggestInstances[fieldIndex].clickSel=1;
                               var content = this.lastChild.innerHTML;
                               content = SLs.clearHTMLTags(content);
                               gFSuggestInstances[fieldIndex].setSLSInput(SLs,content,parseInt(this.id))
                               SLs.delete_SLs();
                          }
                          c[b].onmouseover = function(){
                              SLs.mouseSelect(this,"bottom");

                           /*  if(gFSuggestInstances[fieldIndex].params.useMaps==true) {

                                  SLs.showGeoMap(SLs.sls.suggestions[this.id].xcoord,SLs.sls.suggestions[this.id].ycoord, SLs.sls.suggestions[this.id].value);
                              } */
                          }
                          c[b].onmouseout = function(){
                              this.className = SLs.classSelect(this.className,"selected");
                          }
                      }
                  }else{
                      return false
                  }
             }

             if(SLs.sls.suggestions.length >= 12 && SLs.extendedSearch == true) {
                 //this.addFurtherMatchesButton();// Link für alle Treffer anbringen
             }
             gFSuggestInstances[fieldIndex].showSuggestionList = false;
             SLs.container.style.borderWidth="1px";
             SLs.container.style.zIndex="10002";
             if(SLs.sls.length<10){
                 SLs.container.style.height="auto";
             }else{
                 SLs.container.style.height="auto";
             }
             //SLs.container.style.maxHeight=SLs.div_hoehe+124+"px";
             if(navigator.userAgent.toLowerCase().indexOf("msie")>-1){
                //SLs.container.style.width=SLs.container.clientWidth+20;

                //  SLs.container.overflow = "auto";
             }

            if(navigator.userAgent.toLowerCase().indexOf("msie")>-1){
                 //SLs.container.style.width=SLs.container.clientWidth+20;
                 if(SLs.container.scrollHeight > (SLs.div_hoehe+124)){
                     if(SLs.sls.suggestions.length < 20) {
                         SLs.container.style.height= SLs.container.scrollHeight + 2 + "px";
                         SLs.container.overflow = "scroll";
                     }else{
                         SLs.container.style.height = SLs.div_hoehe+124 + 'px';
                         SLs.container.style.width = '300px';
                         SLs.container.overflow = "scroll";

                     }
                 }
                 else{
                     SLs.container.style.height="auto";
                 }
                 SLs.hideSelect()

             }
             if(SLs.sls.suggestions.length<1 || addedSuggestions == 0){
                 SLs.delete_SLs()
                 if(SLs.sls.suggestions.length != 0) {
                     gFSuggestInstances[fieldIndex].showSuggestionList = true;
                     gFSuggestInstances[fieldIndex].newJSONRequest = true;
                     SLs.getJS(gFSuggestInstances[fieldIndex].field.value + "?",fieldIndex,false);
                 }
             }
             gFSuggestInstances[fieldIndex].moveSelection(1);
             if(typeof gFSuggestInstances[fieldIndex].params.onShow != 'undefined' /*&& gFSuggestInstances[fieldIndex].params.useMaps == true*/) {
                 gFSuggestInstances[fieldIndex].params.onShow();
                 SLs.lastZoom = geoMap.getZoom();
             }
             SLs.stopWaiting();
             return true

         },showAllSuggestions:function(){
              SLs.delete_SLs();
              gFSuggestInstances[fieldIndex].showSuggestionList = true;
              gFSuggestInstances[fieldIndex].newJSONRequest = true;
              SLs.getJS(gFSuggestInstances[fieldIndex].field.value + "?",fieldIndex,true);
              gFSuggestInstances[fieldIndex].field.focus();


         },addMapButton:function(x,y,desc){
              //var tmp = '<span "><img src="/img/karte_grau_16x16.gif" style="margin: 0 2px; width:12px; height:12px;" onmouseover="this.src=\'/img/karte_blau_16x16.gif\';" onmouseout="this.src=\'/img/karte_grau_16x16.gif\';" /></span>';
              if(typeof fsugg_map != 'undefined') {
                  var tmp = '<span onmouseover="SLs.showGeoMap('+ x + ',' + y + ',\'' + desc + '\');">' + fsugg_map + '</span>';
                  return tmp;
              }
         },addProductsButton:function(){
              var tmp = '<span>' + SLs.getProducts() + '</span>';
              return tmp;
         },addIcons:function(x,y,desc){
              var icons = '';
              if(gFSuggestInstances[fieldIndex].params.useProducts) {
                      icons +=  SLs.addProductsButton();
              }
              // Maps eingeschaltet?
              if(gFSuggestInstances[fieldIndex].params.useMaps) {

              icons += SLs.addMapButton(x,y,desc);

              }

              return icons;

         },addFurtherMatchesButton: function(){
              var showAllMatches = document.createElement("div");
              showAllMatches.style.textAlign = 'left';
              showAllMatches.className = 'furtherMatches';
              //showAllMatches.id = 'furtherMatches';
              showAllMatches.style.borderTop = '1px solid #333333';
              var allMatchesLink = document.createElement("a");
              allMatchesLink.innerHTML = (typeof t_furtherMatches != 'undefined')?t_furtherMatches:'Show additional matches...';
              allMatchesLink.onclick = function(){
                   SLs.showAllSuggestions();
              }
              showAllMatches.appendChild(allMatchesLink);
              SLs.container.appendChild(showAllMatches);



         },mouseSelect:function(obj,mode){
              if(SLs.countList!=-1 && SLs.container.getElementsByTagName("div")[SLs.countList].className) {
                 var oldClassName = SLs.container.getElementsByTagName("div")[SLs.countList].className;
                 if(oldClassName != 'infoLabel') {
                     SLs.container.getElementsByTagName("div")[SLs.countList].className = SLs.classSelect(oldClassName,"selected");
                 }
              }
              if(obj.className == 'poi') {
                   obj.className = 'poiselected';
              }else if(obj.className == 'adr'){
                   obj.className = 'adrselected';
              }else if(obj.className == '') {
                   obj.className = 'selected';
              }
              if(mode == "bottom") {
                   SLs.countList = parseInt(obj.id) + gFSuggestInstances[fieldIndex].topMatches;
              }else{
                  SLs.countList = parseInt(obj.id);
              }

          },addTopCities:function(){
              if(typeof favHash != 'undefined') {

              SLs.container.style.height = SLs.div_hoehe + 120 + "px";

              gFSuggestInstances[fieldIndex].params.requestURL.match(/REQ0JourneyStopsS0A=(\d)/);
              var d=RegExp.$1;
              if(navigator.userAgent.indexOf("Safari")>-1){
                  var e="right: 18px;"
              }else{
                  if(navigator.userAgent.indexOf("MSIE")>-1){
                      var e="right: 18px;"
                  }else{
                      var e="right: 0px;"
                  }
              }

              var c=new Array();
              var addedSuggestions = 0;
              favHash.suggestions.sort(stringComparison);
              for(var b=0;b<favHash.suggestions.length;b++){
                  if(SLs.container){
                      var tmpSuggestion = favHash.suggestions[b].value;
                      tmpSuggestion = SLs.replaceSpecialChars(tmpSuggestion);
                      var userInput = gFSuggestInstances[fieldIndex].field.value;
                      var matchedWordStart;
                      var inputTokens = new Array();
                      inputTokens = userInput.split(" ");
                      matchedWordStart = tmpSuggestion.toUpperCase().indexOf(userInput.toUpperCase());
                      if(matchedWordStart != 0) {
                          matchedWordStart = -1;
                      }
                      if((SLs.checkForMatches("substr",userInput,tmpSuggestion) && addedSuggestions < 6) || gFSuggestInstances[fieldIndex].field.value.length == 0){
                          c[addedSuggestions]=SLs.container.appendChild(document.createElement("div"));
                          c[addedSuggestions].id=addedSuggestions;

                          if(favHash.suggestions[addedSuggestions].typeStr == '[POI]') {
                              c[addedSuggestions].className = 'poi';
                          }
                          if(((d==7)||(d==255) || (d==5))&&(typeof(favHash.suggestions[addedSuggestions].typeStr)!="undefined")&&(!gFSuggestInstances[fieldIndex].selectType)){
                              var a=favHash.suggestions[addedSuggestions].typeStr
                          }else{
                              var a=""
                          }
                         var wordlength = gFSuggestInstances[fieldIndex].field.value.length;

                              // NO SYNTAX HIGHLIGHT
                              /*for(var k=0; k < inputTokens.length; k++) {
                                 if(inputTokens[k] != "") {
                                      tmpSuggestion = this.getBoldCharacters(inputTokens[k],tmpSuggestion,0);
                                 }
                              }*/
                              resultString = tmpSuggestion;
                          var iconsRight = '';
                          iconsRight = SLs.addIcons(favHash.suggestions[b].xcoord,favHash.suggestions[b].ycoord,favHash.suggestions[b].value);

                          c[addedSuggestions].innerHTML="<span style='margin-right: 3px; display: inline; float: right; color: rgb(77, 77, 77); font-style: italic;"+e+"'>" + iconsRight + "</span><span>"+ resultString + "</span>";
                          c[addedSuggestions].onmousedown=function(){
                               gFSuggestInstances[fieldIndex].clickSel=1;
                               var content = this.lastChild.innerHTML;
                               content = SLs.clearHTMLTags(content);
                               gFSuggestInstances[fieldIndex].setSLSInput(SLs,content,parseInt(this.id))
                               SLs.delete_SLs();
                          }
                          c[addedSuggestions].onmouseover=function(){
                              SLs.mouseSelect(this,"top");

                          }
                          c[addedSuggestions].onmouseout= function(){
                              this.className = SLs.classSelect(this.className,"selected");;
                          }
                          addedSuggestions++;
                      }
                  }
               }
              if(addedSuggestions > 0) {
                    /* var labelTopCities = document.createElement("div");
                     labelTopCities.innerHTML = '<div class="infoLabel">' + ((typeof t_topMatches != 'undefined')?t_topMatches:'Top matches') + '</div>';
                     //labelTopCities.style.textAlign = 'right';
                     labelTopCities.className = 'infoLabel';
                     gFSuggestInstances[fieldIndex].topMatches = addedSuggestions + 1;
                     SLs.container.insertBefore(labelTopCities,c[0]);   */

               }
               return addedSuggestions;
             }
             return 0;
         },getJS:function(d,f,ngramm_ext){

              var backupURL;

               // Erweiterung der NGRAMM
              if(ngramm_ext == true) {
                  gFSuggestInstances[f].params.requestURL = gFSuggestInstances[f].params.requestURL.replace(/REQ0JourneyStopsB=12/,"REQ0JourneyStopsB=50");
                  this.extendedSearch = false;
              }else{
                  gFSuggestInstances[f].params.requestURL = gFSuggestInstances[f].params.requestURL.replace(/REQ0JourneyStopsB=50/,"REQ0JourneyStopsB=12");
                  this.extendedSearch = true;
              }
              var h=gFSuggestInstances[f].params.requestURL+d+"&";

              if(typeof(this.selectPerimeterFilterParam) == "string")
                h+=this.selectPerimeterFilterParam+"&";
              if(this.selectPerimeterFilterParam!=null) {
                  this.selectPerimeterFilterParam = "";
              }
              var c=gFSuggestInstances[f].field.name.replace(/G$/,"A");
              var g=document.getElementsByName(c)[0];
              if((g!=null)&&(g.nodeName=="SELECT")){
                  var b=/REQ0JourneyStopsS0A=(\d+)&/;h=h.replace(b,"REQ0JourneyStopsS0A="+g.value+"&");
                  gFSuggestInstances[f].selectType=true
              }if(gFSuggestInstances[f].params.locType&&document.getElementById(gFSuggestInstances[f].params.locType+"_hidden")){
                  var a=document.getElementById(gFSuggestInstances[f].params.locType+"_hidden").value;
                  h=h+gFSuggestInstances[f].params.requestURL2+a+"&"
              }if(document.getElementById("hafasCallJS")!=null){
                  document.getElementsByTagName("head")[0].removeChild(document.getElementById("hafasCallJS"))
              }
              var e=document.createElement("script");
              e.type="text/javascript";
              e.src=h+"js=true&";
              e.id="hafasCallJS";
              document.getElementsByTagName("head")[0].appendChild(e)
              SLs.stopWaiting();
            },hafasurl2utf8:function(a){
             a=a.replace(/\+/g,"%20");
             a=a.replace(/%A7/g,"%C2%A7");
             a=a.replace(/%E4/g,"%C3%A4");
             a=a.replace(/%F6/g,"%C3%B6");
             a=a.replace(/%FC/g,"%C3%BC");
             a=a.replace(/%DF/g,"%C3%9F");
             a=a.replace(/%C4/g,"%C3%84");
             a=a.replace(/%D6/g,"%C3%96");
             a=a.replace(/%DC/g,"%C3%9C");
             a=a.replace(/%E9/g,"%C3%A9");
             return a
          },getCookieValue:function(d,c,b){
               if(typeof d=="undefined"||d==""){
                   return""
               }
               var e=d.search(c);
               if(e<0){
                   return""
               }
               var a=d.substr(e+c.length);
               e=a.search(b);if(e>0){
                   a=a.substr(0,e)
               }

              return decodeURIComponent(a)
          },fillWithCookieValues:function(h){
               if(typeof h.params.cookiename=="undefined" && gFSuggestInstances[fieldIndex].useTopFavorites != true){
                   return
               }
               var j=document.cookie;
               var b=h.params.cookiename;
               j=this.getCookieValue(j,b+"=",";");

               if(j=="" && gFSuggestInstances[fieldIndex].useTopFavorites != true){
                   return
               }
               j=this.getCookieValue(j,"history=",";");
               if(j=="" && gFSuggestInstances[fieldIndex].useTopFavorites != true){
                   return
               }
               j=this.hafasurl2utf8(j);
               if(!SLs.container){
                   document.getElementsByTagName("body")[0].appendChild(SLs.erzeugen(this.instance))
               }
               var k=new Array;
               var e=0;
               for(var a=1;a<=6;a++){
                   var d=this.getCookieValue(j,"Stop"+a,"&");
                   if(d!=""){
                       k[e]=new Object;k[e].text=d;e++
                   }
               }
               SLs.sls=new Object;
               SLs.sls.suggestions=new Array;
               for(a=0;a<k.length;a++){
                   SLs.sls.suggestions[a]=new Object;
                   SLs.sls.suggestions[a].id=this.getCookieValue(k[a].text,"§L=","§");
                   SLs.sls.suggestions[a].value=this.getCookieValue(k[a].text,"O=","@");
                   SLs.sls.suggestions[a].type=this.getCookieValue(k[a].text,"A=","@")
               }
               var l=new Array();
               var g="right: 0px;";
               var topcities;
               gFSuggestInstances[fieldIndex].topMatches = 0;
               //SLs.addMenu();
               if(gFSuggestInstances[fieldIndex].useTopFavorites == true && gFSuggestInstances[fieldIndex].field.value.length >= 0) {
                   topcities = this.addTopCities();
               }
               var addedSuggestions = 0;
               for(var c=0;c<SLs.sls.suggestions.length;c++){
                    if(SLs.container){
                        if((SLs.checkForMatches("substr",gFSuggestInstances[fieldIndex].field.value,SLs.sls.suggestions[c].value))){
                           var tmpSuggestion = SLs.sls.suggestions[c].value;
                           var userInput = gFSuggestInstances[fieldIndex].field.value;
                           tmpSuggestion = SLs.replaceSpecialChars(tmpSuggestion);
                           l[addedSuggestions]=SLs.container.appendChild(document.createElement("div"));
                           l[addedSuggestions].id=addedSuggestions;
                           if((typeof(historyCookieTypeString)!="undefined")&&(typeof(historyCookieTypeString[SLs.sls.suggestions[c].type])!="undefined")){
                               var f="<span style='display: block;position: absolute; background-color: #fff;"+g+"'>"+historyCookieTypeString[SLs.sls.suggestions[c].type]+"</span>"
                           }else{
                               var f=""
                           }

                           if(SLs.sls.suggestions[c].type == 4) {
                               l[addedSuggestions].className = 'poi';

                           }else if(SLs.sls.suggestions[c].type == 2){
                               l[addedSuggestions].className = 'adr';
                           }

                           l[addedSuggestions].innerHTML = f+"<span>" + this.getBoldCharacters(userInput,tmpSuggestion,0) + "</span>";
                           l[addedSuggestions].onmousedown=function(){
                               var content = this.lastChild.innerHTML;
                               content = content.replace(/<b>/g,"");
                               content = content.replace(/<\/b>/g,"");

                               gFSuggestInstances[fieldIndex].clickSel=1;
                               gFSuggestInstances[fieldIndex].setSLSInput(SLs,content,parseInt(this.id))
                               // ALter Parameter, jetzt content !!! this.lastChild.firstChild.nodeValue
                           }
                           l[addedSuggestions].onmouseover=function(){
                              SLs.mouseSelect(this,"bottom");
                           }
                           l[addedSuggestions].onmouseout= function(){
                              this.className = SLs.classSelect(this.className,"selected");
                           }
                           addedSuggestions++;
                       }

                  }else{
                      return false
                  }

              }
              if(addedSuggestions == 0) {

              }/*else{
                           var labelSuggestions = document.createElement("div");
                           labelSuggestions.innerHTML = 'Favouriten';
                           labelSuggestions.style.textAlign = 'right';
                           labelSuggestions.className = 'infoLabel';

                           SLs.container.insertBefore(labelSuggestions,l[0]);
              }*/
              if(addedSuggestions == 0 && topcities == 0 && gFSuggestInstances[fieldIndex].params.useSuggest == true){
                  /*var labelSuggestions = document.createElement("div");
                  labelSuggestions.innerHTML = (typeof t_hintNoMatches !='undefined')?t_hintNoMatches:'No top matches found. Please make use of the <br/><b>Suggest functionality</b>, by typing at least <br/><b>'+ gFSuggestInstances[fieldIndex].params.minChar + ' characters</b>!';
                  labelSuggestions.style.wordWrap = 'break-word';
                  labelSuggestions.className = 'infoLabel';
                  labelSuggestions.id = 'note';
                  SLs.container.insertBefore(labelSuggestions,null);*/
              }
              SLs.container.style.borderWidth="1px";
              SLs.container.style.zIndex="10002";
              SLs.container.style.height="auto";
              SLs.container.style.maxHeight=SLs.div_hoehe+124+"px";
              if(gFSuggestInstances[fieldIndex].field.value.length > 0) {
                  //this.addFurtherMatchesButton();
              }
              if(navigator.userAgent.toLowerCase().indexOf("msie")>-1){
                  //SLs.container.style.width=SLs.container.clientWidth+20
              }
              if(navigator.userAgent.toLowerCase().indexOf("msie")>-1&&navigator.userAgent.indexOf("7.0")<0){
                  SLs.hideSelect()
              }
              //addedSuggestions == 0
              if((gFSuggestInstances[fieldIndex].useTopFavorites != true) || (addedSuggestions == 0 && topcities <= 0)){

                  SLs.delete_SLs()
              }
          },delete_SLs:function(){
             if(document.getElementById('tooltip')!=null) {
                 document.getElementById('tooltip').style.display = 'none';
             }
             if (!blockHide) {
               if((SLs.container)&&(SLs.container.parentNode)){
                   document.getElementsByTagName("body")[0].removeChild(SLs.container);
                   //&&navigator.userAgent.indexOf("7.0")<0
                   if(navigator.userAgent.toLowerCase().indexOf("msie")>-1){
                       SLs.showSelect()
                   }
                   SLs.countList=-1;
                   SLs.container=null;
                   SLs.currentTop=0;
                   SLs.currentBottom=9
               }
               if(document.getElementById('overlayProducts')){
                    document.getElementById('overlayProducts').style.display = 'none';
               }
               if(document.getElementById('geomap')) SLs.hideGeoMap();
             }
          },checkUpdate: function(keycode){
               var cached;
               if(!SLs.cachedSuggestions) {
                   return true;
               }else{
                   SLs.stopWaiting();
                   if(cached = SLs.laden(gFSuggestInstances[fieldIndex].field.value)) {
                       SLs.sls.suggestions = cached;
                       return false;
                   }else{
                       if(typeof SLs.sls.suggestions[0] != 'undefined') {
                           var matches = SLs.checkForMatches("prefix", gFSuggestInstances[fieldIndex].field.value, SLs.sls.suggestions[0].value);
                           if(matches == false || (keycode == 8)) {  return true; }
                           else { return false; }
                       }else{
                           return true;
                       }
                   }
               }
           },checkForMatches:function(type,userInput,sugg){
            if(type == 'prefix') {
                matchedWordStart = sugg.toString().toLowerCase().indexOf(userInput.toString().toLowerCase());
                if(matchedWordStart != 0) {
                   return false;
                }else{
                    return true;
                }
            }else{
                var inputTokens = new Array();
                var prefixMatch = false;
                inputTokens = userInput.split(" ");
                    for(var j=0; j < inputTokens.length; j++) {
                       var matches = 0;
                       var checkedWords = 0;

                       if(inputTokens[j] != '' && inputTokens[j] != ' ') {
                           matchedWordStart = sugg.toString().toLowerCase().indexOf(inputTokens[j].toLowerCase());
                           if(matchedWordStart == 0 && j == 0) {
                                prefixMatch = true;
                                matches++
                           }
                           else if(matchedWordStart != -1 && j > 0) {
                               matches++;
                           }
                           checkedWords++;
                       }
                    }
                if(matches == checkedWords && prefixMatch == true) {
                    return true;
                }else{
                    return false;
                }

            }



          },getPosX:function(a){
               var b=0;if(a.offsetParent){
                   while(a.offsetParent){
                       b+=a.offsetLeft;a=a.offsetParent
                   }
               }else{
                   if(a.x){
                       b+=a.x
                   }
               }
               return b
          },getPosY:function(a){
               var b=0;
               if(a.offsetParent){
                   while(a.offsetParent){
                       b+=a.offsetTop;
                       a=a.offsetParent
                   }
               }
               else{
                   if(a.y){
                       b+=a.y
                   }
               }
               return b
          },hideSelect:function(){
               var f=document.getElementsByTagName("select");
               for(var e=0;e<f.length;e++){
                   var d=false;
                   var c=false;
                   var b=SLs.getPosX(f[e]);
                   var a=SLs.getPosY(f[e]);
                   if(SLs.pos_x<=b&&b<SLs.pos_x+SLs.container.clientWidth){
                       d=true
                   }else{
                       if(SLs.pos_x<b+f[e].clientWidth&&b+f[e].clientWidth<=SLs.pos_x+SLs.container.clientWidth){
                           d=true
                       }else{
                           if(SLs.pos_x>b&&b+f[e].clientWidth>SLs.pos_x){
                               d=true
                           }
                       }
                   }
                   if(SLs.pos_y<a&&a<SLs.pos_y+SLs.container.clientHeight){
                       c=true
                   }else{
                       if(SLs.pos_y<a+f[e].clientHeight&&a+f[e].clientHeight<SLs.pos_y+SLs.container.clientHeight){
                           c=true
                       }
                   }
                   if((d)&&(c)){
                       f[e].style.visibility="hidden"
                   }
               }
           },clearHTMLTags:function(str){
                if(typeof str != 'undefined') {
                    str = str.replace(/<b>/g,"");
                    str = str.replace(/<\/b>/g,"");
                    str = str.replace(/<B>/g,"");
                    str = str.replace(/<\/B>/g,"");
                    str = str.replace(/&amp;/g,"&");
                    return str;
                }
           },showSelect:function(){
                var b=document.getElementsByTagName("select");
                for(var a=0;a<b.length;a++){
                    if(b[a].style.visibility=="hidden"){
                        b[a].style.visibility="visible"}
                }
           },replaceSpecialChars:function(str){
                if(typeof str != 'undefined') {
                    str = str.replace(/&#252;/, "ü");
                    str = str.replace(/&#223;/, "ß");
                    str = str.replace(/&#220;/, "Ü");
                    str = str.replace(/&#228;/, "ä");
                    str = str.replace(/&#196;/, "Ä");
                    str = str.replace(/&#246;/, "ö");
                    str = str.replace(/&#214;/, "Ö");
                    str = str.replace(/&amp;/, "&");
                }
                return str;
           },getProducts:function(){
                var str = "";
                var products = new Array("ice_16x16.gif","sbahn_16x16.gif","ubahn_16x16.gif","ec_ic_16x16.gif");
                a = 1 + (products.length-1)*(Math.random());
                a = Math.round(a);
                if(typeof fsugg_products != 'undefined') {
                    str += fsugg_products;
                }
                return str;
           },classSelect:function(str,keyword){
                 if(str.length >= keyword.length) {
                     return str.substr(0,str.length - keyword.length);
                 }else{
                     return str;
                 }
           },createGeoBox:function(){
                  // Creates the div container for the map in relation to the suggestbox
                  var geomapid = 'geomap';
                  var mapcontid = 'mapcontainer';

                  effectDuration = 0.4;
                  var mapContainer = document.getElementById(geomapid);
                  if(!mapContainer) {
                            // create container
                            mapContainer = document.createElement("div");
                            mapContainer.style.position = 'absolute';
                            mapContainer.style.height = '307px';
                            mapContainer.style.width = '300px';
                            mapContainer.style.display = 'block';
                            mapContainer.style.overflow = 'hidden';
                            mapContainer.style.zIndex = '20000';
                            //mapContainer.style.opacity = 0;
                            //mapContainer.style.filters = 'Alpha(opacity=0)';
                            mapContainer.style.backgroundColor = '#F2F2F2';
                            mapContainer.id = geomapid;
                            mapContainer.style.left = SLs.getPosX(SLs.container) + parseInt(SLs.container.style.width)  + 'px';
                            mapContainer.style.top = SLs.getPosY(SLs.container) + 'px';
                            mapContainer.onmouseover = function() { blockHide=true }
                            mapContainer.onmouseout = function() { blockHide=false }
                            document.getElementsByTagName("body")[0].appendChild(mapContainer);

                            // create map headtitle
                            var mapTitle = document.createElement("div");
                            mapTitle.style.height = '15px';
                            mapTitle.style.width = '300px';
                            mapTitle.style.backgroundColor = '#5D5D5D';
                            mapTitle.style.color = '#fff';
                            mapTitle.style.fontSize = '11px';
                            mapTitle.id = 'maptitle';
                            mapContainer.appendChild(mapTitle);

                            // create map area
                            var mapArea = document.createElement("div");
                            mapArea.style.height = '292px';
                            mapArea.style.width = '300px';
                            mapArea.id = mapcontid;
                            mapContainer.appendChild(mapArea);

                           geoMap = new CPTVMap(mapcontid, {mode:"simple",coord:new CCoord({latitude:52520501,longitude:13386987}),zoom:1400});
                           geoMap.show();

                  }
                  mapContainer.style.left = SLs.getPosX(SLs.container) + parseInt(mapContainer.style.width)  + 'px';
                  if(navigator.userAgent.indexOf("MSIE")>-1 && SLs.sls.suggestions.length > 14){
                     mapContainer.style.left = parseInt(SLs.container.style.width) + 13 + 'px';
                  }
                  mapContainer.style.top = SLs.getPosY(SLs.container) + 'px';

                  return mapContainer;
           },showGeoMap:function(coordx, coordy, ptitle){
                       // create container, title and map area if not done yet
                       var mapContainer = SLs.createGeoBox();

                       // set place specific values (coords and place title) to container
                       var coordset = new CCoord({lat:coordy,lon:coordx});
                       geoMap.setZoom(1400);
                       geoMap.centerToGeo(coordset);
                       if(SLs.currLocation != null) {
                           geoMap.hideContent(SLs.currLocation);
                           geoMap.removeContent(SLs.currLocation);
                       }
                       SLs.currLocation = geoMap.createContent({
                         type: 'location',
                         coord: coordset,
                         imageurl: gImagePath + 'buttons/icon_std_red.gif',
                         imagewidth: 14,
                         imageheight: 14,
                         hotspot: {x:0, y:0}
                       });
                       geoMap.showContent(SLs.currLocation);

                       document.getElementById('maptitle').innerHTML = '<b>&nbsp;' + ((typeof t_location != 'undefined')?t_location:'Location:') + ':</b>&nbsp;<span id="maplocation" title="' + ptitle + '">' + ptitle + '</span>';

                       // move container if suggestbox moved
                       mapContainer.style.left = (SLs.getPosX(SLs.container)+ parseInt(SLs.container.style.width)) +'px';
                       if(navigator.userAgent.indexOf("MSIE")>-1 && SLs.sls.suggestions.length > 14){
                          mapContainer.style.left = parseInt(SLs.container.style.width) + 13 + 'px';
                       }
                       mapContainer.style.top = SLs.getPosY(SLs.container) + 'px';
                       // animate incoming box
                       //SLs.fadeIn('mapcontainer');	// fade opacity
                       //if (mapContainer.style.display == 'none') mapContainer.style.width = '0px';
                       mapContainer.style.display = 'block';	// blind left
           },hideGeoMap:function(){
                       // Hides the div container
                       //SLs.fadeOut('mapcontainer');	// fade opacity
                       document.getElementById('geomap').style.display = 'none';	// blind left
           },getProductIcon:function(prodclass,name){
                var productNames = new Array('ICE', 'IC/EC', 'IR/D', 'IRE/RE/RB','S-Bahn','Bus','Schiff','U-Bahn','Bahn');
                if(prodclass != '0') {
                    var num = parseInt(prodclass);
                    var bits = num.toString(2);
                    var pclass = -1;
                    var j=0;
                    var title = '';
                    for(var i=bits.length;i>=0;i--) {
                        if(bits.substr(i,1)=='1') {
                            if(j <= pclass || pclass == -1) {
                                pclass = j;
                            }
                            title += productNames[j-1] + ' ';
                        }
                        j++;
                    }
                    var imageProduct = document.createElement("img");
                    imageProduct.height = '14';
                    imageProduct.width = '14';
                    imageProduct.style.width = '14px';
                    imageProduct.style.height = '14px';
                    imageProduct.src = product_icons[pclass-1];
                    imageProduct.onmousemove = function(evt){

                         if(document.getElementById('tooltip')==null) {
                            var tooltip = document.body.appendChild(document.createElement("div"));
                            tooltip.style.width = 'auto';
                            tooltip.id = 'tooltip';
                            tooltip.style.height = 'auto';
                            tooltip.style.position = 'absolute';
                            tooltip.style.zIndex = '20000000';
                            tooltip.style.background = '#efefef';
                            tooltip.style.border = '1px solid #333333';
                            tooltip.style.padding = '3px';
                            tooltip.className = 'greyBox';
                            tooltip.style.display = 'none';
                            tooltip.style.opacity = '0';
                         }
                         if(typeof evt == 'undefined') {
                             SLs.createTooltip(window.event,title,name,bits);
                         }else{
                             SLs.createTooltip(evt,title,name,bits);
                         }

                    }
                    imageProduct.onmouseout = function(evt){
                         document.getElementById('tooltip').style.opacity = '0';
                         document.getElementById('tooltip').style.filter = 'alpha(opacity=0)';
                    }
                    imageProduct.onmouseover = function(evt){
                        if(document.getElementById('tooltip')) {
                           document.getElementById('tooltip').style.opacity = '0';
                           document.getElementById('tooltip').style.filter = 'alpha(opacity=0)';
                           SLs.fadeIn('tooltip');
                        }
                    }
                    return imageProduct;
                    //return '<img id=' src="' + product_icons[pclass-1] + '" height="14" width="14" title="Produktklassen:' + title + '"/>';
                }else{
                    var imageProduct = document.createElement("div");
                    imageProduct.src = '';
                    imageProduct.height = '14';
                    imageProduct.width = '14';
                    return '<img src="" height="14" width="14"/>';
                }
                return '';
           },getWeightIcon:function(weight){
                var image = '';
                if(weight < 200)
                    image = 'icons/icon_weight_01.gif';
                else if(weight >= 200 && weight < 5000) {
                    image = 'icons/icon_weight_03.gif';
                }else if(weight >=5000 && weight < 10000){
                    image = 'icons/icon_weight_05.gif';
                }else if(weight >=10000 && weight < 15000){
                    image = 'icons/icon_weight_07.gif';
                }else{
                    image = 'icons/icon_weight_08.gif';
                }
                return '<span><img title="' + weight +  ' ' + ((typeof t_connectionsPerYear != 'undefined')?t_connectionsPerYear:'rides per year') + '" src="' + gImagePath + image + '" height="14" width="14"/></span>';
           },createTooltip:function(evt,title,name,bits){
                var productNames = new Array('ICE', 'IC/EC', 'IR/D', 'IRE/RE/RB','S-Bahn','Bus','Schiff','U-Bahn','Bahn');
                document.getElementById('tooltip').style.left = evt.clientX + 18 + 'px';
                document.getElementById('tooltip').style.top = evt.clientY + 'px';

                var content = '';
                for(var i=bits.length; i >= 0 ; i--) {
                    if(bits.substr(i,1) == '1') {
                        content += '<li style="text-align:center;width:60px;list-style-type:none;float:left"><img src="'+ product_icons[bits.length - i - 1] + '"/><br/>' + productNames[bits.length - i -1] + '</li>';
                    }
                }
                document.getElementById('tooltip').innerHTML = ((typeof t_meansOfTransport != 'undefined')?t_meansOfTransport:'means of transport') + ' <b>' + name + '</b>:<br/><ul style="margin-left:-40px;">' + content + '</ul>';
                document.getElementById('tooltip').style.display = 'block';
           },fadeIn:function(elemid){
                       // Fades Opacity
                       elem = document.getElementById(elemid);
                       elem.style.display = 'block';
                       elem.style.opacity = '1.0';
                       var oldOpac = parseFloat(elem.style.opacity)*100;
                       var opac = oldOpac + 4;
                       if (opac > 100) opac = 100;

                       elem.style.opacity = (opac/100);
                       elem.style.filter = 'Alpha(opacity=' + opac + ')';

                       if (opac < 100) window.setTimeout("SLs.fadeIn('" + elemid + "');", 20);
           },fadeOut:function(elemid){
                       // Fades Opacity
                       elem = document.getElementById(elemid);

                       var oldOpac = parseFloat(elem.style.opacity)*100;
                       var opac = oldOpac - 4;
                       if (opac < 0) opac = 0;

                       elem.style.opacity = (opac/100);
                       elem.style.filters = 'Alpha(opacity=' + opac + ')';

                       if (opac > 0) window.setTimeout("SLs.fadeOut('" + elemid + "');", 20);
                       else elem.style.display = 'none';
           },selPerimParams:function(checkbox){
                if(checkbox.checked){
                    var param = "selectPerimeterFilter;"
                        param += Map.getCenter().lon+";";
                        param += Map.getCenter().lat+";";
                        var zoom = Map.getZoom();
                        zoom = Math.round(zoom/2000);
                        if(zoom == 0)
                          zoom= 1;
                          param += zoom+";";
                          checkbox.value = param;
                          this.selectPerimeterFilterParam = checkbox.name+"="+param;

                }
                else
                    this.selectPerimeterFilterParam = "";
           }

};






