
 // create a constructor
    var tooltip;
    var tooltipDiv;
    function Tooltip(options) {
    	// Now initialize all properties.
    	this.marker_ = options.marker;
    	this.content_ = options.content;
    	this.map_ = options.marker.get('map');
    	this.cssClass_ = options.cssClass || null;
    	this.first_ = true;
    	// We define a property to hold the content's
    	// div. We'll actually create this div
    	// upon receipt of the add() method so we'll
    	// leave it null for now.
    	//this.div_ = null;
    	//Explicitly call setMap on this overlay
    	this.setMap(this.map_);
    	var me = this;
    	// Show tooltip on mouseover event.
//    	google.maps.event.addListener(me.marker_, 'mouseover', function() {
//    		me.show();
//    	});
//    	// Hide tooltip on mouseout event.
//    	google.maps.event.addListener(me.marker_, 'mouseout', function() {
//    		me.hide();
//    	});
    }
    // Now we extend google.maps.OverlayView()
    Tooltip.prototype = new google.maps.OverlayView();
    //We must implement three functions: onAdd, draw and onRemove, add the following lines:
    // onAdd is one of the functions that we must implement,
    // it will be called when the map is ready for the overlay to be attached.
    Tooltip.prototype.onAdd = function() {
    	// Create the DIV and set some basic attributes.
    	if(tooltipDiv == null){
    		tooltipDiv = document.createElement('DIV');
    		tooltipDiv.style.position = "absolute";
    		// Hide tooltip
    		tooltipDiv.style.visibility = "hidden";
    		if (this.cssClass_)
    			tooltipDiv.className += " " + this.cssClass_;
    	}
    	//Attach content to the DIV.
    	tooltipDiv.innerHTML = this.content_;
    	// Set the overlay's div_ property to this DIV
    	// We add an overlay to a map via one of the map's panes.
    	// We'll add this overlay to the floatPane pane.
    	var panes = this.getPanes();
    	panes.floatPane.appendChild(tooltipDiv);
    	
    }
    // We here implement draw
    Tooltip.prototype.draw = function() {
    	// Position the overlay. We use the position of the marker
    	// to peg it to the correct position, just northeast of the marker.
    	// We need to retrieve the projection from this overlay to do this.
    	var overlayProjection = this.getProjection();
    	// Retrieve the coordinates of the marker
    	// in latlngs and convert them to pixels coordinates.
    	// We'll use these coordinates to place the DIV.
    	var ne = overlayProjection.fromLatLngToDivPixel(this.marker_.getPosition());
    	// Position the DIV.
    	tooltipDiv.style.left = ne.x + 'px';
    	tooltipDiv.style.top = ne.y + 'px';
    	if(this.first_){
    		tooltipDiv.style.visibility = "visible";
    		this.first_ = false;
    	}
    }
    // We here implement onRemove
    Tooltip.prototype.onRemove = function() {
    	tooltipDiv.parentNode.removeChild(tooltipDiv);
    }
    // Note that the visibility property must be a string enclosed in quotes
    Tooltip.prototype.hide = function() {
    	if (tooltipDiv) {
    		tooltipDiv.style.visibility = "hidden";
    		if(tooltipDiv.parentNode)
    			tooltipDiv.parentNode.removeChild(tooltipDiv);
    	}
    }
    Tooltip.prototype.show = function() {
    	if (tooltipDiv) {
    		tooltipDiv.style.visibility = "visible";
    	}
    }