function hbTokenMarker (point, icon, inert, pane)
{
  GMarker.call (this, point, icon, inert);
  this.point_ = point;
  this.icon_ = icon;
  this.title_ = "";
  this.clickable_ = false;
  this.draggable_ = false;
  this.bouncy_ = false;
  this.bounceGravity_ = 1;
  this.pane_ = pane ? pane : G_MAP_MARKER_SHADOW_PANE;
  this.tooltip = null;
}

hbTokenMarker.prototype = new GMarker (new GLatLng (0, 0));
hbTokenMarker.prototype.constructor = hbTokenMarker;

hbTokenMarker.prototype.destroy = function ()
{
  this.remove ();

  this.point_ = undefined;
  this.icon_ = undefined;
  this.title_ = undefined;
  this.clickable_ = undefined;
  this.draggable_ = undefined;
  this.bouncy_ = undefined;
  this.bounceGravity_ = undefined;
  this.pane_ = undefined;
  this.map_ = undefined;
  this.div_ = undefined;
  this.img_ = undefined;
}

hbTokenMarker.prototype.setPane = function (newPane)
{
  this.pane_ = newPane;

  if (this.div_)
  {
    this.div_.parentNode.removeChild (this.div_);
    this.map_.getPane (this.pane_).appendChild (this.div_);
  }
}

hbTokenMarker.prototype.initialize = function (map)
{
  this.remove ();

  var a = document.createElement ("a");

  var div = document.createElement ("div");
  div.style.position = "absolute";

  if (this.tooltip)
  {
    div.title = this.tooltip;
  }

  var img = document.createElement ("img");
  img.src = this.icon_.image;

  div.appendChild (img);
  map.getPane (this.pane_).appendChild (div);

  this.map_ = map;
  this.div_ = div;
  this.img_ = img;
}

hbTokenMarker.prototype.remove = function ()
{
  if ((this.div_) && (this.div_.parentNode))
  {
    GEvent.clearNode (this.div_);
    this.div_.parentNode.removeChild (this.div_);
  }
}

hbTokenMarker.prototype.copy = function ()
{
  var opts = {
    title : this.title_,
    clickable : this.clickable_,
    draggable : this.draggable_,
    bouncy : this.bouncy_,
    bouncyGravity : this.bounceGravity_,
    pane : this.pane_
  }
  
  return new hbTokenMarker (this.point_,
                            this.icon_);
}

hbTokenMarker.prototype.redraw = function (force)
{
  if (false == force)
  {
    return;
  }

  var pixelCoord = this.map_.fromLatLngToDivPixel (this.point_);
  var iconSize = this.icon_.iconSize;

  if (iconSize)
  {
    this.div_.style.width = iconSize.width;
    this.div_.style.height = iconSize.height;
    this.img_.width = iconSize.width;
    this.img_.height = iconSize.height;
  }

  if (this.icon_.iconAnchor)
  {
    this.div_.style.left = pixelCoord.x - this.icon_.iconAnchor.x;
    this.div_.style.top = pixelCoord.y - this.icon_.iconAnchor.y;
  }
  else
  {
    this.div_.style.left = pixelCoord.x;
    this.div_.style.top = pixelCoord.y;
  }
}

hbTokenMarker.prototype.setTooltip = function (tooltip)
{
  this.tooltip = tooltip;

  if (this.div_)
  {
    this.div_.title = tooltip;
  }
}
