// JavaScript Document

//create the Counter overlay object
function Counter(marker,html,width) {
	this.html_ = html;
	this.width_ = (width ? width + 'px' : 'auto');
	this.marker_ = marker;
}

try
{
	Counter.prototype = new GOverlay();
}
catch (ex) 
{
	location.href = '/FindAgent/NoGoogle.htm';
}

cp = Counter.prototype;

cp.initialize = function(map){
	var div = document.createElement("div");
	div.style.display = 'none';
	map.getPane(G_MAP_MARKER_PANE).appendChild(div);
	this.map_ = map
	this.container_ = div;
}

cp.redraw = function(force) {
	if(!force) return;
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	var zIndex = GOverlay.getZIndex(this.marker_.getPoint().y);

	this.container_.innerHTML = '<span class="cluster_count">' + this.html_ + '</span>';
	this.container_.style.position = 'absolute';
	this.container_.style.left = pixelLocation.x + 15 + "px";
	this.container_.style.top = pixelLocation.y - 20 + "px";
	this.container_.style.background = "transparent url(/findagent/img/icon_flag.png) no-repeat top right";
	this.container_.style.font = 'bold 12px/12px "Helvetica Neue",Helvetica, arial, sans';
	this.container_.style.color = "#d4021f";
	this.container_.style.textAlign = "center";
	this.container_.style.padding = "0 5px 0 2px";
	this.container_.style.width = "auto";
	this.container_.style.height = "23px";
	this.container_.style.zIndex = zIndex + 1;
	
	this.container_.style.display = 'block';
}

cp.remove = function(){
	this.container_.parentNode.removeChild(this.container_);
}

cp.copy = function(){
	return new Counter(this.html_);
}

try
{
GMarker.prototype.CounterInstance = null;
GMarker.prototype.showCounter = function(content){
	if(this.CounterInstance == null){
		this.CounterInstance = new Counter(this, content);
		map.addOverlay(this.CounterInstance);
	}
}
GMarker.prototype.removeCounter = function(){
	if(this.CounterInstance != null) {
		map.removeOverlay(this.CounterInstance);
		this.CounterInstance = null;
	}
}
}
catch (ex) {}