
function Tooltip(marker, content, flag){
	this.marker = marker;
	this.content = content;
	this.flag = flag;
}

Tooltip.prototype = new GOverlay();

Tooltip.prototype.initialize = function(map){
	var div = document.createElement("div");
	var flag = document.createElement("img");
	var source = document.createAttribute("src");
	source.nodeValue = this.flag;
	flag.setAttributeNode(source);
	div.appendChild(flag);
	div.appendChild(document.createTextNode(this.content));
	div.className = 'tooltip';
	div.style.position = 'absolute';
	div.style.visibility = 'hidden';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	this.map = map;
	this.div = div;
}

Tooltip.prototype.remove = function(){
	this.div.parentNode.removeChild(this.div);
}

Tooltip.prototype.copy = function(){
	return new Tooltip(this.marker,this.content);
}

Tooltip.prototype.redraw = function(force){
	if (!force) return;
	var markerPos = this.map.fromLatLngToDivPixel(this.marker.getPoint());
	var iconAnchor = this.marker.getIcon().iconAnchor;
	var xPos = Math.round(markerPos.x - this.div.clientWidth / 2);
	var yPos = markerPos.y - iconAnchor.y - this.div.clientHeight + 5;
	this.div.style.top = yPos + 'px';
	this.div.style.left = xPos + 'px';
}

Tooltip.prototype.show = function(){
	this.div.style.visibility = 'visible';
}

Tooltip.prototype.hide = function(){
	this.div.style.visibility = 'hidden';
}