function draw_points()
{
  this.points_list=new Array();
  this.layers_list=new Array();

  var self = this;
  this.add_point = function(config, layer_name)
  {
    var xpoint=new MapgoIcon();
    if (typeof(layer_name)=='undefined') layer_name='ob_layer';

    xpoint.id=config.id;
    if (typeof(config.image)=='undefined')
      xpoint.image='http://www.eholiday.pl/img/marker.png';
    else
      xpoint.image=config.image;
    
    if (typeof(config.i_width)=='undefined')
      xpoint.width=20;
    else
      xpoint.width=parseInt(config.i_width);

    if (typeof(config.i_height)=='undefined')
      xpoint.height=34;
    else
      xpoint.height=parseInt(config.i_height);

    if (typeof(config.i_offx)=='undefined')
      xpoint.icon_offx=-10;
    else
      xpoint.icon_offx=parseInt(config.i_offx);

    if (typeof(config.i_offy)=='undefined')
      xpoint.icon_offy=-34;
    else
      xpoint.icon_offy=parseInt(config.i_offy);

    if (typeof(config.k1) != 'undefined' && typeof(config.k2) != 'undefined')
      self.re(config);
    xpoint.lon=parseFloat(config.x);
    xpoint.lat=parseFloat(config.y);
    if (typeof(config.tip_width)=='undefined')  xpoint.tip_width=330;  else xpoint.tip_width= parseInt(config.tip_width);
    if (typeof(config.tip_height)=='undefined') xpoint.tip_height=160; else xpoint.tip_height=parseInt(config.tip_height);

    if (typeof(config.anchorx)=='undefined')
      xpoint.tip_anchorx=10;
    else
      xpoint.tip_anchorx=parseInt(config.anchorx);

    if (typeof(config.anchory)=='undefined')
      xpoint.tip_anchory=15;
    else
      xpoint.tip_anchory=parseInt(config.anchory);
    xpoint.descr=config.desc;

    var xlayer = self.get_layer_point(layer_name);
//    alert(xlayer.points.length);
    xlayer.points.push(xpoint);
  }

  this.get_layer_point = function(layer_name)
  {
    for (var i=0,n=self.layers_list.length;i<n;i++)
    {
      if (self.layers_list[i].name == layer_name)
      {
        return self.layers_list[i];
      }
    }
    self.layers_list[n]={name:layer_name, points:new Array()};
    return self.layers_list[n];
  }

  this.re = function(p)
  {
    var tr=[['fa',0],['fb',1],['fc',2],['fd',3],['fe',4],['0a',5],['0b',6],['0c',7],['0d',8],['0e',9],['0f','.']];
    var t=p.k1;
    var c=t.length;
    var t1='';
    var t2='';
    var ds;
    if(p.k2=='') d=c/2;
//    if(c%2==0) d=c/2;
    else { ds=self.sp('0x',self.su(2,p.k2)); d=parseInt(ds[0]); }
    for(var j=0; j<c; j++)
    {
      var v = self.st(t[j],tr);
      if(j<d)
        t1+=self.st(t[j],tr);
      else
        t2+=self.st(t[j],tr);
    }
//    alert(t1);
//    alert(t2);
    p.x=t1;
    p.y=t2;
  }

  this.su = function(p,s)
  {
    return s.substring(p, s.length);
  };

  this.st = function(a,b)
  {
    a=self.su(2,a);
    for(var i in b) {if (typeof(b[i][0])!='undefined') a=a.replace(RegExp(b[i][0],"g"),b[i][1]); }
    return a;
  };

  this.load_points = function(layer_name, show_icon)
  {
    if (typeof(layer_name)=='undefined') layer_name='ob_layer';
    if (typeof(show_icon)=='undefined') show_icon=false;

    var xlayer = self.get_layer_point(layer_name);
    if (window.mapobject&&xlayer.points.length>0)
    {
      window.mapobject.addIconsToMap(xlayer.points, xlayer.name);
      if (xlayer.points.length==1&&show_icon)
      {
        window.mapobject.centerTo(xlayer.points[0].lon, xlayer.points[0].lat, 7);
        window.mapobject.showIconTip(xlayer.points[0]);
      }
    }
  }

  this.show_icon_tip = function(id)
  {
    if (typeof(id)=='object')
    {
      window.mapobject.showIconTip(id);
    }
    else
    {
      for (var i=0,n=self.layers_list.length;i<n;i++)
      {
        for (var j=0,m=self.layers_list[i].points.length;j<m;j++)
        {
          if (self.layers_list[i].points[j].id==id)
          {
            window.mapobject.showIconTip(self.layers_list[i].points[j]);
          }
        }
      }
    }
  }

  this.show_on_map = function(xlayers)
  {
    var xpoints=new Array();
    if (typeof(xlayers)=='undefined') xlayers = ['ob_layer'];
    for (var i=0,n=xlayers.length;i<n;i++)
      xpoints = xpoints.concat(self.get_layer_point(xlayers[i]).points);

    if (xpoints.length)
      window.mapobject.positionMap(xpoints);
  }

  this.sp = function(p,s)
  {
    return s.split(p);
  };
  this.hide_layer = function(layer_name)
  {
    if (typeof(layer_name)=='undefined') layer_name='ob_layer';
    window.mapobject.hideLayer(layer_name);
  }
  this.show_layer = function(layer_name)
  {
    if (typeof(layer_name)=='undefined') layer_name='ob_layer';
    window.mapobject.showLayer(layer_name);
  }
}

