var o3i_help = new Object();
o3i_help._oninstall = function(element) {
	if (element.o3_help) { return; }

	var parent = o3_reparent(element);
	o3_append_class(parent, 'o3_help');

	var span = document.createElement('div');
	span.className = 'o3_help_text';
	span.style.display = 'none';
	parent.appendChild(span);

	parent.onmouseover = o3_help_onmouseover;
	parent.onmouseout = o3_help_onmouseout;

	element.o3_help = span; 
};

o3i_help.onkeypress = function(event)
{
	if (this.o3_help_block_key) { return false; }
	return true;
};

o3i_help.onkeydown = function(event) 
{
	var code = event_get_keycode(event);
	if (code == event.DOM_VK_F1 || (!event.DOM_VK_F1 && code == 112))
	{ 
		this.o3_help.style.display = ''; 
		this.o3_help_block_key = true;
	}
	else
	{ 
		this.o3_help.style.display = 'none'; 
		this.o3_help_block_key = false;
	}
	return true;
};

o3i_help.onblur = function(event) {
	this.o3_help.style.display = 'none';
};

function o3_help_onmouseover(event) {
	this.firstChild.o3_help.style.display = '';
}

function o3_help_onmouseout(event) {
	this.firstChild.o3_help.style.display = 'none';
}

function o3_help_set(element, text)
{
	var span = element.o3_help;
	if (span)
	{
		span.appendChild(document.createTextNode(text));
		span.style.right = - span.offsetWidth + 'px';
		span.style.top = '0px';
	}
}

function o3_help_use(element, data_id)
{
	var span = element.o3_help;
	var data = document.getElementById(data_id);
	if (span && data)
	{
		span.appendChild(data);
		data.style.right = '0px';
		data.style.top = '0px';
	}
}
