//function ELabel(opt_options) {
function ELabel(opt_options, point, html, classname, pixelOffset, percentOpacity, overlap,quit) {
 // Initialization
 this.setValues(opt_options);

 // Label specific
 var span = this.span_ = document.createElement('span');
 span.style.cssText = 'position: relative; left: -50%; top: -8px; ' +
                      'white-space: nowrap; border: 1px solid blue; ' +
                      'padding: 2px; background-color: white';

 var div = this.div_ = document.createElement('div');
 div.appendChild(span);
 div.style.cssText = 'position: absolute; display: none';
};      
ELabel.prototype = new google.maps.OverlayView;
	  
	 

ELabel.prototype.onAdd = function() {
       
	   var pane = this.getPanes().overlayLayer;
		var div = document.createElement("div");
		var contentdiv = document.createElement("div");
		this.div_ = div;
        div.style.position = "absolute";
		
		

        
		var pane = this.getPanes().floatPane;
		
		var topDiv = document.createElement('div');
		topDiv.style.textAlign = "right";
		
		//div.style.textAlign = 'left';
	
		var closeImg = document.createElement('img');
		closeImg.src = '/public/images/closebigger.gif';
		closeImg.style.width = '16px';
		closeImg.style.height = '16px';
		//closeImg.style.float = "right";
		closeImg.style.cursor = 'pointer';
		topDiv.appendChild(closeImg);
		if (this.quit == true) div.appendChild(topDiv);
		//if (this.quit == true) div.appendChild(closeImg);
		//div.appendChild(contentdiv);
		//alert(div.firstChild.nodeValue)
		div.className =this.classname;
		
		contentdiv.innerHTML = this.html
		//contentdiv.innerHTML =  "<div style='float:right'>x</div>"+this.html
		div.appendChild(contentdiv);
		

		function removeInfoWindow(ib) {
		  return function() {
			ib.setMap(null);
		  };
		}
		google.maps.event.addDomListener(closeImg, 'click', removeInfoWindow(this));
		pane.appendChild(div);
        
        //alert(div.parentNode.innerHTML);
        if (this.percentOpacity) {        
          if(typeof(div.style.filter)=='string'){div.style.filter='alpha(opacity:'+this.percentOpacity+')';}
          if(typeof(div.style.KHTMLOpacity)=='string'){div.style.KHTMLOpacity=this.percentOpacity/100;}
          if(typeof(div.style.MozOpacity)=='string'){div.style.MozOpacity=this.percentOpacity/100;}
          if(typeof(div.style.opacity)=='string'){div.style.opacity=this.percentOpacity/100;}
        }
        if (this.overlap) {
          //var z = pane.getZIndex(this.point.lat());
          var z =100;
		  this.div_.style.zIndex = z;
        }
        if (this.hidden) {
          this.hide();
        }
};

  ELabel.prototype.draw = function() {
		
	   var projection = this.getProjection();
	   
		var p = projection.fromLatLngToDivPixel(this.point);
        var h = parseInt(this.div_.clientHeight);
        this.div_.style.left = (p.x + this.pixelOffset.width) + "px";
        this.div_.style.top = (p.y +this.pixelOffset.height - h) + "px";
      };

 ELabel.prototype.onRemove = function() {
    
	this.div_.parentNode.removeChild(this.div_);
	
};

  
	 /*  ELabel.prototype.draw = function() {
		
	   var projection = this.getProjection();
		var p = projection.fromLatLngToDivPixel(this.point);
        var h = parseInt(this.div_.clientHeight);
        this.div_.style.left = (p.x + this.pixelOffset.width) + "px";
        this.div_.style.top = (p.y +this.pixelOffset.height - h) + "px";
      };
   ELabel.prototype.onRemove = function() {
        this.div_.parentNode.removeChild(this.div_);
      };

      ELabel.prototype.copy = function() {
        return new ELabel(this.point, this.html, this.classname, this.pixelOffset, this.percentOpacity, this.overlap);
      };

      

      ELabel.prototype.show = function() {
        if (this.div_) {
          this.div_.style.display="";
          this.redraw();
        }
        this.hidden = false;
      };
      
      ELabel.prototype.hide = function() {
        if (this.div_) {
          this.div_.style.display="none";
        }
        this.hidden = true;
      };
      
      ELabel.prototype.isHidden = function() {
        return this.hidden;
      };
      
      ELabel.prototype.supportsHide = function() {
        return true;
      };

      ELabel.prototype.setContents = function(html) {
        this.html = html;
        this.div_.innerHTML = '<div class="' + this.classname + '">' + this.html + '</div>' ;
        this.redraw(true);
      };
      
      ELabel.prototype.setPoint = function(point) {
        this.point = point;
        if (this.overlap) {
          //var z = GOverlay.getZIndex(this.point.lat());
          this.div_.style.zIndex = z;
        }
        this.redraw(true);
      };
      
      ELabel.prototype.setOpacity = function(percentOpacity) {
        if (percentOpacity) {
          if(percentOpacity<0){percentOpacity=0;}
          if(percentOpacity>100){percentOpacity=100;}
        }        
        this.percentOpacity = percentOpacity;
        if (this.percentOpacity) {        
          if(typeof(this.div_.style.filter)=='string'){this.div_.style.filter='alpha(opacity:'+this.percentOpacity+')';}
          if(typeof(this.div_.style.KHTMLOpacity)=='string'){this.div_.style.KHTMLOpacity=this.percentOpacity/100;}
          if(typeof(this.div_.style.MozOpacity)=='string'){this.div_.style.MozOpacity=this.percentOpacity/100;}
          if(typeof(this.div_.style.opacity)=='string'){this.div_.style.opacity=this.percentOpacity/100;}
        }
      };

      ELabel.prototype.getPoint = function() {
        return this.point;
      };
*/
   
