if( typeof gAPTVMAP == 'undefined' ){
  var gAPTVMAP = 'defined';
  
  var sizeCenterZoom2BBox = function(width, height, center, zoom) {
    var supp = com.ptvag.webcomponent.map.CoordUtil.getSmartUnitsPerPixel(zoom);
    var bb = {left:center.x - supp*width/2, top:center.y + supp*height/2,
    right:center.x + supp*width/2, bottom:center.y - supp*height/2};
    return bb;
  }

  var sizeCenterZoomInSUPP2BBox = function(width, height, center, supp) {
    var bb = {left:center.x - supp*width/2, top:center.y + supp*height/2,
    right:center.x + supp*width/2, bottom:center.y - supp*height/2};
    return bb;
  }
  var APTVMap = Class.create();
  APTVMap.prototype = Object.extend(new AAjaxMap(), {
    localurl : gJSMapImagePath+"APTVMap/",
    getURLParams: function(){
      var par=
        "&REQMapWidth="+this.mapDiv.clientWidth+
        "&REQMapHeight="+this.mapDiv.clientHeight+
        "&REQMapCenterX="+this.getCenter().getLon()+
        "&REQMapCenterY="+this.getCenter().getLat()+
        "&REQMapScaling="+this.getZoom();
      var r=0;
      for(var c=this.contcount;c>0;c--){
        var p=this.content.get(c.toString());
        if(p.show){
          if(p.type=='polyline' || p.type=='route'){
            par+="&REQMapRoute"+r+".DisplayMode=POLYGON";
            par+="&REQMapRoute"+r+".Color="+this.getColorFFFFFF(p.color);
            par+="&REQMapRoute"+r+".LineWidth="+p.width;
            for(var l=0;l<p.coords.length;l++){
              par+="&REQMapRoute"+r+".Location"+l+".X="+p.coords[l].getLon();
              par+="&REQMapRoute"+r+".Location"+l+".Y="+p.coords[l].getLat();
              if(l==0||l==p.coords.length-1)
                par+="&REQMapRoute"+r+".Location"+l+".Marker=TRANSPARENT";
            }
            r++;
          }
          else if(p.type=='location'){
            par+="&REQMapRoute"+r+".DisplayMode=LOCATIONS";
            par+="&REQMapRoute"+r+".Location0.X="+p.coord.getLon();
            par+="&REQMapRoute"+r+".Location0.Y="+p.coord.getLat();
//            par+="&REQMapRoute"+r+".Location0.Name="+p.text;
            var imageptv=p.imageurl.substring(p.imageurl.lastIndexOf("/")+1,p.imageurl.lastIndexOf(".")).toUpperCase();
            par+="&REQMapRoute"+r+".Location0.Marker="+imageptv;
            r++;
          }
        }
      }
      return par;
    },
    additionalMapInitialisations:function(){
    },
    decodeUniCode:function(u){
      var d=this.addElem("div","dummy",{display:"none"},this.mapDiv);
      d.innerHTML=u;
      var a=d.innerHTML;
      this.mapDiv.removeChild(d);
      return a;
    },
    show: function() {
      var w=(typeof this.mapParams.width!='undefined'?this.mapParams.width:this.mapDiv.clientWidth);
      var h=(typeof this.mapParams.height!='undefined'?this.mapParams.height:this.mapDiv.clientHeight);
      var bbox = sizeCenterZoom2BBox( w,h,
                                      this.CCoord2SmartUnit(this.mapParams.coord),
                                      this.AjaxMap2PTVZoom( this.mapParams.zoom ) );
      this.map = new com.ptvag.webcomponent.map.Map( this.mapDiv, bbox );
      var toolbar=this.map.getLayer("toolbar");
      toolbar.removeElement("hybrid-view");
      toolbar.removeElement("aerial-view");
      toolbar.removeElement("map-view");
      toolbar.removeElement("spacing-between-view-1");
      toolbar.removeElement("spacing-between-view-2");
      toolbar.removeElement("spacing-after-view");
      if(typeof this.mapParams.tZoomIn!='undefined')toolbar.setButtonTooltip("zoom-in",this.decodeUniCode(this.mapParams.tZoomIn));
      if(typeof this.mapParams.tZoomOut!='undefined')toolbar.setButtonTooltip("zoom-out",this.decodeUniCode(this.mapParams.tZoomOut));
      if(typeof this.mapParams.tZoomMode!='undefined')toolbar.setButtonTooltip("zoom-mode",this.decodeUniCode(this.mapParams.tZoomMode));
      if(typeof this.mapParams.tMoveMode!='undefined')toolbar.setButtonTooltip("move-mode",this.decodeUniCode(this.mapParams.tMoveMode));
      if(typeof this.mapParams.tOverview!='undefined')toolbar.setButtonTooltip("overview",this.decodeUniCode(this.mapParams.tOverview));
      if(typeof this.mapParams.tMeasurement!='undefined')toolbar.setButtonTooltip("measurement",this.decodeUniCode(this.mapParams.tMeasurement));
      if(typeof this.mapParams.tReset!='undefined')toolbar.setButtonTooltip("reset",this.decodeUniCode(this.mapParams.tReset));
      if(typeof this.mapParams.tHistoryBack!='undefined')toolbar.setButtonTooltip("history-back",this.decodeUniCode(this.mapParams.tHistoryBack));
      if(typeof this.mapParams.tHistoryForward!='undefined')toolbar.setButtonTooltip("history-forward",this.decodeUniCode(this.mapParams.tHistoryForward));
      if(typeof this.mapParams.language=='undefined')this.mapParams.language="d";
      this.map.setAllowMouseWheelZoom(true);
      this.map.getLayer("position").setEnabled(true);
      //this.map.getLayer('debug').setEnabled(true);

      this.map.getLayer("overview").setAreaWidth(0.25);
      this.map.getLayer("overview").setAreaHeight(0.25);
      this.map.getLayer("overview").setAreaRight(1);
      this.map.getLayer("overview").setAreaBottom(1);
      this.map.getLayer("overview").setAreaLeft(null);
      this.map.getLayer("overview").setLayerOpacity(0.95);
      this.map.getLayer("overview").setAreaBorderWidth(1);
      this.map.getLayer("zoomslider").setAreaRight(null);
      this.map.getLayer("zoomslider").setAreaLeft(7);
      this.map.getLayer("scale").setAreaRight(null);
      this.map.getLayer("scale").setAreaLeft(84);
      this.map.getLayer("scale").setAreaBottom(1);

//      this.map.getLayer("toolbar").toggleOverview();
      this.map.getLayer("toolbar").switchToMoveMode();
//      this.InfoBoxFactory = com.ptvag.webcomponent.map.vector.InfoBoxElementFactoryRound.getInstance();
      this.InfoBoxFactory = com.ptvag.webcomponent.map.vector.InfoBoxElementFactoryDefault.getInstance();
      this.InfoBoxFactory.setAllowWrap(true);
      com.ptvag.webcomponent.map.vector.InfoBoxElementFactory =
        this.InfoBoxFactory;
      this.additionalMapInitialisations();
      if(typeof this.mapParams.onshow!='undefined')
        this.mapParams.onshow();
      this.map.addEventListener("changeZoom", this.cbChange.bind(this));
      this.map.addEventListener("changeCenter", this.cbChange.bind(this));
      this.vectorlayer=this.map.getLayer('vector');
      this.leftclickarea=new com.ptvag.webcomponent.map.vector.ClickArea(null,null, null, 0,
        this.cbLeftClick.bind(this));
      this.rightclickarea=new com.ptvag.webcomponent.map.vector.RightClickArea(null,null, null, 0,
        this.cbRightClick.bind(this));
      this.vectorlayer.addElement(this.leftclickarea);
      this.vectorlayer.addElement(this.rightclickarea);
    },
    geo2scr:function(g){
      var su = this.CCoord2SmartUnit(g);
      var zoom = this.map.getZoom();
      var pix = com.ptvag.webcomponent.map.CoordUtil.smartUnit2Pixel( su, zoom );
      var ctrpix = this.map.getCenterInPixel();
      pix.x = (this.map.getWidth()/2) + pix.x - ctrpix.x;
      pix.y = (this.map.getHeight()/2) + ctrpix.y - pix.y;
      return pix;
    },
    setOnChange: function(listener){
      if(typeof this.mapParams.onchange=='undefined')
        this.mapParams.onchange=new Array;
      this.mapParams.onchange[this.mapParams.onchange.length]=listener;
    },
    cbonViewChange: function(){
      this.activeTimeout=null;
      if(typeof this.mapParams.onchange!='undefined'){
        for(var i=0;i<this.mapParams.onchange.length;i++){
          this.mapParams.onchange[i]();
        }
      }
    },
    cbChange: function(){
      window.clearTimeout(this.activeTimeout);
      this.activeTimeout=window.setTimeout("g"+this.classtype+"Instances["+this.instance+"].cbonViewChange()",500);
    },
    getBoundingBox: function(){
      var bb = this.map.getRect();
      return {
        sw:this.SmartUnit2CCoord({x:bb.left,y:bb.bottom}),
        ne:this.SmartUnit2CCoord({x:bb.right,y:bb.top})
      }
    },
    showInfoboxGeo:function(geo,titletext,content){
      this.showNewInfoboxSU(this.CCoord2SmartUnit(geo),titletext,content);
    },
    showInfoboxSU:function(su,titletext,content){
      this.hideAllInfoBoxes();
      var style = "<style>td.title {background-color:#00309C;height:14px;color:#FFFFFF;font-weight:bold;padding:2px 4px;}</style>";
      var title    = titletext.replace(/\ /g,'&nbsp;');
      var titlebut = "<img id='PTVInfoboxClosebuttonImage_"+this.instance+"' src='" +
                     this.localurl+"closebutton.gif' width='14' height='14' "+
                     "onclick='g"+this.classtype+"Instances["+this.instance+"].hideAllInfoBoxes();return false'/>";
      var extcontent = "<div style='float:left;'>"+content+"</div>";
      var allcontent = style+
                       "<table cellspacing='0' width='100%'><tr>"+
                       "<td class='title' width='100%'>"+title+"</td>"+
                       "<td class='title' style='width:16px'>"+titlebut+"</td></tr>"+
                       "<tr><td colspan='2'>"+extcontent+"</td></tr></table>";
      this.currentInfoBox=new com.ptvag.webcomponent.map.vector.InfoBox(
                        su.x, su.y,allcontent, 34, 1, "Infobox", false);
      this.vectorlayer.addElement(this.currentInfoBox);
      this.map.getLayer("floater").setSwallowHoverEvents(true);
    },
    cbLeftClick: function(p){
      var geo=this.SmartUnit2CCoord({x:p.clickX,y:p.clickY});
      if(typeof this.mapParams.leftinfoclicktitle!='undefined'){
        this.showInfoboxSU({x:p.clickX,y:p.clickY},
                            this.mapParams.leftinfoclicktitle,
                            this.mapParams.leftinfoclickcontent(geo));
      }
    },
    cbRightClick: function(p){
      var geo=this.SmartUnit2CCoord({x:p.clickX,y:p.clickY});
      if(typeof this.mapParams.rightinfoclicktitle!='undefined'){
        this.showInfoboxSU({x:p.clickX,y:p.clickY},
                            this.mapParams.rightinfoclicktitle,
                            this.mapParams.rightinfoclickcontent(geo));
      }
    },
    isCoordVisible:function(c){
      var bb = this.map.getRect();
      var s = this.CCoord2SmartUnit(c);
      return s.x>=bb.left&&s.x<=bb.right&&s.y>=bb.bottom&&s.y<=bb.top;
    },
    getCenter: function(){
      return this.SmartUnit2CCoord(this.map.getCenter());
    },
    centerToGeo:function(g){
      this.map.setCenter(this.CCoord2SmartUnit(g));
    },
    setZoom:function(zoom){
      this.map.setZoom(this.AjaxMap2PTVZoom( zoom ));
    },
    createContent:function(params){
      if(typeof params.type=='undefined')return null;
      this.contcount++;
      var cc=this.contcount.toString();
      var p=this.clone_contentparams(params)
      p.cc=cc;
      p.show = false;
      this.content.set(cc,p);
      switch(p.type){
      case 'location':this.createLocation(p);break;
      case 'route':
      case 'polyline':this.createPolyline(p);break;
      case 'polygon':this.createPolygon(p);break;
      case 'circle':this.createCircle(p);break;
      case 'container':this.createContainer(p);break;
      default:return null;
      }
      return cc;
    },
    showContent:function(content){
      if(typeof content=='undefined')return;
      if(content==null)return;
      var p=this.content.get(content);
      if(typeof p=='undefined')return;
      switch(p.type){
      case 'location':this.showLocation(p);break;
      case 'route':
      case 'polyline':this.showPolyline(p);break;
      case 'polygon':this.showPolygon(p);break;
      case 'circle':this.showCircle(p);break;
      case 'container':this.showContainer(p);break;
      }
      p.show = true;
    },
    hideContent:function(content){
      if(typeof content=='undefined')return;
      if(content==null)return;
      var p=this.content.get(content);
      if(typeof p=='undefined')return;
      p.show = false;
      switch(p.type){
      case 'location':this.hideLocation(p);break;
      case 'route':
      case 'polyline':
      case 'polygon':
      case 'circle':
        if(typeof this.vectorlayer.removeElement!='undefined')
          this.vectorlayer.removeElement(p.cc);
        else
          this.vectorlayer.hideElement(p.cc);
        delete p.content;
        break;
      }
    },
    removeContent:function(content){
      if(typeof content=='undefined')return;
      if(content==null)return;
      var p=this.content.get(content);
      if(typeof p=='undefined')return;
      switch(p.type){
      case 'location':
      case 'route':
      case 'polyline':
      case 'polygon':
      case 'container':
        break;
      case 'circle':
        this.removeContent(p._poly);
        break;
      }
      this.content.unset(content);
    },
    centerToContent: function(content){
      if(typeof content=='undefined')return;
      if(content==null)return;
      var par=this.content.get(content);
      switch(par.type){
      case "circle":
        this.map.setCenter(this.CCoord2SmartUnit(par.coord));
        this.map.setZoom(this.AjaxMap2PTVZoom(this.mincenterzoom));
      case "location":
        this.map.setCenter(this.CCoord2SmartUnit(par.coord));
        this.map.setZoom(this.AjaxMap2PTVZoom(this.mincenterzoom));
        break;
      case "polyline":
      case "polygon":
      case "route":
        if(typeof par.su != 'undefined')
          this.map.setViewToPoints(par.su, false, false);
        break;
      }
    },
    
    // Hilfsmethoden
    createIconHTML:function(par){
      var shad = false;
      if( typeof par.shadowheight!='undefined' &&
          typeof par.shadowwidth!='undefined' &&
          typeof par.shadowurl!='undefined' )
        shad = true;
      var w = shad?Math.max( par.shadowwidth,par.imagewidth ):par.imagewidth;
      var h = shad?Math.max( par.shadowheight,par.imageheight ):par.imageheight;
      par.html = "<div style='position:absolute;" +
          "width:" + w + "px;" +
          "height:" + h + "px;" +
          "left:" + (-par.hotspot.x).toString() + "px;" +
          "top:" + (-par.hotspot.y).toString() + "px;" +
          "'>";
      if(shad)
        par.html+= "<img style='position:absolute;" +
          "' " +
          "src='" + par.shadowurl + "' " +
          "width='" + par.shadowwidth + "' " +
          "height='" + par.shadowheight + "' />";
      par.html+="<img style='position:absolute;" +
          "' " +
          "src='" + par.imageurl + "' " +
          "width='" + par.imagewidth + "' " +
          "height='" + par.imageheight + "' " +
          "</div>";
    },
    changeTooltip: function(content,param){
      var par=this.content.get(content);
      par.text=param.text;
      if(typeof par.tooltip!='undefined'){
        var t=this.vectorlayer.getElement(par.cc+"_tooltip");
        t.setText(par.text.replace(/\ /g,'&nbsp;'));
      }
    },
    changeInfo: function(content,param){
      var par=this.content.get(content);
      par.infotitle=param.infotitle;
      par.infocontent=param.infocontent;
      par.onshowinfobox=function(){
        this.showInfoboxSU(par.su,par.infotitle,par.infocontent);
      };
      var t=this.vectorlayer.getElement(par.cc+"_clickarea");
      t.setHandler(par.onshowinfobox.bind(this));
    },
    changeIcon: function(content,param){
      if(typeof com.ptvag.webcomponent.map.vector.HTML!='undefined'){
        var par=this.content.get(content);
        this.vectorlayer.removeElement(par.cc);
        par.shadowheight= param.shadowheight;
        par.shadowwidth = param.shadowwidth;
        par.shadowurl   = param.shadowurl;
        par.imageheight = param.imageheight;
        par.imagewidth  = param.imagewidth;
        par.imageurl    = param.imageurl;
        this.createIconHTML(par);
        par.content=new com.ptvag.webcomponent.map.vector.HTML(
          par.su.x, par.su.y, 17, par.html, null, par.cc, par.flexible);
      }
    },
    createLocation: function( par ){
      var shad = false;
      if( typeof par.shadowheight!='undefined' &&
          typeof par.shadowwidth!='undefined' &&
          typeof par.shadowurl!='undefined' )
        shad = true;
      var w = shad?Math.max( par.shadowwidth,par.imagewidth ):par.imagewidth;
      var h = shad?Math.max( par.shadowheight,par.imageheight ):par.imageheight;
      par.html = "<div style='position:absolute;" +
          "width:" + w + "px;" +
          "height:" + h + "px;" +
          "left:" + (-par.hotspot.x).toString() + "px;" + 
          "top:" + (-par.hotspot.y).toString() + "px;" +
          "'>";
      if(shad)
        par.html+= "<img style='position:absolute;" + 
          "' " +
          "src='" + par.shadowurl + "' " +
          "width='" + par.shadowwidth + "' " +
          "height='" + par.shadowheight + "' />";
      par.html+="<img style='position:absolute;" + 
          "' " +
          "src='" + par.imageurl + "' " +
          "width='" + par.imagewidth + "' " +
          "height='" + par.imageheight + "' " +
          "</div>";
      if(typeof par.flexible=='undefined')par.flexible=false;
      par.su=this.CCoord2SmartUnit(par.coord);
      par.su.x+=0.0001*parseInt(par.cc)%100-0.005;
    },
    showLocation: function( par ){
      // Marker
      if(typeof com.ptvag.webcomponent.map.vector.HTML!='undefined')
        par.content=new com.ptvag.webcomponent.map.vector.HTML(
            par.su.x, par.su.y, 17, par.html, null, par.cc, par.flexible);
      else
        par.content=new com.ptvag.webcomponent.map.vector.ImageMarker(
            par.su.x, par.su.y, par.imageurl,34, null, par.cc, par.flexible);
      //par.content.positionFlexible = true;
      //par.content.flexX = 10;
      //par.content.flexY = 10;
      this.vectorlayer.addElement(par.content);
      // Tooltip (on hover)
      if ( typeof par.htmlText!='undefined') {
        par.tooltip=new com.ptvag.webcomponent.map.vector.Tooltip(
          par.su.x, par.su.y, 17, Math.max(par.imagewidth,par.imageheight),
          par.htmlText, 34, 2, par.cc+"_tooltip", par.flexible);
        this.vectorlayer.addElement(par.tooltip);
      }
      else if ( typeof par.text!='undefined') {
        par.tooltip=new com.ptvag.webcomponent.map.vector.Tooltip(
          par.su.x, par.su.y, 17, Math.max(par.imagewidth,par.imageheight),
          "<div style='white-space:nowrap;'>"+par.text+"</div>", 34, 2, par.cc+"_tooltip", par.flexible);
        this.vectorlayer.addElement(par.tooltip);
      }
      if ( typeof par.onclick!='undefined') {
        par.clickArea=new com.ptvag.webcomponent.map.vector.ClickArea(
            par.su.x, par.su.y, null, 8, par.onclick, 0, par.cc+"_clickArea", par.flexible);
        this.vectorlayer.addElement(par.clickArea);
      }
      // Infobox (on left click)
      if( typeof par.infotitle!='undefined'&&typeof par.infocontent!='undefined') {
        par.onshowinfobox=function(){
          this.showInfoboxSU(par.su,par.infotitle,par.infocontent);
        };
        par.clickarea=new com.ptvag.webcomponent.map.vector.ClickArea(
          par.su.x, par.su.y, null, Math.max(par.imagewidth,par.imageheight),
          par.onshowinfobox.bind(this), 0, par.cc+"_clickarea", par.flexible);
        this.vectorlayer.addElement(par.clickarea,true);
      }
      else if ( typeof par.info!='undefined') {
        par.onshowinfobox=function(){
          this.hideAllInfoBoxes();
          var infotop = "<div style='float:right;text-align:right'>" +
                        "<img id='PTVInfoboxClosebuttonImage_"+this.instance+"' src='" +
                        this.localurl+"closebutton.gif' width='16' height='16' "+
                        "onclick='g"+this.classtype+"Instances["+this.instance+"].hideAllInfoBoxes();return false'/></div>";
          this.currentInfoBox=new com.ptvag.webcomponent.map.vector.InfoBox(
            par.su.x, par.su.y, infotop+par.info, 34, 1, "Infobox", false);
          this.vectorlayer.addElement(this.currentInfoBox);
        };
        par.clickarea=new com.ptvag.webcomponent.map.vector.ClickArea(
          par.su.x, par.su.y, null, Math.max(par.imagewidth,par.imageheight),
          par.onshowinfobox.bind(this), 0, par.cc+"_clickarea", par.flexible);
        this.vectorlayer.addElement(par.clickarea);
      }
    },
    hideLocation: function(p){
      this.hideAllInfoBoxes();
      if(typeof this.vectorlayer.removeElement!='undefined')
      {
        this.vectorlayer.removeElement(p.cc);
        this.vectorlayer.removeElement(p.cc+"_tooltip");
        this.vectorlayer.removeElement(p.cc+"_clickarea");
        this.vectorlayer.removeElement(p.cc+"_clickArea");
      }
      else
      {
        this.vectorlayer.hideElement(p.cc);
        this.vectorlayer.hideElement(p.cc+"_tooltip");
        this.vectorlayer.hideElement(p.cc+"_clickarea");        
        this.vectorlayer.hideElement(p.cc+"_clickArea");        
      }
      delete p.content;
      delete p.tooltip;
      delete p.clickarea;
      delete p.clickArea;
    },
    hideAllInfoBoxes: function(){
      if(this.currentInfoBox!=null){
        if(typeof this.vectorlayer.removeElement!='undefined')
          this.vectorlayer.removeElement("Infobox");
        else
          this.vectorlayer.hideElement("Infobox");
        delete this.currentInfoBox;
        this.currentInfoBox=null;
        this.map.getLayer("floater").setSwallowHoverEvents(false);
      }
    },
    createCircle: function( par ){
      if(typeof par.color=='undefined')par.color="red";
      if(typeof par.opacity=='undefined')par.opacity=0.7;
      if(typeof par.radius=='undefined')par.radius=16;
      if(typeof par.flexible=='undefined')par.flexible=false;
//      this.vectorlayer = this.map.getLayer('vector');
//      par.su=this.CCoord2SmartUnit(par.coord);
//      par.rgba=this.getRGBA(par.color,par.opacity);
      // Create polyline
      var lat = par.coord.getLat();
      var lon = par.coord.getLon();
      var radfact = Math.PI/180;
      var latoff = par.radius / 60 / 1852 * 1e6;
      var lonoff = par.radius / 60 / 1852 * 1e6 / Math.cos(lat/1e6*radfact);
      var n = 32;
      var crds = [];
      for( var i=0; i<n; i++ ) {
        var rad = 360 * i / n * radfact;
        var latfact = Math.cos(rad);
        var lonfact = Math.sin(rad);
        crds[i] = new CCoord({ lat: lat+latfact*latoff, lon: lon+lonfact*lonoff });
      }
      crds.push(crds[0]);
      par._poly = this.createContent({
        type: 'polyline',
        coords: crds,
        color: par.color,
        width: 4
      });
    },
    showCircle: function( par ){
//      par.content=new com.ptvag.webcomponent.map.vector.Circle(
//          par.su.x, par.su.y, par.rgba, par.radius, null, par.cc, par.flexible);
//      this.vectorlayer.addElement(par.content);
      this.showContent( par._poly );
    },
    createPolyline: function( par ){
      if(typeof par.color=='undefined')par.color="blue";
      if(typeof par.opacity=='undefined')par.opacity=0.7;
      if(typeof par.width=='undefined')par.radius=4;
      this.vectorlayer = this.map.getLayer('vector');
      par.su=new Array();
      for(var i=0;i<par.coords.length;i++)
        par.su[i]=this.CCoord2SmartUnit(par.coords[i]);
      par.rgba=this.getRGBA(par.color,par.opacity);
    },
    showPolyline: function( par ){
      par.content=new com.ptvag.webcomponent.map.vector.Line(
          par.rgba, par.width, par.su, null, par.cc);
      this.vectorlayer.addElement(par.content);
      // ---------------------------
      // Marker
      //if(typeof com.ptvag.webcomponent.map.vector.HTML!='undefined')
      //  par.content=new com.ptvag.webcomponent.map.vector.HTML(
      //      par.su.x, par.su.y, 17, par.html, null, par.cc, par.flexible);
      //else
      //  par.content=new com.ptvag.webcomponent.map.vector.ImageMarker(
      //      par.su.x, par.su.y, par.imageurl,34, null, par.cc, par.flexible);
      for(var i=0;i<par.coords.length;i=i+20)
         {
         var icon = new com.ptvag.webcomponent.map.vector.ImageMarker(
              par.su[i].x, par.su[i].y, "/hafas-res/sitkol/img/js/map_location_via.gif", 34, null, par.cc+i, par.flexible);
         //this.vectorlayer.addElement(icon);
         }
      //var icon1 = new com.ptvag.webcomponent.map.vector.ImageMarker(
      //     par.su[0].x, par.su[0].y, "/hafas-res/sitkol/img/js/map_location_via.gif", 34, null, par.cc, par.flexible);
      //var icon2 = new com.ptvag.webcomponent.map.vector.ImageMarker(
      //     par.su[4].x, par.su[4].y, "/hafas-res/sitkol/img/js/map_location_via.gif", 34, null, par.cc+1, par.flexible);
      //this.vectorlayer.addElement(icon1);
      //this.vectorlayer.addElement(icon2);
      //var icon = new com.ptvag.webcomponent.map.vector.ImageMarker();
      //icon.setX(par.su[0].x);
      //icon.setYear(par.su[0].y);
      //icon.setUrl("/hafas-res/sitkol/img/js/map_location_via.gif");
      //this.vectorlayer.addElement(icon);
      // Tooltip (on hover)
      //if ( typeof par.text!='undefined') {
      //  par.tooltip=new com.ptvag.webcomponent.map.vector.Tooltip(
      //    par.su.x, par.su.y, 17, Math.max(par.imagewidth,par.imageheight),
      //    "<div style='white-space:nowrap'>"+par.text+"</div>", 34, 2, par.cc+"_tooltip", par.flexible);
      //  this.vectorlayer.addElement(par.tooltip);
      //}
      // ---------------------------
    },
    createPolygon: function( par ){
      if(typeof par.color=='undefined')par.color="green";
      if(typeof par.opacity=='undefined')par.opacity=0.3;
      if(typeof par.width=='undefined')par.radius=4;
      this.vectorlayer = this.map.getLayer('vector');
      par.su=new Array();
      for(var i=0;i<par.coords.length;i++)
        par.su[i]=this.CCoord2SmartUnit(par.coords[i]);
      par.rgba=this.getRGBA(par.color,par.opacity);
    },
    showPolygon: function( par ){
      par.content=new com.ptvag.webcomponent.map.vector.Poly(
          par.rgba, par.su);
      this.vectorlayer.addElement(par.content);
    },
    createContainer: function( par ){
      par.su=this.CCoord2SmartUnit(par.coord);
      par.content = '<div style="position:absolute; left:' + 
        (-par.hotspot.x) + 'px; top:' + (-par.hotspot.y) + 'px;">' + 
        par.content + '</div>'
    },
    showContainer: function( par ){
      par.content=new com.ptvag.webcomponent.map.vector.HTML(
          par.su.x, par.su.y, 2, par.content, null, par.cc, par.flexible);
      this.vectorlayer.addElement(par.content);
    },
    CCoord2SmartUnit: function( coord ){
      return com.ptvag.webcomponent.map.CoordUtil.geoDecimal2SmartUnit(
        {x:coord.getLon()/10, y:coord.getLat()/10});
    },
    SmartUnit2CCoord: function( su ){
      var gd = com.ptvag.webcomponent.map.CoordUtil.smartUnit2GeoDecimal(su);
      return new CCoord({lon:Math.round(gd.x*10),lat:Math.round(gd.y*10)});
    },
    AjaxMap2PTVZoom: function( aZoom ){
      if (typeof aZoom == 'undefined') {
        return 10;
      }
      var maxpix = Math.max( this.mapDiv.clientWidth, this.mapDiv.clientHeight );
      return Math.max( 0, Math.min( 23, Math.round( Math.log( aZoom/(maxpix * 0.3) ) / Math.log( 1.59 ) )));
    },
    PTV2AjaxMapZoom: function( aPTVZoom ){
      if (typeof aPTVZoom == 'undefined') {
        return 10000;
      }
      var maxpix = Math.max( this.mapDiv.clientWidth, this.mapDiv.clientHeight );
      return Math.round( Math.exp(aPTVZoom*Math.log(1.59)) * (maxpix * 0.3) );
    },
    getZoom: function(){
      return this.PTV2AjaxMapZoom( this.map.getZoom() );
    },
    getRGBA: function(c,o){
      if(typeof o=='undefined')o=1;
      if(typeof c=='undefined')c="red";
      switch(c){
      case 'red':return 'rgba(255,0,0,'+o+')';
      case 'green':return 'rgba(0,255,0,'+o+')';
      case 'blue':return 'rgba(0,0,255,'+o+')';
      case 'yellow':return 'rgba(255,255,0,'+o+')';
      case 'cyan':return 'rgba(0,255,255,'+o+')';
      case 'purple':return 'rgba(255,0,255,'+o+')';
      case 'white':return 'rgba(255,255,255,'+o+')';
      case 'black':return 'rgba(0,0,0,'+o+')';
      case 'grey':return 'rgba(128,128,128,'+o+')';
      default:return 'rgba(255,0,0,'+o+')';
      }
    },
    getColorFFFFFF: function(c){
      if(typeof c=='undefined')c="red";
      switch(c){
      case 'red':return 'FF0000';
      case 'green':return '00FF00';
      case 'blue':return '0000FF';
      case 'yellow':return 'FFFF00';
      case 'cyan':return '00FFFF';
      case 'purple':return 'FF00FF';
      case 'white':return 'FFFFFF';
      case 'black':return '000000';
      case 'grey':return '888888';
      default:return 'FF0000';
      }
    },
    getPTVMapType: function( type ){
      switch( type ){
      case "satellite":
        return G_SATELLITE_MAP;
      case "road":
        return G_NORMAL_MAP;
      case "hybrid":
        return G_HYBRID_MAP;
      default:
        return G_NORMAL_MAP;
      };
      return G_NORMAL_MAP;
    }
  });
}


