FSite2._helperInitClose = function()
{
	if (!this._timeout)
		this._timeout = setTimeout(FSite2._callRef(FSite2._helperClose, this), 100);
}

FSite2._helperCancelClose = function(helper)
{
	if (this && !helper)
		helper = this;
	if (helper._timeout)
	{
		clearTimeout(helper._timeout);
		helper._timeout = null;
	}
}

FSite2._helperClose = function(helper)
{
	if (!helper)
		helper = this;
	helper.style.display = 'none';
	helper.style.visibility = 'hidden';
	clearInterval(helper._showlayer);
	helper._showlayer=null;
	helper._opacity=null;
	if (helper.parentNode)
		helper.parentNode.removeChild(helper);
	helper._element._helpBox = null;
}

FSite2._initShow = function ()
{
	if (!this._showlayer)
	{
		this._showlayer=setInterval(FSite2._callRef(FSite2._ShowLayerAnimated, this),50)
	}
}

FSite2._ShowLayerAnimated = function (el)
{
	op=new Number(el._opacity);
	if (isNaN(op))op=0;
	next=(100-op)/5;
	op=op+next;
	if (op>100)
	{
		op=100;
		clearInterval(el._showlayer);
		el._showlayer=null;
	}
	el._opacity=op;
	el.style.opacity=el._opacity/100;
	el.style.filter='alpha(opacity='+el._opacity+')';
}

FSite2.extendHelpers = function(node, params)
{
	if (!node)
		node = document.body;
	var bd = FSite2.getElementsByClassName(params.helperClass, node);
	if (!params.helperElementId)
		params.helperElementId = 'FSite2_helper';
	for (var i = 0, a = [], d; d = bd[i++];)
	{
		if (d._helper) continue;
		d._helper=true;
		if (d.getAttribute('title'))
		{
			d.setAttribute('alt', d.getAttribute('title'));
			d.removeAttribute('title');
		}
		if (params.helperTrackClass && RegExp('\\b' + params.helperTrackClass + '\\b', 'gi').test(d.className))
		{
			d._helperTrack = true;
			d.onmousemove = function(event) {
				if (this._helpBox)
				{
					widthScreen = window.getWindowWidth()-22;
					widthBox = window.getObjectWidth(this._helpBox);
					maxR = Math.round(widthBox/2)+getMouseXY(event)[0];
					minR = getMouseXY(event)[0]-Math.round(widthBox/2);
					if (minR<0)
						this._helpBox.style.left = (Math.round(widthBox/2))+'px';
					else if (maxR>widthScreen)
						this._helpBox.style.left = (widthScreen-Math.round(widthBox/2)+window.getScrollX())+'px';
					else
						this._helpBox.style.left = getMouseXY(event)[0]+'px';
					this._helpBox.style.top = getMouseXY(event)[1] + 'px';
				}
			}
		}
		d.onmouseover = function (event) {
			if (!this.getAttribute('alt'))
				return;
			this.setAttribute('_alt', this.getAttribute('alt'));
			this.setAttribute('alt', '');
			if (!event)
				event = window.event;
			var box;
			if (!(box = document.getElementById(params.helperElementId)))
			{
				box = document.createElement('div');
				document.body.appendChild(box);
				box._opacity=0;
				box._helperInitClose = FSite2._helperInitClose;
				box._helperInitCancelClose = FSite2._helperInitCancelClose;
				box._helperCancelClose = FSite2._helperCancelClose;
				box._helperClose = FSite2._helperClose;
				box.id = params.helperElementId;
				box.style.position = 'absolute';
				posBox_x = getMouseXY(event)[0];
				posBox_y = getMouseXY(event)[1];
				box.style.left = posBox_x + 'px';
				box.style.top = posBox_y + 'px';
				if (params.helperElementClass)
					box.className = params.helperElementClass;
				box.style.opacity=Math.round(box._opacity/100);
				box.style.filter='alpha(opacity='+box._opacity+')';
				if (!this._helperTrack)
				{
					box.onmouseover = function()
					{
						this._helperCancelClose();
					}
					box.onmouseout = function()
					{
						this._helperInitClose();
					}
				}
				box.initShow = FSite2._initShow;
				box.initShow();
			}
			this._helpBox=box;
			box._element = this;
			box.innerHTML = this.getAttribute('_alt');
			this._helper = box;
			this._helper._helperCancelClose();
		}
		if (d.onclick)
			d._onclick_helper=d.onclick;
			
		d.onclick = function (event) {
			if (this._onclick_helper) this._onclick_helper();
			if (this._helpBox) this._helpBox._helperClose();
		}
		d.onmouseout = function (event) {
			if (this.getAttribute('_alt'))
			{
				this.setAttribute('alt', this.getAttribute('_alt'));
				this.removeAttribute('_alt');
			}
			if (this._helper) this._helper._helperInitClose();
		}
	//if(window.addEventListener)
	//  d.addEventListener('click', d.onmouseout, false);
	//else if(window.attachEvent)
	//  d.attachEvent('onclick', d.onmouseout);
	}
}
