var helpContextGlobalInstance = null;

function helpContextObject(in_strInstanceName, in_strUrlHelpFile)
{
	helpContextGlobalInstance = this;
	this.strInstanceName = in_strInstanceName;
	this.strUrlHelpFile = in_strUrlHelpFile;
	this.objService = null;
	this.intMouseX = 0;
	this.intMouseY = 0;

	this.OFFSET_OVERLAYS = new Array();
	this.OFFSET_OVERLAYS['nw'] = new Array();
	this.OFFSET_OVERLAYS['nw']['x'] = -235;
	this.OFFSET_OVERLAYS['nw']['y'] = -290;
	this.OFFSET_OVERLAYS['ne'] = new Array();
	this.OFFSET_OVERLAYS['ne']['x'] = -15;
	this.OFFSET_OVERLAYS['ne']['y'] = -290;
	this.OFFSET_OVERLAYS['se'] = new Array();
	this.OFFSET_OVERLAYS['se']['x'] = 20;
	this.OFFSET_OVERLAYS['se']['y'] = 20;
	this.OFFSET_OVERLAYS['sw'] = new Array();
	this.OFFSET_OVERLAYS['sw']['x'] = -235;
	this.OFFSET_OVERLAYS['sw']['y'] = 10;

	this.init = function()
	{
		this.addListeners();
		this.objService = new httpServiceObject(this.strUrlHelpFile, this.strInstanceName + '.handleResponseServiceOk');
		this.objService.strMethod = 'GET';
		this.objService.init();
		this.objService.addToSendStack();
	}

	this.addListeners = function()
	{
		var arrNodes = document.getElementsByTagName('*');
		for (var i = 0; i < arrNodes.length; i++)
		{
			if (arrNodes[i].id != null && arrNodes[i].id.toString().match(/help_context_\d+/))
			{
				arrNodes[i].onmouseover = this.show;
				arrNodes[i].onmouseout = this.hide;
			}
		}
	}

	this.handleResponseServiceOk = function()
	{
	}

	this.show = function(in_objEvent)
	{
		{
			if (in_objEvent)
			{
		    var objEvent = in_objEvent;
			}
			else
			{
		    var objEvent = window.event;
			}
			if (objEvent.target)
			{
				var objTarget = objEvent.target;
			}
			else
			{
				var objTarget = objEvent.srcElement;
			}
			var intId = objTarget.id.replace(/help_context_/, '');
			var intMouseX = objEvent.clientX + document.documentElement.scrollLeft;
			var intMouseY = objEvent.clientY + document.documentElement.scrollTop;

			var objXmlNode = getElementById(helpContextGlobalInstance.objService.lastResult, intId);
			if (objXmlNode != null)
			{
				var strText = objXmlNode.firstChild.data.replace(/^\w*(\W+)\w*$/g, '\1');
				var strPos = objXmlNode.getAttribute('position');
			}
			else
			{
				var strText = 'Hilfe ID:' + intId;
				var strPos = 'sw';
			}
			document.getElementById('help_context_text_' + strPos).innerHTML = strText;
			var objHelp = document.getElementById('help_context_' + strPos);
			objHelp.style.top = (intMouseY + helpContextGlobalInstance.OFFSET_OVERLAYS[strPos]['y'])  + "px";
			objHelp.style.left = (intMouseX + helpContextGlobalInstance.OFFSET_OVERLAYS[strPos]['x']) + "px";
			objHelp.style.display = 'block';
		}
	}

	this.hide = function(in_objEvent)
	{
		document.getElementById('help_context_nw').style.display = 'none';
		document.getElementById('help_context_ne').style.display = 'none';
		document.getElementById('help_context_se').style.display = 'none';
		document.getElementById('help_context_sw').style.display = 'none';
	}
}
