function RMarkerNamespace() {

var n4=(document.layers);
var n6=(document.getElementById&&!document.all);
var ie=(document.all);
var o6=(navigator.appName.indexOf("Opera") != -1);
var safari=(navigator.userAgent.indexOf("Safari") != -1);

function RMarker( a, b, tooltipContent, r_link) {
    this.parent = GMarker;
    this.parent(a,b);
    if ( typeof tooltipContent != "undefined" ) {
        this.setTooltip( tooltipContent );
    }
	this.r_link = r_link;
}

RMarker.prototype = new GMarker(new GLatLng(0,0));

RMarker.prototype.setTooltip = function( string ) {
    this.tooltip = {};
    this.tooltip.contents = string;
    this.timeout = null;
};

RMarker.prototype.initialize = function( a ) {
    try {
        GMarker.prototype.initialize.call(this, a);
	GEvent.bind(this, "mouseover", this, this.onMouseOver);
	GEvent.bind(this, "mouseout",  this, this.onMouseOut);
	GEvent.bind(this, "click",     this, this.onClick);
	this.map = a;
    } catch(e) { }
}

RMarker.prototype.remove = function( a ) {
    GMarker.prototype.remove.call(this);
    if ( this.tooltipObject ) {
        document.body.removeChild(this.tooltipObject);
	}
}

RMarker.prototype.onInfoWindowOpen = function() {
    this.hideTooltip();
    GMarker.prototype.onInfoWindowOpen.call(this);
}

RMarker.prototype.onClick = function() {
	if (this.r_link) {
		window.open(this.r_link);
	}
}

RMarker.prototype.onMouseOver = function()
{
	if (this.r_link)
        {
	    this.showTooltip();
	    clearTimeout(this.timeout);
	}
}

RMarker.prototype.onMouseOut = function() {
	if (this.r_link) {
		// close tooltip after 1 second
		this.timeout = setTimeout(this.hideTooltip.bind(this), 200);
	}
}

RMarker.prototype.showTooltip = function() {
    if ( this.tooltip ) {
        if ( typeof this.tooltipObject == "undefined" ) {
            this.tooltipObject = document.createElement("div");
			this.tooltipObject.style.className  = 'tooltip';
            this.tooltipObject.style.display    = "none";
            this.tooltipObject.style.position   = "absolute";
            this.tooltipObject.style.zIndex     = 50000;
            this.tooltipObject.innerHTML        = "<div class=\"tooltip_text\"><div style='margin:3px;'>" + this.tooltip.contents + "</div></div><div class='tooltip_shadow'><img src='/images/tooltip_shadow.png' class='tooltip_shadow'></div><div class='tooltip_arrow'><img src='/images/tooltip_arrow.png' class='tooltip_arrow'></div>";
			this.tooltipObject.onmouseover      = this.onMouseOver.bind(this);
			this.tooltipObject.onmouseout       = this.onMouseOut.bind(this);
			
			document.body.appendChild(this.tooltipObject);
        }

		function getElementPosition(elem) {
		    var offsetTrail = elem;
		    var offsetLeft = 0;
		    var offsetTop = 0;
		    while (offsetTrail) {
		        offsetLeft += offsetTrail.offsetLeft;
		        offsetTop += offsetTrail.offsetTop;
		        offsetTrail = offsetTrail.offsetParent;
		    }
		    if (navigator.userAgent.indexOf("Mac") != -1 && 
		        typeof document.body.leftMargin != "undefined") {
		        offsetLeft += document.body.leftMargin;
		        offsetTop += document.body.topMargin;
		    }
		    return {left:offsetLeft, top:offsetTop};
		}

		
		var tlcLatLng = this.map.fromContainerPixelToLatLng(new GPoint(0,0), true);
		var tlcDivPixel = this.map.fromLatLngToDivPixel(tlcLatLng);
		var pointDivPixel = this.map.fromLatLngToDivPixel(this.getPoint());
		var c = new GPoint(pointDivPixel.x-tlcDivPixel.x, pointDivPixel.y-tlcDivPixel.y);
		var mapPos = getElementPosition(this.map.getContainer());

		this.tooltipObject.style.left = "-1000px";
        this.tooltipObject.style.top = "-1000px";
        this.tooltipObject.style.display = "block";

        var tipLeft = c.x - this.getIcon().iconAnchor.x + mapPos.left;

        this.tooltipObject.style.left = tipLeft - 20 + (this.getIcon().iconSize.width / 2) + "px";

        var tipTop = c.y - this.getIcon().iconAnchor.y + mapPos.top - this.tooltipObject.offsetHeight;

        this.tooltipObject.style.top = tipTop + 10 + "px";
    }
}

RMarker.prototype.hideTooltip = function() {
    if ( typeof this.tooltipObject != "undefined" ) {
        this.tooltipObject.style.display = "none";
    }
}

function makeInterface(a) {
    var b = a || window;
    b.RMarker = RMarker;
}

makeInterface();
}

RMarkerNamespace();