function tooltip()
{
  var d = document;
  var E = d.documentElement;
  var b = d.body;

  if (!E) return;
  var a = this;
  if (!a.title) return;

  if (a.t) delete(a.t);

  a.origiTitle = a.title;

  a.t = $("#tooltip");
  if (a.t.length == 0) a.t = $("<div>").get(0);
  else a.t = a.t[0];

  a.t.innerHTML = a.title.replace(/\|/g,"<br />");

  a.t.id = "tooltip";
  a.t.className = "tooltipDiv";
  a.t.style.display = 'block';

  a.onmouseover = function(e)
  {
    this.title = "";
    this.onmousemove(e);
    b.appendChild(this.t);
  };
  a.onmouseout = function(x)
  {
    this.title = this.origiTitle;
    $('#tooltip').remove();
  };
  a.onmousemove=function(e)
  {
    e=e||event;
    with(this.t.style)
    {
      left=e.clientX+(E.scrollLeft||b.scrollLeft)+2 - Math.max(0, 2-((E.clientWidth||b.parentNode.clientWidth)-e.clientX-this.t.offsetWidth)) + "px";
      var dogtt = 20-((E.clientHeight||b.parentNode.clientHeight)-e.clientY-this.t.offsetHeight);
      top=e.clientY+(E.scrollTop||b.scrollTop) - (dogtt<0?0:(30+this.t.offsetHeight)) + "px";
    };
  };
};

function bindColorboxInline()
{
  $('a.colorboxInline').each(function()
	{
	  var rel = $(this).attr('rel');
	  $(this).attr('rel', '');
	  if (!rel || !$('#' + rel).length) return;
    $(this).colorbox({
      width: "50%",
      inline: true,
      overlayClose: false,
      slideshow: false,
      preloading: false,
      href: "#" + rel
    });
  });
}

$(function ()
{
  $('.tooltip').each(tooltip);
  $('*[title]:not(.tooltip):not(.leaveTitle)').attr('title', '');
  
  $('a.colorbox').colorbox();
  bindColorboxInline();
  
});


