/*javascript for Bubble Tooltips by Alessandro Fulciniti
- http://pro.html.it - http://web-graphics.com
###### corrrections by ID Alizes (http://www.id-alizes.fr) ##################### 
- 2007-08-14 : change in Prepare function remove 
               if(t==null || t.length==0) t="link:";
               put instead : 
               if(t==null || t.length==0) return;  
- 2007-08-14 : add in Prepare function 
               if(l=="#") l=""; 
- 2007-08-14 : make one new enableTooltips :  
               - enableTooltips_nolink : not use link in prepare, then call prepare_nolink
- 2007-08-14 : renam id 'btc' in 'IDBubbleTooltips'  
- 2007-08-14 : add Tooltips in all functions names (old : AddCss, Prepare, setOpacity, CreateEl, Locate )  
- 2007-08-14 : add Tooltips in all span names (old : top, bottom )  
*/

//window.onload=function(){enableTooltips_nolink()};


function enableTooltips(id){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
AddCssTooltips();
h=document.createElement("span");
h.id="IDBubbleTooltips";
h.setAttribute("id","IDBubbleTooltips");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) links=document.getElementsByTagName("a");
else links=document.getElementById(id).getElementsByTagName("a");
for(i=0;i<links.length;i++){
    PrepareTooltips(links[i]);
    }
}

function enableTooltips_nolink(id){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
AddCssTooltips();
h=document.createElement("span");
h.id="IDBubbleTooltips";
h.setAttribute("id","IDBubbleTooltips");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) links=document.getElementsByTagName("a");
else links=document.getElementById(id).getElementsByTagName("a");
for(i=0;i<links.length;i++){
    PrepareTooltips_nolink(links[i]);
    }
}

function PrepareTooltips(el){
var tooltip,t,b,s,l;
t=el.getAttribute("title");
if(t==null || t.length==0) return;
el.removeAttribute("title");
tooltip=CreateElTooltips("span","tooltip");
s=CreateElTooltips("span","topTooltips");
s.appendChild(document.createTextNode(t));
tooltip.appendChild(s);
b=CreateElTooltips("b","bottomTooltips");
l=el.getAttribute("href");
if(l.length>30) l=l.substr(0,27)+"...";
if(l=="#") l="";
b.appendChild(document.createTextNode(l));
tooltip.appendChild(b);
setOpacityTooltips(tooltip);
el.tooltip=tooltip;
el.onmouseover=showTooltip;
el.onmouseout=hideTooltip;
el.onmousemove=LocateTooltips;
}

function PrepareTooltips_nolink(el){
var tooltip,t,b,s,l;
t=el.getAttribute("title");
if(t==null || t.length==0) return;
el.removeAttribute("title");
tooltip=CreateElTooltips("span","tooltip");
s=CreateElTooltips("span","topTooltips");
s.appendChild(document.createTextNode(t));
tooltip.appendChild(s);
b=CreateElTooltips("b","bottomTooltips");
l="";
b.appendChild(document.createTextNode(l));
tooltip.appendChild(b);
setOpacityTooltips(tooltip);
el.tooltip=tooltip;
el.onmouseover=showTooltip;
el.onmouseout=hideTooltip;
el.onmousemove=LocateTooltips;
}

function showTooltip(e){
document.getElementById("IDBubbleTooltips").appendChild(this.tooltip);
LocateTooltips(e);
}

function hideTooltip(e){
var d=document.getElementById("IDBubbleTooltips");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacityTooltips(el){
el.style.filter="alpha(opacity:95)";
el.style.KHTMLOpacity="0.95";
el.style.MozOpacity="0.95";
el.style.opacity="0.95";
}

function CreateElTooltips(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function AddCssTooltips(){
var l=CreateElTooltips("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","bt.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function LocateTooltips(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientY+document.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }
document.getElementById("IDBubbleTooltips").style.top=(posy+10)+"px";
document.getElementById("IDBubbleTooltips").style.left=(posx-20)+"px";
}
