var Help = Class.create();
Help.prototype = {

//local variables
m_surface: null,
m_highlight: null,
m_lastElement: null,

//
// Constructor
initialize: function(objectOptions)
	{
		ParseOptions(objectOptions, this);

		if (this.m_renderSurfaceId!=null)
		{
			this.m_surface = document.getElementById(this.m_renderSurfaceId);
		}

		this.m_surface.innerHTML = "?";
		this.m_surface.style.border = "1px";

		this.m_highlight = createDiv("HelpHighlight");
		this.m_highlight.style.display = 'none';
		this.m_highlight.title = "Click for help on this item";
		document.body.appendChild(this.m_highlight);


		mSpaceApplication.Subscribe("Help.Show", this);
		mSpaceApplication.Subscribe("Help.ShowHighlight", this);
		mSpaceApplication.Subscribe("Help.HideHighlight", this);
	
		RegisterEvent(this.m_surface, "click", this, "Toggle");
		RegisterEvent(this.m_highlight, "click", this, "ShowHelp");

	},
	
Notify: function(eventName, eventParams)
	{
		switch(eventName)
		{
			/*case 'Help.Show' : this.ShowHelp(eventParams); break;	*/
			case 'Help.ShowHighlight' : this.ShowHighlight(eventParams); break;		
			case 'Help.HideHighlight' : this.HideHighlight(eventParams); break;
			default: break;
		}
	},

Toggle: function()
	{
		HelpOn = !HelpOn;

		if(HelpOn)	
			this.m_surface.innerHTML = "<b>?</b>";
		else
		{
			this.m_surface.innerHTML = "?";
			this.m_highlight.style.display = 'none';
		}

		mSpaceApplication.FireEvent("Cursor.Refresh");
	},

ShowHelp: function(eventParams)
	{
		switch(this.m_lastElement)
		{
			case 'ColumnBrowser.Closed':
				mSpaceApplication.FireEvent("InformationControl.SetContents", 'This is a closed columnbrowser');
				break;
			case 'ColumnBrowser.ClosedColumns':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/columnbar.html');
				break;
			case 'ColumnBrowser.ScrollLeft':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/columnbar.html');
				break;
			case 'ColumnBrowser.ScrollRight':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/columnbar.html');
				break;
			case 'ColumnBrowser.Reload':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/reset.html');
				break;
			case 'Column.Open':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/colbrowser.html');
				break;
			case 'Column.Closed':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/columnbar.html');
				break;
			case 'PreviewCue':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/previewcue.html');
				break;
			case 'Promotions':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/clips.html');
				break;
			case 'Interests':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/bookmarks.html');
				break;
			case 'AdvancedSearch':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/advsearch.html');
				break;
			case 'InformationPanel':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/infopanel.html');
				break;
			case 'GeneralSearch':
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'help/searchbox.html');
				break;
			default:
				mSpaceApplication.FireEvent("InformationControl.SetUrl", 'No help for this item');
		}
	},

ShowHighlight: function(eventParams)
	{
		this.m_lastElement = eventParams.name;
		this.m_highlight.style.display = '';
		this.m_highlight.style.position = 'absolute';
		this.m_highlight.style.left = eventParams.element.offsetLeft+'px';
		this.m_highlight.style.top = eventParams.element.offsetTop+'px';
		this.m_highlight.style.width = eventParams.element.offsetWidth+'px';
		this.m_highlight.style.height = eventParams.element.offsetHeight+'px';
		this.m_highlight.style.borderWidth = '2px';
		this.m_highlight.style.borderStyle = 'solid';
		this.m_highlight.style.borderColor = 'red';
	},

HideHighlight: function()
	{
		/* This needs to go on some kind of timer to prevent flashing and loosing the ability to click on an element */
		//this.m_highlight.style.display = 'none';
	}
}
