/*
 *  Podmienia domyslne wyswietlanie atrybutu title na wszystkich linkach w calym dokumencie
 *  @date 7. września 2007, 16:02:44
 *  @author lukasz@szakul.net
 */
 
var titles = {
  speed: 50,
  timer: '',
  tip: '',
  className: 'tip',
  
  load: function() {
    if (document.links.length) {
        for (var i=0; i < document.links.length; i++) {
             if (document.links[i].title != '') { titles.handle(document.links[i]); }
        }
       
        titles.tip = document.createElement('div');
        titles.tip.style.position = 'absolute';
        titles.tip.style.display = 'none';
        titles.tip.className = titles.className;
        document.body.appendChild(titles.tip);
    }
  },
  
  handle: function(o) {
    o.tip = o.title;
    o.title = '';
    
    o.onmouseover = function() {
      titles.timer = setTimeout(function() { titles.show(o); }, titles.speed);
      return false;
    }
    
    o.onmouseout = function() {
      clearTimeout(titles.timer);
      titles.hide(o);
    }
    
    o.onmousemove = function(evt) {
      if (typeof evt == "undefined") { evt = window.event; };
      var doc = document.documentElement;
      titles.tip.style.top = evt.clientY + doc.scrollTop + 20 + 'px';
      titles.tip.style.left = evt.clientX + doc.scrollLeft + 'px';
    }
  },
  
  show: function(o) {
    titles.tip.style.display = 'block';
    titles.tip.innerHTML = o.tip;
  },
  
  hide: function(o) {
    titles.tip.innerHTML = '';
    titles.tip.style.display = 'none'; 
  },
  
  init: function() {
    if (window.addEventListener){ window.addEventListener('load', titles.load, false); } else { window.attachEvent('onload', titles.load); }
  }
}

titles.init();