// 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
// Updated: August 2008, Author: Dadasaheb Honde, dadasahebhonde@yahoo.com. 
// 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 = "relative";
	div.style.width = "0px";
	div.style.height = "0px";
	//div.style.backgroundColor = this.color_;
	div.style.background= "transparent";
	if(this.tooltip_ != null){
		div.style.cursor = "none";
		div.style.color = "white";
		div.innerHTML = '<font style="font-size: large" color="#FFFFFF"><b><table border=0><tr><td align=center>'+this.tooltip_+"</td></tr><tr><td align=center>Listings</td></tr></table></b></font>";
	}

	// 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-36) + "px";
	this.div_.style.top = (p.y-45) + "px";
}


