// show dhtml acronym
abbrId='abbr';
abbrCache = "";
abbrObj = null;
abbrInterval = null;
abbrX = 0;
abbrY = 0;
abbrXof = 20;
abbrYof = -20;
abbrCanMove = false;

function abbrShow(obj,head,lnk)	{
	if ( document.body )	{
		var ttl = obj.title;
		if ( ttl.length<1 )	return;
		if ( abbrInterval != null )	{	
			clearTimeout(abbrInterval);
			abbrRemI();
		}
		
		var newDom = document.createElement("DIV");
		if (newDom==null)	return;
		abbrCache = ttl;
		obj.title="";
		newDom.id = abbrId;
		newDom.onmouseover = abbrClear;
		newDom.onmouseout = abbrSet;
		if (lnk == 'no-glossary') {
			newDom.innerHTML = '<img class="fr burinkaIco" src="/img/u/ico/ico_burinka.png" width="48" height="23" border="0" alt="" /><div class="ttl">' +head + '</div><div class="body">'+ ttl +'</div>';	
		} else {
			newDom.innerHTML = '<div class="ttl">' +head + '</div><div class="body">'+ ttl +'</div><div class="lnk">více ve <a href="/srv/www/glossary/show.do?'+lnk+'">slovníku pojmů</a></div>';	
		}
		document.body.appendChild(newDom);
		abbrCanMove = true;
		
		var scrolledFromTop = $(window).scrollTop();
		var eventOffsetX = 0;
		if (xIE4Up) {
			eventOffsetX = event.x;
			abbrX = eventOffsetX;
		} else {
			window.onmousemove=abbrMouse;
		}
		
		abbrY = $(obj).offset().top;

		xLeft(abbrId,correctX(abbrX+abbrXof));
		xTop(abbrId,correctY(abbrY+abbrYof));
		xShow(abbrId);
	}
	return true;
}

function abbrMouse(e){
	if (xIE4Up)	{
		abbrX = event.x+xScrollLeft();
		abbrY = event.y+xScrollTop();
	}
	else	{
		abbrX = e.pageX;
		//abbrY = e.pageY;
	}
	if ( abbrCanMove )	{
		xLeft(abbrId, correctX(abbrX+abbrXof) );
		xTop(abbrId, correctY(abbrY+abbrYof) );
		abbrCanMove=false;
	}
}

function correctX( x )	{
	var xs = xClientWidth()+xScrollLeft();
	var xw = xWidth(abbrId);
	if ( xs > 0 && xw != null )	{
		var dif = (x+xw)-xs;
		if ( dif>0 )	{
			x-=dif+15; // ad additional offset
		}
	}
	return x;
}

function correctY( y )	{
	var ys = xClientHeight()+xScrollTop();
	var yh = xHeight(abbrId);
	if ( ys > 0 && yh != null )	{
		var dif = (y+yh)-ys;
		if ( dif>0 )	{
			y-=dif+15; // ad additional offset
		}
	}
	return y;
}


function abbrRem(obj)	{
	abbrCanMove = false;
	if ( abbrInterval == null )	{
		abbrInterval = setTimeout(abbrRemI,1000);
		abbrObj = obj;
	}
	return true;
}

function abbrClear(obj)	{
	if ( abbrInterval != null )	{
		clearTimeout(abbrInterval);
		abbrInterval = null;
	}
}

function abbrSet(obj)	{
	if ( abbrInterval == null )	{
		abbrInterval = setTimeout(abbrRemI,1500);
	}
}

function abbrRemI()	{
	if ( document.body )	{
		if ( abbrInterval!=null )	{
			xHide(abbrId);
			var el = xGetElementById(abbrId);
			if (el != null )	{
				document.body.removeChild(el);
			}
			abbrObj.title=abbrCache;
			abbrInterval = null;
		}
	}
}
