// A Block is a simple overlay that shows a coloured 7x7 block on the map
//
// Kept very small and simple (no events or opacity) so that you can use lots of them
//
// Bill Chadwick 2006
//
// Free for any use
//
function BdccBlock(point, opt_color, tooltip) {
  this.point_ = point;
  this.color_ = opt_color || "#888888";
  this.tooltip_ = tooltip;
}
BdccBlock.prototype = new GOverlay();

// Creates the DIV representing this block.
BdccBlock.prototype.initialize = function(map) {

  var div = document.createElement("DIV");
  div.style.position = "absolute";
  div.style.width = "7px";
  div.style.height = "7px";
  div.style.overflow = "hidden";
  div.style.backgroundColor = this.color_;
  if(this.tooltip_ != null){
      div.style.cursor = "help";
      div.title = this.tooltip_;
  }

  // Block is similar to a marker, so add to marker pane
  map.getPane(G_MAP_MARKER_PANE).appendChild(div);

  //save for later
  this.map_ = map;
  this.div_ = div;
  
}

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

// Copy our data to a new Block
BdccBlock.prototype.copy = function() {
  return new Block(this.point_, this.color_, this.tooltip_);
}

// Redraw the block based on the current projection and zoom level
BdccBlock.prototype.redraw = function(force) {
  // We only need to redraw if the coordinate system has changed
  if (!force) return;

  // Calculate the DIV coordinates of the centre of our block
  var p = this.map_.fromLatLngToDivPixel(this.point_);
  
  // Now position our DIV 
  this.div_.style.left = (p.x-3) + "px";
  this.div_.style.top = (p.y-3) + "px";
}



