/**
 * EWindow Library for Google Maps
 * (see: http://econym.googlepages.com/ewindows.htm)
 *
 * This library is used to create custom flyout.
 * Modified by Baris Bikmaz, namics ag Zürich
 */


	function EStyle(stemImage, stemSize, boxClass, boxOffset)
	{
		this.stemImage 	= stemImage;
		this.stemSize 	= stemSize;
		this.boxClass 	= boxClass;
		this.boxOffset	= boxOffset;
	}
      
	  
	var E_STYLE_COOP = new EStyle("image/StemCoop.png", new GSize(229,54),  "estyle2", new GPoint(-110,-10));

	function EWindow(map,estyle) 
	{
		this.map		= map;
		this.estyle		= estyle;
		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}
	} 
      
    EWindow.prototype = new GOverlay();

    EWindow.prototype.initialize = function(map)
	{
		var div1 = document.createElement("div");
		div1.style.position = "absolute";
		map.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(div1);
		this.div1 = div1;
    }

	EWindow.prototype.openOnMap = function(point, html, offset, closedescr) {
		this.offset = offset||new GPoint(0,0);
		this.point  = point;
		var layout = '<div class="flyoutTop"><div class="flyoutClose" onclick="COOP.Map.ew.hide()">' + closedescr + '</div></div>'
				+'<div class="flyoutContent">'
				+ html
				+'</div>'
				+'<div class="flyoutStem"></div>';
				
		this.div1.innerHTML = '<div id="Flyout"><nobr>' + layout + '</nobr></div>';
		

		var z = GOverlay.getZIndex(this.point.lat());
		this.div1.style.zIndex = z;
		this.visible = true;
		this.show();
		this.redraw(true);
	}
      
	EWindow.prototype.openOnMarker = function(marker, html, closedescr)
	{
		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), closedescr);
	}
      

	EWindow.prototype.redraw = function(force)
	{
		if (!this.visible) {return;}
		var p = this.map.fromLatLngToDivPixel(this.point);
		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) + "px";
	}

	EWindow.prototype.remove = function()
	{
		this.div1.parentNode.removeChild(this.div1);
		this.visible = false;
	}

	EWindow.prototype.copy = function()
	{
		return new EWindow(this.map, this.estyle);
	}

	EWindow.prototype.show = function()
	{
		this.div1.style.display="";
		this.visible = true;
	}

	EWindow.prototype.hide = function() {
		this.div1.style.display="none";
		this.visible = false;
	}

	EWindow.prototype.isHidden = function() {
		return !this.visible;
	}

	EWindow.prototype.supportsHide = function() {
		return true;
	}

	EWindow.prototype.zindex = function(zin) {
		var z = GOverlay.getZIndex(this.point.lat());
		this.div1.style.zIndex = z+zin;
	}
