var offsetfromcursorY=15 // y offset of tooltip
var ie=document.all
var ns6=document.getElementById&&!document.all
var tipobj,op;
		
function showhint(txt, el, e, tipwidth) {
	tipobj=document.getElementById('hintbox');
	tipobj.innerHTML=txt;
	if (tipwidth!=""){
		tipobj.widthobj=tipobj.style
		tipobj.widthobj.width=tipwidth
	}
	op = 0.1;	
	tipobj.style.opacity = op; 
	tipobj.style.visibility="visible";
	el.onmousemove=positiontip;
	appear();
	el.onmouseout=hidetip
}

function hidetip(e){
tipobj.style.visibility="hidden"
tipobj.style.left="-500px"
}

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function positiontip(e) { //Позиционирование хинта относительно курсора
	var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	var winwidth=ie? ietruebody().clientWidth : window.innerWidth-20
	var winheight=ie? ietruebody().clientHeight : window.innerHeight-20
	
	var rightedge=ie? winwidth-event.clientX : winwidth-e.clientX;
	var bottomedge=ie? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;

	if (rightedge < tipobj.offsetWidth)	tipobj.style.left=curX-tipobj.offsetWidth+"px";
	else tipobj.style.left=curX+"px";

	if (bottomedge < tipobj.offsetHeight) tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
	else tipobj.style.top=curY+offsetfromcursorY+"px";
}

function appear() {	
	if(op < 0.8) { //Прозрачность. 1.0 - полностью НЕ прозрачно
		op += 0.05; //Шаг перехода
		tipobj.style.opacity = op;
		tipobj.style.filter = 'alpha(opacity='+op*100+')';
		t = setTimeout('appear()', 30); //Время задержки
	}
}

