/*
function BuildingToolTip(marker, name, divLocation, width, height) 
{
	this.marker_ = marker;
	this.name_ = name;
	this.html_ = "<div>" + name + "</div>";
	this.divLocation_ = divLocation;

	this.width_ = width; // Kartenbreite
	this.height_ = height; // Kartenhöhe
}

BuildingToolTip.prototype = new GOverlay();

BuildingToolTip.prototype.initialize = function(map) 
{
	var buildingDiv = document.createElement("div");
	buildingDiv.setAttribute("class", "buildingDiv");
	buildingDiv.style.display = 'none';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(buildingDiv);
	
	this.map_ = map;
	this.container_ = buildingDiv;
}

BuildingToolTip.prototype.remove = function() 
{
	this.container_.parentNode.removeChild(this.container_);
}

BuildingToolTip.prototype.copy = function() 
{
	return new BuildingToolTip(this.html_);
}

BuildingToolTip.prototype.redraw = function(force) 
{

	if (!force) return;
	var width_TT = 200; // Breite des ToolTips
	var height_TT; // Höhe des ToolTips
	
	var laenge = this.name_.length;	
	if (laenge <= 30) {
		height_TT = 15;
	} else {
		height_TT = 30;
	}
	var x_correction = 0;
	var y_correction = 0;

	// kontrolliert ob die Breite des ToolTips über die Grenzen des Div-Containers ragt und passt entsprechend an
	if (this.divLocation_.x > (this.width_ - width_TT - 15)) { x_correction = (this.width_ - width_TT - 15 - this.divLocation_.x); } 

	// kontrolliert ob die Höhe des ToolTips über die Grenzen des Div-Containers ragt und passt entsprechend an
	//if (this.divLocation_.y > (this.height_ - height_TT - 15)) { y_correction = -135; } 
	if (this.divLocation_.y > (this.height_ - height_TT - 15)) { y_correction = ((-1) * height_TT) - 35; } 
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());	
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	this.container_.style.left = (pixelLocation.x + x_correction) + "px";
	this.container_.style.top = (pixelLocation.y + y_correction) + "px";	
	this.container_.style.width = width_TT + 'px';
	this.container_.style.height = height_TT + 'px';
	this.container_.style.overflow = 'hidden';
	this.container_.style.background = '#FFFFFF';	
	this.container_.style.border = '1px solid #9C9D9F'; 
	this.container_.style.padding = '4px';
	this.container_.style.display = 'block';
}

GMarker.prototype.BuildingToolTipInstance = null;

GMarker.prototype.openBuildingToolTip = function(content, divLocation, width, height) 
{
	// don't show the tool tip if there is acustom info window
	if(this.BuildingToolTipInstance == null) 
	{
		this.BuildingToolTipInstance = new BuildingToolTip(this, content, divLocation, width, height)
		map.addOverlay(this.BuildingToolTipInstance);
	}
}

GMarker.prototype.closeBuildingToolTip = function() 
{
	if(this.BuildingToolTipInstance != null) 
	{
		map.removeOverlay(this.BuildingToolTipInstance);
		this.BuildingToolTipInstance = null;
	}
}
*/
function BuildingToolTip(marker, name, divLocation, width, height) 
{
	this.marker_ = marker;
	this.name_ = name;
	this.html_ = "<div>" + name + "</div>";
	this.divLocation_ = divLocation;

	this.width_ = width; // Kartenbreite
	this.height_ = height; // Kartenhöhe
}

BuildingToolTip.prototype = new GOverlay();

BuildingToolTip.prototype.initialize = function(map) 
{
	var buildingDiv = document.createElement("div");
	buildingDiv.setAttribute("class", "buildingDiv");
	buildingDiv.style.display = 'none';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(buildingDiv);
	
	this.map_ = map;
	this.container_ = buildingDiv;
}

BuildingToolTip.prototype.remove = function() 
{
	this.container_.parentNode.removeChild(this.container_);
}

BuildingToolTip.prototype.copy = function() 
{
	return new BuildingToolTip(this.html_);
}

BuildingToolTip.prototype.redraw = function(force) 
{
	if (!force) return;
	
	var name = this.name_;
	
	var name = name.replace(/&auml;/, "a");
	var name = name.replace(/&Auml;/, "A");
	var name = name.replace(/&uuml;/, "u");
	var name = name.replace(/&Uuml;/, "U");
	var name = name.replace(/&ouml;/, "o");
	var name = name.replace(/&Ouml;/, "O");
	var name = name.replace(/&szlig;/, "ß");	
	var laenge = name.length;		
	
	var width_TT = laenge * 7; // Breite des ToolTips
	var height_TT =15; // Höhe des ToolTips
	//Höhe dynamisch anpassen
	/*
	if (width_TT >= 170)
	{
		width_TT = 180;
		height_TT = 30;
	}
	else
	{
		height_TT = 15;
	}	
	*/
	
	var x_correction = 0;
	var y_correction = 0;

	// kontrolliert ob die Breite des ToolTips über die Grenzen des Div-Containers ragt und passt entsprechend an
	if (this.divLocation_.x > (this.width_ - width_TT - 15)) { x_correction = (this.width_ - width_TT - 15 - this.divLocation_.x); } 

	// kontrolliert ob die Höhe des ToolTips über die Grenzen des Div-Containers ragt und passt entsprechend an
	//if (this.divLocation_.y > (this.height_ - height_TT - 15)) { y_correction = -135; } 
	if (this.divLocation_.y > (this.height_ - height_TT - 15)) { y_correction = ((-1) * height_TT) - 35; } 
	
	var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());	
	this.container_.innerHTML = this.html_;
	this.container_.style.position = 'absolute';
	this.container_.style.left = (pixelLocation.x + x_correction) + "px";
	this.container_.style.top = (pixelLocation.y + y_correction) + "px";	
	this.container_.style.width = width_TT + 'px';
	this.container_.style.height = height_TT + 'px';
	this.container_.style.overflow = 'hidden';
	this.container_.style.background = '#FFFFFF';	
	this.container_.style.border = '1px solid #9C9D9F'; 
	this.container_.style.padding = '4px';
	this.container_.style.display = 'block';
}

GMarker.prototype.BuildingToolTipInstance = null;

GMarker.prototype.openBuildingToolTip = function(content, divLocation, width, height) 
{
	// don't show the tool tip if there is acustom info window
	if(this.BuildingToolTipInstance == null) 
	{
		this.BuildingToolTipInstance = new BuildingToolTip(this, content, divLocation, width, height)
		map.addOverlay(this.BuildingToolTipInstance);
	}
}

GMarker.prototype.closeBuildingToolTip = function() 
{
	if(this.BuildingToolTipInstance != null) 
	{
		map.removeOverlay(this.BuildingToolTipInstance);
		this.BuildingToolTipInstance = null;
	}
}
