function EStyle(stemImage, stemSize, boxClass, boxOffset) {
  this.stemImage = stemImage;
  this.stemSize = stemSize;
  this.boxClass = boxClass;
  this.boxOffset = boxOffset;
  
  var agent = navigator.userAgent.toLowerCase();
  
  var fudge = 5;  // assume Netscape if no match found
 
  if (agent.indexOf("opera") > -1) {
    fudge = 3;
  }   
  if (agent.indexOf("firefox") > -1) {
    fudge = 5;
  }   
  if (agent.indexOf("safari") > -1) {
    fudge = 5;
  }   
  if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){
    fudge = 0;
  }
  this.fudge = fudge;
}
function eb_map_window(map) {
  this.map=map;
  this.estyle=new EStyle("/_imgs/gmaps/stem7.png", new GSize(24,24),  "eb_map_window", new GPoint(-10,23));
  this.visible = false;
  this.ie = false;
  var agent = navigator.userAgent.toLowerCase();
  if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){ this.ie = true} else {this.ie = false}
} 
eb_map_window.prototype = new GOverlay();
eb_map_window.prototype.initialize = function(map) {
  var div1 = document.createElement("div");
  div1.style.position = "absolute";
  map.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(div1);
  var div2 = document.createElement("div");
  div2.style.position = "absolute";
  div2.style.width = this.estyle.stemSize.width+"px";
  map.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(div2);
  this.div1 = div1;
  this.div2 = div2;
}
eb_map_window.prototype.openOnMap = function(point, html, offset) {
  this.offset = offset||new GPoint(0,0);
  this.point = point;
  this.div1.innerHTML = '<div class="' + this.estyle.boxClass + '"><nobr>' + html + '</nobr></div>';
  if (this.ie && this.estyle.stemImage.toLowerCase().indexOf(".png")>-1) {
    var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.estyle.stemImage+"', sizingMethod='scale');";
    this.div2.innerHTML = '<div style="height:' +this.estyle.stemSize.height+ 'px; width:'+(this.estyle.stemSize.width+10)+'px; ' +loader+ '" ></div>';
  } else {
    this.div2.innerHTML = '<img src="' + this.estyle.stemImage + '" width="' + this.estyle.stemSize.width +'" height="' + this.estyle.stemSize.height +'">';
  }
  var z = GOverlay.getZIndex(this.point.lat());
  this.div1.style.zIndex = z;
  this.div2.style.zIndex = z+1;
  this.visible = true;
  this.show();
  this.redraw(true);
	this.centermap();
}
eb_map_window.prototype.centermap = function() {

	if(this.map.getZoom() == 5)
		centerbox=2;
	else if(this.map.getZoom() == 9)
		centerbox=0.1;
	else
		centerbox = 0;

	var center = new GLatLng((this.point.lat()+centerbox), this.point.lng());
	this.map.panTo(center);
}
eb_map_window.prototype.openOnMarker = function(marker,html) {
  var vx = marker.getIcon().iconAnchor.x - marker.getIcon().infoWindowAnchor.x;
  var vy = marker.getIcon().iconAnchor.y - marker.getIcon().infoWindowAnchor.y;
  this.openOnMap(marker.getPoint(), html, new GPoint(vx,vy));
}


eb_map_window.prototype.redraw = function(force) {
  if (!this.visible) {return;}
  var p = this.map.fromLatLngToDivPixel(this.point);
  this.div2.style.left   = (p.x + this.offset.x) + "px";
  this.div2.style.bottom = (-p.y + this.offset.y -this.estyle.fudge) + "px";
  this.div1.style.left   = (p.x + this.offset.x + this.estyle.boxOffset.x) + "px";
  this.div1.style.bottom = ((-p.y + this.offset.y + this.estyle.boxOffset.y)-this.estyle.fudge) + "px";
}

eb_map_window.prototype.remove = function() {
  this.div1.parentNode.removeChild(this.div1);
  this.div2.parentNode.removeChild(this.div2);
  this.visible = false;
}

eb_map_window.prototype.copy = function() {
  return new eb_map_window(this.map, this.estyle);
}

eb_map_window.prototype.show = function() {
  this.div1.style.display="";
  this.div2.style.display="";
  this.visible = true;
}

eb_map_window.prototype.hide = function() {
  this.div1.style.display="none";
  this.div2.style.display="none";
  this.visible = false;
}

eb_map_window.prototype.isHidden = function() {
  return !this.visible;
}

eb_map_window.prototype.supportsHide = function() {
  return true;
}

eb_map_window.prototype.zindex = function(zin) {
  var z = GOverlay.getZIndex(this.point.lat());
  this.div1.style.zIndex = z+zin;
  this.div2.style.zIndex = z+1+zin;
}