2 * JavaScript code to create "bubble tooltips"
4 * This is largely based on code written by Alessandro Fulciniti
5 * http://pro.html.it - http://web-graphics.com
8 function btt_enableTooltips(id)
11 if (!document.getElementById || !document.getElementsByTagName) {
15 h = document.createElement("span");
17 h.setAttribute("id", "btc");
18 h.style.position = "absolute";
19 document.getElementsByTagName("body")[0].appendChild(h);
21 links = document.getElementsByTagName("a");
24 links = document.getElementById(id).getElementsByTagName("a");
26 for (i = 0; i < links.length; i++) {
27 btt_Prepare(links[i]);
31 function btt_Prepare(el)
33 var tooltip, b, s, l, ih;
34 ih = el.getAttribute("btt_tooltext");
38 el.removeAttribute("btt_tooltext");
39 el.removeAttribute("title");
40 tooltip = btt_CreateEl("span", "tooltip");
41 s = btt_CreateEl("span", "top");
42 s.appendChild(document.createTextNode(""));
44 tooltip.appendChild(s);
45 b = btt_CreateEl("b", "bottom");
46 tooltip.appendChild(b);
47 btt_setOpacity(tooltip);
49 el.onmouseover = btt_showTooltip;
50 el.onmouseout = btt_hideTooltip;
51 el.onmousemove = btt_Locate;
54 function btt_showTooltip(e)
56 document.getElementById("btc").appendChild(this.tooltip);
60 function btt_hideTooltip(e)
62 var d = document.getElementById("btc");
63 if (d.childNodes.length > 0) {
64 d.removeChild(d.firstChild);
68 function btt_setOpacity(el)
70 el.style.filter = "alpha(opacity:95)";
71 el.style.KHTMLOpacity = "0.95";
72 el.style.MozOpacity = "0.95";
73 el.style.opacity = "0.95";
76 function btt_CreateEl(t, c)
78 var x = document.createElement(t);
80 x.style.display = "block";
86 var l = btt_CreateEl("link");
87 l.setAttribute("type", "text/css");
88 l.setAttribute("rel", "stylesheet");
89 l.setAttribute("href", "static/bt.css");
90 l.setAttribute("media", "screen");
91 document.getElementsByTagName("head")[0].appendChild(l);
94 function btt_Locate(e)
96 var posx = 0, posy = 0;
100 if (e.pageX || e.pageY) {
105 else if (e.clientX || e.clientY) {
106 if (document.documentElement.scrollTop) {
109 document.documentElement.scrollLeft;
111 e.clientY + document.documentElement.scrollTop;
115 posx = e.clientX + document.body.scrollLeft;
116 posy = e.clientY + document.body.scrollTop;
119 document.getElementById("btc").style.top = (posy + 10) + "px";
120 document.getElementById("btc").style.left = (posx - 20) + "px";