// Property Tooltip

// A PropertyToolTip is a simple overlay that displays a text message on the
// map. 
function PropertyToolTip(point, message ) {
  this.point_ = point;
  this.message_ = message;
}

PropertyToolTip.prototype = new GOverlay();

// Creates the DIV representing this PropertyToolTip.
PropertyToolTip.prototype.initialize = function(map) {
  var div = document.createElement("div");
  div.style.border = "1px solid black";
  div.style.position = "absolute";
  div.style.background = "white";
  div.style.color = "black";
  div.style.fontFamily = "Arial";
  div.style.fontSize = "11px";
  div.style.textAlign = "center";
  div.innerHTML = this.message_; //replaced innerText (deprecated) with innerHTML
  div.style.height = "21px";
  div.style.width = div.innerHTML.length * 7.0 + "px";
  map.getPane(G_MAP_MARKER_PANE).appendChild(div);
  this.map_ = map;
  this.div_ = div;
}

// Remove the main DIV from the map pane
PropertyToolTip.prototype.remove = function() {
  this.div_.parentNode.removeChild(this.div_);
}

// Copy our data to a new PropertyToolTip
PropertyToolTip.prototype.copy = function() {
  return new PropertyToolTip(this.point_, this.message_);
}

// Redraw the PropertyToolTip
PropertyToolTip.prototype.redraw = function(force) {
  // We only need to redraw if the coordinate system has changed
  if (!force) return;

  var c1 = this.map_.fromLatLngToDivPixel(this.point_);
  var c2 = this.map_.getCenter();
  var xoffset;
  if ( c2.x > this.point_.x ) xoffset = 16;
  else xoffset = - (this.div_.innerText.length * 8.0) - 16;

  // Now position our DIV based on the DIV coordinates of our bounds
  this.div_.style.left = (c1.x + xoffset) + "px";
  this.div_.style.top = (c1.y - 32) + "px";
}


