var d = document;
var offsetfromcursorY=15 // y offset of tooltip
var ie=d.all && !window.opera;
var ns6=d.getElementById && !d.all;
var tipobj,op;
var prev_color=null;
var prev_textDecoration=null;

var bg = "#FFFF77";
var tbcont = '<table border="1" bordercolor="#DDBA88" cellspacing="1" cellpadding="3" bgcolor="'+bg+'"><tr><td align="center">';

/*
el  - îáúåêò
txt - òåêñò ïîäñêàçêè
img - èçîáðàæåíèå ê ïîäñêàçêå, ÍÅÎÁßÇÀÒÅËÜÍÛÉ àðãóìåíò 
*/
function toolt_i(el,txt,img) 
{
	tipobj=d.getElementById('mess');
	if (!img) { tipobj.innerHTML = tbcont+'<span class="style932">'+txt+'</span></td></tr></table>'; }
	else      { tipobj.innerHTML = tbcont+'<span class="style932">'+txt+'</span><img src="'+img+'"></td></tr></table>'; }
	op = 0.1;	
	tipobj.style.opacity = op; 
	tipobj.style.visibility="visible";
	el.onmousemove=positiontip;
	el.style.cursor='pointer'
	prev_color=el.style.color;
	el.style.color="#0000FF";
	tipobj.style.cursor="move";
	prev_textDecoration=el.style.textDecoration;
	appear();
}

/*
el  - îáúåêò
img - èçîáðàæåíèå ê ïîäñêàçêå, ÍÅÎÁßÇÀÒÅËÜÍÛÉ àðãóìåíò 
txt - òåêñò ïîäñêàçêè, ÍÅÎÁßÇÀÒÅËÜÍÛÉ àðãóìåíò, åñëè ïðîïóùåí - âûâîäèòñÿ "Êëèê - óâåëè÷èòü ôîòî<br>[Esc] - çàêðûòü ôîòî<br>Click - to increase photo,<br>[Esc] - close photo<br>"
Ôóíêöèÿ òàêæå ýìóëèðóåò ýôôåêò #HREF - öâåò òåêñòà èçì.íà ñèíèé ñ ïîä÷åðêèâàíèåì
*/
function toolt_p(el,img,txt) 
{
	var txtp;
	tipobj=d.getElementById('mess');
	if (!txt) { txtp = 'Êëèê - óâåëè÷èòü ôîòî,<br>[Esc] - çàêðûòü ôîòî<br><br>Click - to increase photo,<br>[Esc] - close photo<br>'; }
	else      { txtp = txt; }
	if (!img) { tipobj.innerHTML = tbcont+'<span class="style932">'+txtp+'</span></td></tr></table>'; }
	else      { tipobj.innerHTML = tbcont+'<span class="style932">'+txtp+'</span><img src="'+img+'"></td></tr></table>'; }
	op = 0.1;	
	tipobj.style.opacity = op; 
	tipobj.style.visibility="visible";
	el.onmousemove=positiontip;
	el.style.cursor='pointer';
	prev_color=el.style.color;
	el.style.color="#0000FF";
	prev_textDecoration=el.style.textDecoration;
	el.style.textDecoration="underline";
	appear();
}

function hide_info(el) 
{
	d.getElementById('mess').style.visibility='hidden';
	el.onmousemove='';
	el.style.color=prev_color;
	prev_color=null;
	el.style.textDecoration=prev_textDecoration;
	prev_textDecoration=null;
}

function ietruebody(){
return (d.compatMode && d.compatMode!="BackCompat")? d.documentElement : d.body
}

function positiontip(e) 
{
	var curX=((ns6)?e.pageX : event.clientX+ietruebody().scrollLeft)+10;
	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 < 1) 
  {
    op += 0.1;
    tipobj.style.opacity = op;
    tipobj.style.cursor="hand";
    tipobj.style.filter = 'alpha(opacity='+op*100+')';
    t = setTimeout('appear()', 20);
  }
}


