
function OverlayPoi(opt_options, id) 
{
	 // Initialization
	this.setValues(opt_options);
	
	var isOpen = this.isOpen_ = false;
	var div = this.div_ = document.createElement('div');
	var divInner = this.divInner_ = document.createElement('div');
	var span = document.createElement('span');
	jQuery(span).addClass('title');
	
	jQuery(span).html(opt_options['title']);
	 
	var icon = this.icon_ = opt_options['icon'];
	div.style.cssText = 'position: absolute; display: none';
	divInner.appendChild(span);
	div.appendChild(divInner); 
	
	jQuery(div).attr('id', 'absGpsOverlayPoi_'+id)
};

OverlayPoi.prototype = new google.maps.OverlayView;

OverlayPoi.prototype.onAdd = function() {
	var pane = this.getPanes().overlayLayer;
	pane.appendChild(this.div_);
	jQuery(this.div_).css('height', '42px').
		css('width', '190px').
		css('z-index', '100').
		addClass('absolutGpsMapPoiOverlay');
		
	// Ensures the label is redrawn if the text or position is changed.
	var me = this;
	this.listeners_ = [
	                google.maps.event.addListener(this, 'position_changed',
	                function() { me.draw(); }),
	                google.maps.event.addListener(this, 'text_changed',
	                function() { me.draw(); })
	                ];
};

// Implement onRemove
OverlayPoi.prototype.onRemove = function() {
	 this.div_.parentNode.removeChild(this.div_);
	
	 // Label is removed from the map, stop updating its position/text.
	 for (var i = 0, I = this.listeners_.length; i < I; ++i) {
	   google.maps.event.removeListener(this.listeners_[i]);
	 }
};

// Implement draw
OverlayPoi.prototype.draw = function() {
	 var projection = this.getProjection();
	 var position = projection.fromLatLngToDivPixel(this.get('position'));
	
	 var div = this.div_;
	 div.style.left = position.x + 'px';
	 div.style.top = position.y-64 + 'px';
	 div.style.display = 'block';
	 jQuery(div).css('z-index', 1000);
};

OverlayPoi.prototype.mouseover = function(marker) {
	
	if (!jQuery(this.divInner_).hasClass('isOpen'))
	{
		marker.setZIndex(1001);
		jQuery(this.divInner_).addClass('isOpen');
		jQuery(this.divInner_).show();
		jQuery(this.divInner_).css('z-index', 1000);
		jQuery(this.divInner_).animate({'left': 0});
	}	
};

OverlayPoi.prototype.mouseout = function(marker) {

	jQuery(this.divInner_).animate({'left': -190}, function(){
		jQuery(this).hide();
		marker.setZIndex(0);
		jQuery(this.divInner_).css('z-index', 0);
		jQuery(this).removeClass('isOpen');		
	});
};
