var Tooltip = Class.create();
Tooltip.prototype = {

//local variables
m_controlSurface: null,
m_currentSender: null,

//
// Constructor
initialize: function(objectOptions)
	{
		ParseOptions(objectOptions, this);

		// Create container for the status bar object
		this.m_controlSurface = createDiv("TooltipContainer");
		this.m_controlSurface.style.display = "none";
		
		document.body.appendChild(this.m_controlSurface);
		
		mSpaceApplication.Subscribe("Tooltip.Show", this);
		mSpaceApplication.Subscribe("Tooltip.Hide", this);

	},
	
Notify: function(eventName, eventParams)
	{
		switch(eventName)
		{
			case 'Tooltip.Show' : this.ShowTooltip(eventParams); break;
			case 'Tooltip.Hide' : this.HideTooltip(eventParams); break;		
			default: break;
		}
	},	

ShowTooltip: function(eventParams)
	{
		if (eventParams.sender && eventParams.x && eventParams.y && HelpOn != null && !HelpOn)
		{
			this.m_currentSender = eventParams.sender;
			
			
			if (eventParams.domNode)
			{
				this.m_controlSurface.innerHTML = "";
				this.m_controlSurface.appendChild(eventParams.tooltip);
			}
			else if (eventParams.message)
			{
				this.m_controlSurface.innerHTML = eventParams.message;
			}

			if(eventParams.x > window.innerWidth/2)
			{
				this.m_controlSurface.style.left = '';
				this.m_controlSurface.style.right = (window.innerWidth-eventParams.x) + "px";
			}
			else
			{
				this.m_controlSurface.style.left = eventParams.x + "px";
				this.m_controlSurface.style.right = '';
			}
			
			this.m_controlSurface.style.top = eventParams.y + "px";
			
			this.m_controlSurface.style.display = "";
		}
	},	

HideTooltip: function(eventParams)
	{
		if (eventParams.sender && (eventParams.sender==this.m_currentSender))
		{
			this.m_controlSurface.style.display = "none";
		}
	}
	
}
