function enableTooltips(id)
{
	var links,i,h;
	if(!document.getElementById || !document.getElementsByTagName) return;
	h=document.createElement("div");
	h.id="stt";
	h.setAttribute("id","stt");
	h.style.position="absolute";
	document.getElementsByTagName("body")[0].appendChild(h);
	if(id==null) links=document.getElementsByTagName("*");
	else links=document.getElementById(id).getElementsByTagName("*");
	for(i=0;i<links.length;i++){ Prepare(links[i]); }
}

function Prepare(el)
{
	var tooltip,t,b,s,l,str;
	t=el.getAttribute("title");
	str = '';
	if(t==null || t.length==0) return;
	else  str += t;
	el.removeAttribute("title");
	el.removeAttribute("alt");
	tooltip=CreateEl("div","tooltip");
	s=CreateEl("div","top");
	s.appendChild(document.createTextNode(str));
	tooltip.appendChild(s);
	b=CreateEl("div","bottom");
	l=el.getAttribute("href");
	if(l==null || l=='#'){l = '';}
	else
	{
		if(l.length>30) l=l.substr(0,27)+"...";
		l="Адрес: "+l;
	}
	b.appendChild(document.createTextNode(l));
	tooltip.appendChild(b);
	setOpacity(tooltip);
	el.tooltip=tooltip;
	el.onmouseover=showTooltip;
	el.onmouseout=hideTooltip;
//	el.onclick=hideTooltip;
	el.onmousemove=showhideTooltip;
//	el.onfocus=showTooltip;
//	el.onblur=hideTooltip;
}

function showTooltip(e)
{
	document.getElementById("stt").appendChild(this.tooltip);
	Locate(e);
}

function hideTooltip(e)
{
	var d=document.getElementById("stt");
	if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function showhideTooltip(e)
{
	var d=document.getElementById("stt");
	if(d.childNodes.length>0) d.removeChild(d.firstChild);
	document.getElementById("stt").appendChild(this.tooltip);
	Locate(e);
}

function setOpacity(el)
{
	el.style.filter="alpha(opacity:90)";
	el.style.KHTMLOpacity="0.90";
	el.style.MozOpacity="0.90";
	el.style.opacity="0.90";
}

function CreateEl(t,c)
{
	var x=document.createElement(t);
	x.className=c;
	x.style.display="block";
	return(x);
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function Locate(e)
{
	var posx=0,posy=0,_alt_x=0,_alt_y=0,_xx=0,_yy=0;
	if(e==null) e=window.event;
	if(e.pageX || e.pageY)
	{
    	posx=e.pageX; posy=e.pageY;
	}
	else if(e.clientX || e.clientY)
	{
	   	if(document.documentElement.scrollTop)
   		{
       		posx=e.clientX+document.documentElement.scrollLeft;
	       	posy=e.clientY+document.documentElement.scrollTop;
    	}
	   	else
   		{
       		posx=e.clientX+document.body.scrollLeft;
	       	posy=e.clientY+document.body.scrollTop;
		}
	}

	_xx = getClientWidth(); // ширина рабочей области окна
	_yy = getClientHeight(); // высота рабочей области окна
	_alt_x = posx+document.getElementById("stt").clientWidth; // тек. позиция мыши X + ширина подсказки
	_alt_y = posy+23+document.getElementById("stt").clientHeight; // тек. позиция мыши Y + высота подсказки

    if( _alt_x >= _xx ) posx = posx - document.getElementById("stt").clientWidth;
    if( _alt_y >= _yy ) posy = posy - document.getElementById("stt").clientHeight;
    else posy = posy + 23;

	document.getElementById("stt").style.top=(posy)+"px";
	document.getElementById("stt").style.left=(posx)+"px";
}