if( typeof gCMENUE == 'undefined' ){
  var gCMENUE = 'defined';
  
  var gCKachelDrawing = false;
  var gCKachelInstanceCounter = 0;
  var gCKachelInstances = new Array;
  var CKachel=Class.create();
  CKachel.prototype={
    initialize:function(param){
      gCKachelInstances[gCKachelInstanceCounter]=this;
      this.instance=gCKachelInstanceCounter++;
      this.param=param;
      this.loaded=false;
      this.visible=false;
    },
    draw:function(){
      if(this.visible)return;
      if(!this.loaded){
        this.load();
      }else{
        this.drawKachel(0);
      }
    },
    hide:function(){
      if(typeof this.locations=='undefined') return;
      var m=this.param.set.father.param.menue.map;
      for(var i=0;i<this.locations.length;i++){
        for(var p=0;p<this.locations[i].length;p++){
          m.hideContent(this.locations[i][p]);
          m.removeContent(this.locations[i][p]);
        }
        delete this.locations[i];
      }
      delete this.locations;
      this.visible=false;
    },
    //private
    drawKachel:function(trycount){
      if(!this.param.set.visible||this.visible)return;
      if(trycount>20){
        alert("Trycount reached");
        return;
      }
      this.visible=true;
      this.locations=new Array;
      var l=0;
      var m=this.param.set.father.param.menue.map;
      if(typeof this.data=='undefined')return;
      for(var i=0;i<this.data.polyline.length;i++){
        var q=this.data.polyline[i];
        if(typeof q.coords=='undefined')return;
        for(var c=0;c<q.coords.length;c++){
          if(typeof this.param.set.names.get(q.name)=='undefined'){
            this.param.set.names.set(q.name,true);
            var par=this.param.set.father.getPolyPar(q.typecode);
            this.locations[l]=new Array;
            for(var p=0;p<par.length;p++){
              par[p].coords=q.coords;
              this.locations[l][p] = m.createContent(par[p]);
              m.showContent(this.locations[l][p]);
            }
            l++;
          }
        }
      }
    },
    load:function(){
      var url = this.param.set.father.param.url;
      url+="tpl="+this.param.set.param.tiledir+"/"+this.param.set.param.set+"/"+this.param.x+"/"+this.param.y;
      if(url!=null){
        var request = new Ajax.Request(
          url,
          {
            method: 'post',
            onComplete: this.handleLoad.bind(this)
          }
        );
      }
    },
    handleLoad:function(json){
      this.loaded=true;
      this.data = eval('(' + json.responseText + ')');
      if(this.param.set.visible)
        this.drawKachel(0);
    }
  };
    
  var CKachelSet=Class.create();
  CKachelSet.prototype={
    initialize:function(father,param){
      this.param=param;
      this.father=father;
      this.visible=false;
      this.names=new Hash;
      this.data=new Array(this.param.countx);
      for(var x=0;x<this.param.countx;x++){
        this.data[x]=new Array(this.param.county);
        for(var y=0;y<this.param.county;y++){
          this.data[x][y]=new CKachel({set:this,
                                          x:x,
                                          y:y});
        }
      }
    },
    hide:function(){
      this.visible=false;
      for(var x=0;x<this.param.countx;x++){
        for(var y=0;y<this.param.county;y++){
          this.data[x][y].hide();
        }
      }
      delete this.names;
      this.names=new Hash;
    },
    draw:function(minx,miny,maxx,maxy){
      this.visible=true;
      var xdiff=maxx-minx;
      var ydiff=maxy-miny;
      var startx=Math.max(0,parseInt((minx-this.param.minx)/this.param.tilesizex));
      var starty=Math.max(0,parseInt((miny-this.param.miny)/this.param.tilesizey));
      var endx=Math.min(this.param.countx-1,parseInt((maxx-this.param.minx)/this.param.tilesizex));
      var endy=Math.min(this.param.county-1,parseInt((maxy-this.param.miny)/this.param.tilesizey));
      for(var x=startx;x<=endx;x++){
        for(var y=starty;y<=endy;y++){
          this.data[x][y].draw();
        }
      }
    }
  };

  var CKachelHash=Class.create();
  CKachelHash.prototype={
    initialize:function(param){
      this.param=param;
      if(typeof this.param.precision=='undefined')this.param.precision=1.0;
      this.usetypecode=false;
      if(typeof this.param.typecodepolyparams!='undefined')this.usetypecode=true;
      this.sets=new Hash;
      for(var i=0;i<10;i++){
        if(typeof this.param.kacheln[i]!='undefined')
          this.sets.set(i,new CKachelSet(this, this.param.kacheln[i]));
      }
      this.currentSet=-1;
    },
    getPolyPar:function(typecode){
      if(this.usetypecode)return this.param.typecodepolyparams.get(typecode);
      return this.param.polyparams;
    },
    checkSet:function(minx,miny,maxx,maxy,pair){
      if(parseInt(pair.key)>this.newkachelset){
        if(pair.value.param.tilesizex*this.param.precision>maxx-minx&&
           pair.value.param.tilesizey*this.param.precision>maxy-miny){
          this.newkachelset=parseInt(pair.key);
        }
      }
    },
    setKachelSet:function(minx,miny,maxx,maxy){
      this.newkachelset = -1;
      this.sets.each(this.checkSet.bind(this,minx,miny,maxx,maxy));
      if(this.currentSet!=this.newkachelset){
        this.hideKachelSet(this.currentSet);
        this.currentSet=this.newkachelset;
      }
    },
    hideKachelSet:function(kachelset){
      if(typeof this.sets.get(kachelset)=='undefined') return;
      this.sets.get(kachelset).hide();
    },
    hide:function(){
      this.hideKachelSet(this.currentSet);
    },
    draw:function(minx,miny,maxx,maxy){
      if(typeof this.sets.get(this.currentSet)=='undefined') return;
      this.sets.get(this.currentSet).draw(minx,miny,maxx,maxy);
    }
  };

  var gCMenueInstanceCounter = 0;
  var gCMenueInstances = new Array;
  var CMenue = Class.create();
  CMenue.prototype = Object.extend(new AJSMapBaseClass(), {
    localurl : gJSMapImagePath+"poimenue/",
    initialize: function( param ) {
      gCMenueInstances[gCMenueInstanceCounter]=this;
      this.instance=gCMenueInstanceCounter++;
      if(typeof param.divname!='undefined') 
        this.div=$(param.divname);
      this.param=param;
      this.divname=param.divname;
      this.showing=false;
      this.row = new Array;
      this.par2icon = new Hash;
      this.map=null;
      this.kachelhash=new Array;
      if( typeof param.map != 'undefined' ){
        this.map=param.map;
        this.map.setOnChange(this.cbOnChange.bind(this));
      }
      if(typeof this.div!='undefined') 
        this.create();
    },
    setMap: function(cm){
      this.map=cm;
      this.map.setOnChange(this.cbOnChange.bind(this));
    },
    setDiv: function(divname){
      this.divname=divname;
      this.div=$(divname);
      this.create();
    },
    setHafasMaps: function(hm){
      this.param.HafasMaps=hm;
    },
    cbHoverRow: function(sr){
      for(var r=0;r<this.row.length;r++){
        if( sr == r ){
          switch (this.row[r].tr.className) {
          case "select": this.row[r].tr.className="hoverselect"; break;
          case "": this.row[r].tr.className="hover"; break;
          }
        }
        else{
          switch (this.row[r].tr.className) {
          case "hoverselect": this.row[r].tr.className="select"; break;
          case "hover": this.row[r].tr.className=""; break;
          }
        }
      }
    },
    getUrl: function(r){
      if(this.map!=null){
        if(typeof this.row[r].param.contentsearchmodus=='undefined')
          this.row[r].param.contentsearchmodus=this.param.contentsearchmodus;
        if(this.row[r].param.contentsearchmodus=='centerbased'){
          var c=this.map.getCenter();
          var url =
            this.row[r].requrl+
            'look_x='+c.getLon()+
            '&look_y='+c.getLat()+
            '&look_maxdist='+this.map.getZoom()+
            '&';
          return url;
        }else{
          var bb=this.map.getBoundingBox();
          var url =
            this.row[r].requrl+
            'look_minx='+bb.sw.getLon()+
            '&look_maxx='+bb.ne.getLon()+
            '&look_miny='+bb.sw.getLat()+
            '&look_maxy='+bb.ne.getLat()+
            '&';
          return url;
        }
      }
      return null;
    },
    updateRow: function(r){
      var currentzoom=this.map.getZoom();
      if(this.row[r].maxzoom<currentzoom){
        this.row[r].tr.className="disabled";
        this.row[r].radioimg.src=this.localurl+"checkbox_disabled.gif";
        if(this.row[r].param.kachel)
          this.hideKacheln(r);
        else
          this.clearLocations(r);
      }
      else if(this.row[r].tr.className=="disabled"){
        this.row[r].tr.className="";
        this.row[r].radioimg.src=this.localurl+"checkbox_0.gif";
      }
      else if(this.row[r].tr.className=="select" ||
              this.row[r].tr.className=="wait" ){
        this.row[r].tr.className="wait";
        this.row[r].radioimg.src=this.localurl+"checkbox_wait.gif";
        if(this.row[r].param.kachel){
          this.showKacheln(r);
        }else{
          this.clearLocations(r);
          this.performAjaxRequest(r);
        }
      }
    },
    cbOnChange: function(){
      for(var r=0;r<this.row.length;r++){
        if(!(typeof this.row[r].param.disableupdate!='undefined'&&this.row[r].param.disableupdate))
          this.updateRow(r);
      }
    },
    cbChangeDate: function(r){
      var f=this.parseDate(this.row[r].frominput.value,0);
      var u=this.parseDate(this.row[r].untilinput.value,24);
      if(f!=null&&u!=null){
        this.row[r].from = f;
        this.row[r].until = u;
        for(var cri=0;cri<this.row[r].childrows.length;cri++){
          var cr = this.row[r].childrows[cri];
          this.row[cr].from=f;
          this.row[cr].until=u;
          this.updateRow(cr);
        }
      }
    },
    showKacheln:function(r){
      if(typeof this.kachelhash[r]=='undefined'){
        this.kachelhash[r]=new CKachelHash({menue:this,
                                               url:this.row[r].param.requrl,
                                               kacheln:this.row[r].param.kacheln,
                                               precision:this.row[r].param.precision,
                                               typecodepolyparams:this.row[r].param.typecodepolyparams,
                                               polyparams:this.row[r].param.polyparams});
      }
      var bb=this.map.getBoundingBox();
      this.kachelhash[r].setKachelSet(bb.sw.getLon(),bb.sw.getLat(),bb.ne.getLon(),bb.ne.getLat());
      this.kachelhash[r].draw(bb.sw.getLon(),bb.sw.getLat(),bb.ne.getLon(),bb.ne.getLat());
      this.row[r].radioimg.src=this.localurl+"checkbox_1.gif";
      this.row[r].tr.className="select";
    },
    hideKacheln:function(r){
      if(typeof this.kachelhash[r]!='undefined'){
        this.kachelhash[r].hide();
      }
    },
    performAjaxRequest:function(r){
      var url = this.getUrl(r);
      if(url!=null){
        var request = new Ajax.Request(
          this.getUrl(r),
          {
            method: 'post',
            onComplete: this.handleAjaxResult.bind(this,r)
          }
        );
      }
    },
    cbSelect: function(r){
      if(this.row[r].tr.className!="select" &&
         this.row[r].tr.className!="wait" &&
         this.row[r].tr.className!="disabled" &&
         this.row[r].tr.className!="hoverselect" )
      {
        this.row[r].tr.className="wait";
        this.row[r].radioimg.src=this.localurl+"checkbox_wait.gif";
        if(this.row[r].param.kachel){
          this.showKacheln(r);
        }else{
          this.performAjaxRequest(r);
        }
      }
      else if(this.row[r].tr.className!="wait" &&
              this.row[r].tr.className!="disabled" )
      {
        this.row[r].t2.innerHTML=this.row[r].name;
        this.row[r].tr.className="";
        this.row[r].radioimg.src=this.localurl+"checkbox_0.gif";
        if(this.row[r].param.kachel){
          this.hideKacheln(r);
        }else{
          this.clearLocations(r);
        }
      }
    },
    clearLocations: function(r){
      var row=this.row[r];
      for(var i=0;i<row.locations.length;i++){
        if(typeof row.locations[i]!='undefined'){
          this.map.hideContent(row.locations[i]);
          this.map.removeContent(row.locations[i]);
          delete row.locations[i];
        }
      }
      delete row.locations;
      row.locations = new Array;
    },
    locparam: {
      type: "location",
      text: "POI",
      imagewidth: 16,
      imageheight: 16,
      shadowwidth: 20,
      shadowheight: 20,
      hotspot:{x:8,y:8}
    },
    locparamtrain: {
      type: "location",
      text: "Train",
      imagewidth: 16,
      imageheight: 16,
      hotspot:{x:8,y:8}
    },
    locparamstop: {
      type: "location",
      text: "Stop",
      imagewidth: 12,
      imageheight: 12,
      shadowwidth: 14,
      shadowheight: 14,
      hotspot:{x:6,y:6}
    },
    locparamhim: {
      type: "location",
      text: "HIM",
      imagewidth: 17,
      imageheight: 17,
      shadowwidth: 20,
      shadowheight: 20,
      hotspot:{x:8,y:8}
    },
    parseDate: function(datestring, hh){
      var s=datestring.split('.');
      if(s.length==3){
        var yy=s[2];
        var mm=s[1]-1;
        var dd=s[0];
        return new Date(yy,mm,dd,hh,0,0);
      }
      return null;
    },
    parseDateTime: function(datetimestring){
      var dt=datetimestring.split(' ');
      if(dt.length==2){
        var d=dt[0].split('.');
        if(d.length==3){
          var yy=d[2];
          var mm=d[1]-1;
          var dd=d[0];
          var t=dt[1].split(':');
          if(t.length==3){
            var hh=t[0];
            var mi=t[1];
            var ss=t[2];
            return new Date(yy,mm,dd,hh,mi,ss);
          }
          return new Date(yy,mm,dd,0,0,0);
        }
      }
      return null;
    },
    handlePoiTmcResult:function(r,poi,i){
      var d0=this.parseDate(poi.tmc_STA_DATE,12);
      if(d0!=null){
        if( typeof this.row[r].from!='undefined'){
          if( d0 < this.row[r].from ){
            return;
          }
        }
      }
      var d1=this.parseDate(poi.tmc_STA_DATE,12);
      if(d1!=null){
        if( typeof this.row[r].until!='undefined'){
          if( d1 > this.row[r].until ){
            return;
          }
        }
      }
      var p=this.getLocationParams(this.locparam,poi.name,r,poi.x,poi.y);
      p.info="<div class='infobox' style='border:1px solid #ccc'>"+
             "<div class='infoboxtitle'>"+poi.tmc_DOBTEXT+"</div>"+
             "<div class='infoboxtext'><strong>"+poi.tmc_PHR+"</strong></div>";
      if(poi.tmc_DST!="")
        p.info+="<div class='infoboxtext'>"+poi.tmc_DST+"</div>";
      if(poi.tmc_PN!=""&&poi.tmc_SN!="")
        p.info+="<div class='infoboxtext'>zwischen <strong>"+poi.tmc_PN+
                "</strong> und <strong>"+poi.tmc_SN+"</strong></div>";
      else if(poi.tmc_PN!="")
        p.info+="<div class='infoboxtext'><strong>"+poi.tmc_PN+"</strong></div>";
      if(poi.tmc_STA_DATE!="")
        p.info+="<div class='infoboxtext'>Start: "+poi.tmc_STA_DATE
                +", "+poi.tmc_STA_TIME+"</div>";
      if(poi.tmc_INP_DATE!="")
        p.info+="<div class='infoboxtext'><small>(Datenstand: "+poi.tmc_INP_DATE
                +", "+poi.tmc_INP_TIME+")</small></div>";
      p.info+="</div>"
      if( this.map.getZoom()<500 )p.flexible=true;
      this.row[r].locations[i] = this.map.createContent(p);
      this.map.showContent( this.row[r].locations[i] );
      this.locationcounter++;
    },
    getLocationParams: function(template,text,r,x,y){
      var p=this.clone_contentparams(template);
      p.text=text;
      p.imageurl= this.row[r].icon;
      if(typeof this.row[r].param.iconwidth!='undefined'){
        p.imagewidth=this.row[r].param.iconwidth;
        p.shadowwidth=this.row[r].param.iconwidth+3;
      }
      if(typeof this.row[r].param.iconheight!='undefined'){
        p.imageheight=this.row[r].param.iconheight;
        p.shadowheight=this.row[r].param.iconheight+3;
      }
      if(typeof this.row[r].param.noshadow=='undefined'||this.row[r].param.noshadow!="yes"){
        if(typeof this.row[r].param.shadow!='undefined')
          p.shadowurl=this.localurl + this.row[r].param.shadow;
        else
          p.shadowurl= this.localurl + "shadow.png";
      }
      p.coord=new CCoord({lon:x,lat:y});
      return p;
    },
    handlePoiResult:function(r,pois){
      this.locationcounter=0;
      for(var i=0;i<pois.length;i++){
        if(this.locationcounter>200)return;
        var po=pois[i];
        po.name=this.decode(po.name);
        if(typeof po.tmc!='undefined')
          this.handlePoiTmcResult(r,po,i);
        else{
          var p=this.getLocationParams(this.locparam,po.name,r,po.x,po.y);
          if(typeof this.row[r].param.infotext!='undefined'){
            p.infotitle=po.name;
            p.infocontent="";
            p.infocontent=this.row[r].param.infotext(this.map,po.extId,po.puic,po.name,po.x,po.y);
          }else{
            if(typeof po.cam!='undefined')
            {
              p.info="<div>"+
                     "<div class='infoboxtitlecam'>"+po.cam_n+"</div>"+
                     "<div class='cam'><iframe class='cam' src='"+po.cam_url_hd+"'"+
                     "<a href='"+po.cam_url_hd+"'>"+po.cam_n+"</a>"+
                     "</iframe></div></div>";
            }
            else if(typeof po.tunnel!='undefined')
            {
              p.info="<div class='infoboxtitle'>"+po.tunnel_n+"</div>"+
                     "<div class='infoboxtext'>"+po.tunnel_str+"</div>";
            }
            else if(typeof po.rs!='undefined')
            {
              p.info="<div class='infoboxtitle'>"+po.rs_n+"</div>"+
                     "<div class='infoboxtext'>"+po.rs_eir+"</div>"+
                     "<div class='infoboxtext'>Betreiber "+po.rs_rhb+"</div>"+
                     "<div class='infoboxtext'>Hotel: "+po.rs_hotel+"</div>"+
                     "<div class='infoboxtext'>Schnellrestaurant: "+po.rs_ffb+"</div>"+
                     "<div class='infoboxtext'><a target='info' href='"+po.rs_url+"'>"+
                       "Zusätzliche Informationen"+"</a></div>"
                     ;
            }
            else if(typeof po.rp!='undefined')
            {
              p.info="<div class='infoboxtitle'>"+po.rp_n+"</div>"+
                     "<div class='infoboxtext'>"+po.rp_str+"</div>"+
                     "<div class='infoboxtext'>"+po.rp_r+"</div>"+
                     "<div class='infoboxtext'>Abstellplätze</div>"+
                     "<div class='infoboxtext'>PKW: "+po.rp_asp+"</div>"+
                     (po.rp_asc!=""?"<div class='infoboxtext'>Caravan: "+po.rp_asc+"</div>":"")+
                     (po.rp_asb!=""?"<div class='infoboxtext'>Bus: "+po.rp_asb+"</div>":"")+
                     (po.rp_asl!=""?"<div class='infoboxtext'>LKW: "+po.rp_asl+"</div>":"")+
                     "<div class='infoboxtext'><a target='info' href='"+po.rp_url+"'>"+
                       "Zusätzliche Informationen"+"</a></div>"
                     ;
            }
            else
            {
              var zid="A=4"
                     +"@O="+po.name
                     +"@U="+po.puic
                     +"@p="+po.pts
                     +"@L="+po.extId
                     +"@X="+po.x
                     +"@Y="+po.y;
              p.info="<div class='infoboxtitle'>"+po.name+"</div>";
              if(this.param.input){
                p.info+="<div class='infoboxtext'>"
                  +"Als "
                  +"<a onclick='"
                  +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"start\",{text:\""+po.name+"\"});"
                  +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"startid\",{text:\""+zid+"\"})"
                  +"'>"
                  +"Start</a>/"
                  +"<a onclick='"
                  +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"dest\",{text:\""+po.name+"\"});"
                  +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"destid\",{text:\""+zid+"\"})"
                  +"'>"
                  +"Ziel</a> "
                  +"in die Auskunft übernehmen</div>";
              }
              if(typeof this.param.HafasMaps!='undefined'){
                this.param.HafasMaps.registerDestination(zid);
              }
            }
          }
          if( this.map.getZoom()<500 )p.flexible=true;
          this.row[r].locations[i] = this.map.createContent(p);
          this.map.showContent( this.row[r].locations[i] );
          this.locationcounter++;
        }
      }
    },
    handleHimResult:function(r,him){
      this.locationcounter=0;
      for(var i=0;i<him.length;i++){
        if(this.locationcounter>50)return;
        var h=him[i];
        h.name=this.decode(h.name);
        var d0=this.parseDateTime(h.end);
        if(d0!=null){
          if( typeof this.row[r].from!='undefined'){
            if( d0 < this.row[r].from ){
              continue;
            }
          }
        }
        var d1=this.parseDateTime(h.begin);
        if(d1!=null){
          if( typeof this.row[r].until!='undefined'){
            if( d1 > this.row[r].until ){
              continue;
            }
          }
        }
        var p=this.getLocationParams(this.locparamhim,h.header,r,h.x,h.y);
        p.info="<div class='infoboxtitle'>"+h.header+"</div>";
        if(h.deploc==h.arrloc)
          p.info+="<div class='infoboxtext'>"+h.header+" in "+h.deploc+".</div>";
        else
          p.info+="<div class='infoboxtext'>"+h.header+" zwischen "+h.deploc+" und "+h.arrloc+".</div>";
        p.info+="<div class='infoboxtext'>"+h.name+"</div>"+
                "<div class='infoboxtext'>"+h.text+"</div>"+
                "<div class='infoboxtext'>Beginn: "+h.begin+"</div>"+
                "<div class='infoboxtext'>Ende: "+h.end+"</div>";
        p.flexible=true;
        this.row[r].locations[i] = this.map.createContent(p);
        this.map.showContent( this.row[r].locations[i] );
        this.locationcounter++;
      }
    },
    handleStopResult:function(r,stops,prods){
      //Produktfilter nur für Flughäfen nutzen
      if(prods!=1)prods=8190;
      var prodFilter="";
      for(var z=4096;z>=1;z/=2){
        if(prods>=z){
          prods-=z;
          prodFilter="1"+prodFilter;
        }
        else
          prodFilter="0"+prodFilter;
      }
      for(var i=0;i<stops.length;i++){
        var s=stops[i];
        s.name=this.decode(s.name);
        var p=this.getLocationParams(this.locparamstop,s.name,r,s.x,s.y);
        
        if(typeof this.row[r].param.infotext!='undefined'){
          p.infotitle=s.name;
          p.infocontent=this.row[r].param.infotext(this.map,s.extId,s.puic,s.name,s.x,s.y);
        }else{
          var zid="A=4"
                 +"@O="+s.name
                 +"@U="+s.puic
                 +"@L="+s.extId
                 +"@X="+s.x
                 +"@Y="+s.y;
          p.info="<div class='infoboxtitle'>"+s.name+"</div>";
          if(this.param.input){
            p.info+="<div class='infoboxtext'>"
              +"Haltestelle als "
              +"<a onclick='"
              +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"start\",{text:\""+s.name+"\"});"
              +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"startid\",{text:\""+zid+"\"})"
              +"'>"
              +"Start</a>/"
              +"<a onclick='"
              +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"dest\",{text:\""+s.name+"\"});"
              +"gCExistingInputInstances["+this.param.input.instance+"].setValue(\"destid\",{text:\""+zid+"\"})"
              +"'>"
              +"Ziel</a> "
              +"in die Auskunft übernehmen</div>";
          }
        }
        if( this.map.getZoom()<500 )p.flexible=true;
        this.row[r].locations[i] = this.map.createContent(p);
        this.map.showContent( this.row[r].locations[i] );
      }
    },
    handleEventResult:function(r,event){
      for(var i=0;i<event.length;i++){
        var e=event[i];
        e.name=this.decode(e.name);
        if( e.x!="" && e.y!="" ){
          var p=this.getLocationParams(this.locparam,e.name,r,e.x,e.y);
          p.info="<div class='infoboxtitle'>"+e.name+"</div>";
          p.info+="<div class='infoboxtext'>"+e.description+"</div>";
          if(e.url!="")
            p.info+="<div class='infoboxtext'><a target='info' href='"+e.url+"'>"+
                     e.linktext+"</a></div>";
          if(typeof e.query!='undefined' && e.query!="")
            p.info+="<div class='infoboxtext'><a href='"+e.query+"'>"+
                     "Als Ziel in die Auskunft übernehmen</a></div>";
          if( this.map.getZoom()<500 )p.flexible=true;
          this.row[r].locations[i] = this.map.createContent(p);
          this.map.showContent( this.row[r].locations[i] );
        }
      }
    },
    handleTrainResult:function(r,t){
      var i;
      for(i=0;i<this.row[r].locations.length;i++){
        this.map.hideContent( this.row[r].locations[i] );
        this.map.removeContent( this.row[r].locations[i] );
      }
      this.row[r].locations=new Array;
      for(i=0;i<t.length;i++){
        var e=t[i];
        e.name=this.decode(e.name);
        if( e.x!="" && e.y!="" ){
          var p=this.getLocationParams(this.locparamtrain,e.name,r,e.x,e.y);
          p.info="<div class='infoboxtitle'>"+e.name+"</div>";
          this.row[r].locations[i] = this.map.createContent(p);
          this.map.showContent( this.row[r].locations[i] );
        }
      }
    },
    handleAjaxResult: function(r,json){
      if(this.row[r].tr.className=="wait"||
         (typeof this.row[r].update!='undefined'&&this.row[r].tr.className=="select")){
        if(typeof json.responseText!='undefined'&&json.responseText!=null&&json.responseText!="") {
          var res = eval('(' + json.responseText + ')');
          if(res.error!="0")
            this.row[r].t2.innerHTML=this.row[r].name+" ("+res.error+")";
          else
            this.row[r].t2.innerHTML=this.row[r].name;
          if(typeof res.pois!='undefined')
            this.handlePoiResult(r,res.pois);
          if(typeof res.him!='undefined')
            this.handleHimResult(r,res.him);
          if(typeof res.stops!='undefined')
            this.handleStopResult(r,res.stops,res.prods);
          if(typeof res.event!='undefined')
            this.handleEventResult(r,res.event);
          if(typeof res.trains!='undefined')
            this.handleTrainResult(r,res.trains);
        }
        this.row[r].radioimg.src=this.localurl+"checkbox_1.gif";
        this.row[r].tr.className="select";
        if(typeof this.row[r].update!='undefined'){
          if(typeof this.row[r].AnimationTimeOut!='undefiend') window.clearTimeout(this.row[r].AnimationTimeOut);
          this.row[r].AnimationTimeOut=
               window.setTimeout("gCMenueInstances["+
                                 this.instance+
                                 "].performAjaxRequest("+r+")",this.row[r].update*1000);
        }
      }
    },
    defineTableData: function(){
      if(typeof this.param.classes == 'undefined'){
        alert('No POI-Classes given');
        return false;
      }
      this.parentrow=new Array;
      for( var i=0;i<this.param.classes.length;i++){
        var c=this.param.classes[i];
        this.row[i] = new Object;
        this.row[i].rowtype = c.rowtype;
        this.row[i].param = c;
        if(c.rowtype=='check'){
          this.row[i].locations = new Array;
          this.row[i].name=c.name;
          this.row[i].maxzoom=c.maxzoom;
          this.row[i].type=c.type;
          this.row[i].update=c.update;
          this.row[i].registerat=c.registerat;
          if(typeof c.icon!='undefined')
            this.row[i].icon=this.localurl+c.icon;
          else
            this.row[i].icon=c.absicon;
          this.row[i].requrl=c.requrl;
        }
        else if(c.rowtype=='title'){
          this.row[i].name=c.name;
          if(typeof c.icon!='undefined')
            this.row[i].icon=this.localurl+c.icon;
          else if(typeof c.absicon!='undefined')
            this.row[i].icon=c.absicon;
        }
        else if(c.rowtype=='subtitle'){
          this.row[i].name=c.name;
          if(typeof c.icon!='undefined')
            this.row[i].icon=this.localurl+c.icon;
          else if(typeof c.absicon!='undefined')
            this.row[i].icon=c.absicon;
        }
        else if(c.rowtype=='line'){
        }
        else if(c.rowtype=='dateperiod'){
          if(typeof c.id!='undefined'){
            this.row[i].childrows = new Array;
            this.parentrow[c.id]=i;
          }
        }
      }
      for(var r=0;r<this.row.length;r++){
        if(typeof this.row[r].registerat!='undefined'){
          for(var pr=0;pr<this.row[r].registerat.length;pr++){
            this.row[this.parentrow[this.row[r].registerat[pr]]].childrows.push(r);
          }
        }
      }
      return true;
    },
    createTable: function(){
      var currentzoom=this.map.getZoom();
      this.table=this.addElem("table",this.divname+"_table",{display:"block"},this.div);
      this.table.cellspacing=0;
      this.table.border=0;
      this.table.className="CMenue";
      for(var r=0;r<this.row.length;r++){
        this.row[r].tr=this.addElem("tr",this.divname+"_tr_"+r,{},this.table);
        if(this.row[r].rowtype=='title'||this.row[r].rowtype=='subtitle'){
          if(typeof this.row[r].icon!='undefined'){
            var t0=this.addElem("td",this.divname+"_row_"+r+"td0",{},this.row[r].tr);
            var t1=this.addElem("td",this.divname+"_row_"+r+"td1",{},this.row[r].tr);
            var t0img=this.addElem("img",this.divname+"_img_"+r+"td0",{},t0);
            t0img.src=this.row[r].icon;
            t1.setAttribute('colspan',2);
            t1.innerHTML=this.row[r].name;
            this.row[r].tr.className=this.row[r].rowtype;
          }else{
            var t0=this.addElem("td",this.divname+"_row_"+r+"td0",{},this.row[r].tr);
            t0.setAttribute('colspan',3);
            t0.innerHTML=this.row[r].name;
            this.row[r].tr.className=this.row[r].rowtype;
          }
        }else if(this.row[r].rowtype=='line'){
          var t0=this.addElem("td",this.divname+"_row_"+r+"td0",{},this.row[r].tr);
          t0.setAttribute('colspan',3);
          this.row[r].tr.className="line";
        }else if(this.row[r].rowtype=='dateperiod'){
          this.createTableRowDatePeriod(r);
        }else if(this.row[r].rowtype=='check'){
          var t0=this.addElem("td",this.divname+"_row_"+r+"td0",{},this.row[r].tr);
          var t1=this.addElem("td",this.divname+"_row_"+r+"td1",{},this.row[r].tr);
          this.row[r].t2=this.addElem("td",this.divname+"_row_"+r+"td2",{},this.row[r].tr);
          this.row[r].radioimg=this.addElem("img",this.divname+"_img_"+r+"td0",{},t0);
          if( currentzoom>this.row[r].maxzoom){
            this.row[r].radioimg.src=this.localurl+"checkbox_disabled.gif";
            this.row[r].tr.className="disabled";
          }
          else
            this.row[r].radioimg.src=this.localurl+"checkbox_0.gif";
          var im=this.addElem("img",this.divname+"_img_"+r+"td1",{},t1);
          im.src=this.row[r].icon;
          if(typeof this.row[r].param.iconwidth!='undefined')
            im.style.width=this.row[r].param.iconwidth.toString()+"px";
          if(typeof this.row[r].param.iconheight!='undefined')
            im.style.height=this.row[r].param.iconheight.toString()+"px";
          var cn=this.row[r].className ? this.row[r].className + " " : "";
          t0.className=cn+" radio";
          t1.className=cn+" icon";
          this.row[r].t2.className=cn+" text";
          if(typeof this.row[r].name!='undefined')
            this.row[r].t2.innerHTML=this.row[r].name;
          else
            this.addElem('div',this.divname+'_arrdummy_'+r,{height:"10px",width:"10px"},this.row[r].t2);
        }
      }
    },
    createTableRowDatePeriod: function(r){
      var from=new Date();
      from.setHours(0);
      from.setMinutes(0);
      from.setSeconds(0);
      var until=new Date();
      until.setHours(23);
      until.setMinutes(59);
      until.setSeconds(59);
      if(typeof this.row[r].param.fromoffsetmonth!='undefined'){
        var m=parseInt(from.getMonth())+parseInt(this.row[r].param.fromoffsetmonth);
        while(m<0){
          from.setFullYear(from.getFullYear()-1);
          m+=12;
        }
        while(m>11){
          from.setFullYear(from.getFullYear()+1);
          m-=12;
        }
        from.setMonth(m);
      }
      for(var cri=0;cri<this.row[r].childrows.length;cri++){
        var cr = this.row[r].childrows[cri];
        this.row[cr].from=from;
        this.row[cr].until=until;
      }
      var fromString=(from.getDate()<10?'0':'')+from.getDate()+'.'+(from.getMonth()<9?'0':'')+(from.getMonth()+1).toString()+'.'+(from.getFullYear()).toString();
      var untilString=(until.getDate()<10?'0':'')+until.getDate()+'.'+(until.getMonth()<9?'0':'')+(until.getMonth()+1).toString()+'.'+(until.getFullYear()).toString();

      this.row[r].tr.className="dateperiod";
      var t0=this.addElem("td",this.divname+"_row_"+r+"td0",{},this.row[r].tr);
      t0.setAttribute('colspan',3);
      var d1=this.addElem("div",this.divname+"_row_"+r+"div01",{},t0);
      if( typeof this.row[r].param.text1!='undefined')
        d1.innerHTML=this.row[r].param.text1
      else
        d1.innerHTML="von:"
      var d2=this.addElem("div",this.divname+"_row_"+r+"div02",{},t0);
      this.row[r].frominput=this.addElem("input",this.divname+"_row_"+r+"from",{},d2);
      this.row[r].frominput.setAttribute('type','text');
      this.row[r].frominput.setAttribute('value',fromString);
      this.row[r].frominput.setAttribute('name',this.row[r].frominput.id);
      var d3=this.addElem("div",this.divname+"_row_"+r+"div03",{},t0);
      if( typeof this.row[r].param.text2!='undefined')
        d3.innerHTML=this.row[r].param.text2
      else
        d3.innerHTML="bis:"
      var d4=this.addElem("div",this.divname+"_row_"+r+"div04",{},t0);
      this.row[r].untilinput=this.addElem("input",this.divname+"_row_"+r+"until",{},d4);
      this.row[r].untilinput.setAttribute('type','text');
      this.row[r].untilinput.setAttribute('value',untilString);
      this.row[r].untilinput.setAttribute('name',this.row[r].untilinput.id);
    },
    addEventsToTable: function(){
      for(r=0;r<this.row.length;r++){
        if(this.row[r].rowtype=='check'){
          this.row[r].tr.onclick=this.cbSelect.bind(this,r);
          this.row[r].tr.onmouseover=this.cbHoverRow.bind(this,r);
          this.row[r].tr.onmouseout=this.cbHoverRow.bind(this,-1);
        }
        else if(this.row[r].rowtype=='dateperiod'){
          this.row[r].frominput.onchange=this.cbChangeDate.bind(this,r);
          this.row[r].untilinput.onchange=this.cbChangeDate.bind(this,r);
        }
      }
    },
    rerenderTable: function(){
      // z.B. beim IE kann es Probleme beim rendern der Tabelle geben
      // Auf diese Weise wird der ganze DIV-Container neu gerendert
      this.div.innerHTML = this.div.innerHTML;
      this.table = $(this.divname+"_table");
      for(r=0;r<this.row.length;r++){
        this.row[r].tr=$(this.divname+"_tr_"+r);
        this.row[r].radioimg=$(this.divname+"_img_"+r+"td0");
        this.row[r].frominput=$(this.divname+"_row_"+r+"from");
        this.row[r].untilinput=$(this.divname+"_row_"+r+"until");
      }
    },
    create: function(){
      if( this.defineTableData() ){
        this.createTable();
        this.rerenderTable();
        this.addEventsToTable();
      }
    }
  });
}


