// Author: Alexey Deryabin
// alextheone@mail.ru
// Source: www.rybolov.ru

var __x,__y,__l,__b,__t
var attr_name = "hnt"
var blank_text = "(откроется в новом окне)"; // текст для ссылок с target="_blank"
var nav,old,iex=(document.all),__d=document.body
if(navigator.appName=="Netscape"){(document.layers)?nav=true:old=true}
if(!old){
 var skn=(nav)?document.hnt:hnt.style
 if(nav)document.captureEvents(Event.MOUSEMOVE)
 document.onmousemove=get_mouse
 window.onload = on_load
}
function show(e){
   el = window.event ? window.event.srcElement : e.currentTarget;
   if(!el.getAttribute(attr_name)) return;
   show_msg(el.getAttribute(attr_name));
}
function hide(e){
   show_msg()
}
function load(o, e, a){
   if (o.addEventListener) o.addEventListener(e, a, false); // was true--Opera7b workaround!
   else if (o.attachEvent) o.attachEvent("on" + e, a);
   else return null;
}
function on_load(e) {
   if (document.createElement) {
      a = document.all ? document.all : document.getElementsByTagName("*");
      aLength = a.length;
      for (var i = 0; i < aLength; i++){
         title = a[i].getAttribute("title");
         if (title.type) { // in case of input object name="title"
            continue;
         }
         alt = a[i].getAttribute("alt");
         blank = blank_text && (a[i].getAttribute("target") == "_blank");
         if (title || blank) {
            a[i].setAttribute(attr_name, blank ? (title ? title + " " + blank_text : blank_text) : title);
            if (a[i].getAttribute(attr_name)){
               a[i].removeAttribute("title");
               if (alt && a[i].complete) a[i].removeAttribute("alt");
               load(a[i], "mouseover", show);
               load(a[i], "mouseout", hide);
            }
         } else if (alt && a[i].complete){
            a[i].setAttribute(attr_name, alt);
            if (a[i].getAttribute(attr_name)){
               a[i].removeAttribute("alt");
               load(a[i], "mouseover", show);
               load(a[i], "mouseout", hide);
            }
         }
      }   
   }
}
function mouse_move(_x,_y) {
   _x-=__l>>1;
   //_x-=x%5;
   if(iex) {
      if(_x<__d.scrollLeft)_x=__d.scrollLeft
      if(_x+__l>__d.scrollLeft+__d.scrollWidth)_x=__d.scrollLeft+__d.scrollWidth-__l
   }
   skn.left=_x+"px";
//   _y+=19;_y-=_y%20;
   _y+=20
   skn.top=_y+"px"
}
function get_mouse(e){
 __x = window.event ? event.clientX + __d.scrollLeft : e.pageX;
 __y = window.event ? event.clientY + __d.scrollTop  : e.pageY;
 if(__b)mouse_move(__x,__y)
}             
function show_msg(msg){
 if(msg) {
   beg=0;__l=0;
   do {
      pos=msg.indexOf("",beg);
      if (beg+__l<pos)__l=pos-beg;
      beg=pos+1
   } while (beg>0);
   if(__l==0)__l=msg.length;
   __l=(__l>50?300:((__l>30)?__l*7:__l*8));
   var content = (msg.indexOf(":\t") != -1)
      ?  "<table bgcolor=#f0f0ff class=hint border=0 width="
         +__l+" cellpadding=0 cellspacing=0>"
         +"<tr><td valign=top class=blue nowrap align=right>"
         +msg.replace(//g,
            "</td></tr><tr><td valign=top class=blue nowrap align=right>&nbsp;")
               .replace(/:\t/g,"&nbsp;</td><td>&nbsp;")
         +"</td></tr></table>"
      :  "<table class=hint border=0 width="+__l+" cellpadding=2 cellspacing=0>"
         +"<td bgcolor=#f0f0ff>"
         +msg.replace(//g, "<br>")
         +"</td></table>"
  if(old){
   window.defaultStatus=msg.replace(//g, " ", replace(/\t/g, " ", msg));
  } else{
   if(nav){skn.document.open();skn.document.write(content);skn.document.close()}
   if(iex){document.all("hnt").innerHTML=content}
   __b = true
   __t = setTimeout("skn.visibility='visible';", 1);
  }
 } else {
  if(old)window.defaultStatus=msg
  else{__b=false;clearTimeout(__t);skn.visibility="hidden";skn.left=-990;skn.top=-990}
 }
}
