function InfoBox(latlng, opts) {
  this.latlng_ = latlng;
  this.content_ = opts.content || "InfoText";
  this.offsetVertical_ = opts.offsetVertical || -5;
  this.offsetHorizontal_ = opts.offsetHorizontal || -5;

  this.className_ = opts.className || "";  
  this.height_ = opts.height || 100;
  this.width_ = opts.width || 200;
}
/* GOverlay class  */
InfoBox.prototype = new GOverlay();

/* DIV InfoBox */
InfoBox.prototype.initialize = function(map) {
  var div = document.createElement("div");

  if (this.className_ != "") {
    this.map_ = map;
	var pixPosition = this.map_.fromLatLngToContainerPixel(this.latlng_);
	var strclass="infoBox";
	if (pixPosition.x>210)
	{	strclass+="l";
		this.offsetHorizontal_-=200;}	
	else
	{	strclass+="r";	}
	if (pixPosition.y < 130)
	{	strclass+="d";
		this.offsetVertical_+=120;}	
	else
	{	strclass+="u";	}
	div.className = strclass;
	//div.className = this.className_;
	div.style.paddingTop = "15px";
  } else {
    div.style.border = "1px solid #000000";
    div.style.position = "absolute";
    div.style.background = "../Bilder/infowindow_r.png";
    //div.style.backgroundColor = "#FFFFFF";
    div.style.padding = "2px";
    div.style.width = this.width_ + "px";
    div.style.height = this.height_ + "px";
  } 

  var contentDiv = document.createElement("div");
  contentDiv.innerHTML = this.content_;

 /* var topDiv = document.createElement("div");
  topDiv.style.textAlign = "right";
  topDiv.style.paddingRight = "25px";
  var closeImg = document.createElement("img");
  closeImg.src = "http://localhost/speedy_neu/Bilder/close.gif";
  topDiv.appendChild(closeImg);

  function removeInfoBox(ib, m) {
    return function() { 
      GEvent.trigger(ib, "closeclick");
      m.removeOverlay(ib);
    };
  }
  
  GEvent.addDomListener(closeImg, 'click', removeInfoBox(this, map));
 
  div.appendChild(topDiv);
  */
  div.appendChild(contentDiv);
  div.style.display = 'none';

  map.getPane(G_MAP_MARKER_PANE).appendChild(div);

  this.map_ = map;
  this.div_ = div;
}

/* Remove DIV */
InfoBox.prototype.remove = function() {
  this.div_.parentNode.removeChild(this.div_);
}

InfoBox.prototype.copy = function() {
  var opts = {};
  opts.latlng = this.latlng_;
  opts.content = this.content_;
  opts.offsetVertical = this.offsetVertical_;
  opts.offsetHorizontal = this.offsetHorizontal_;

  opts.className = this.className_ || "";  
  opts.height = this.height_;
  opts.width = this.width_;
  return new InfoBox(this.latlng, opts);
}

InfoBox.prototype.redraw = function(force)
{
  if (!force) return;

  var pixPosition = this.map_.fromLatLngToDivPixel(this.latlng_);

  this.div_.style.width = this.width_ + "px";
  this.div_.style.left = (pixPosition.x + this.offsetHorizontal_) + "px";
  this.div_.style.height = this.height_ + "px";
  this.div_.style.top = (pixPosition.y + this.offsetVertical_) + "px";
  this.div_.style.display = 'block';
  
}

