/*Javascript for Bubble Tooltips by Alessandro Fulciniti
http://pro.html.it - http://web-graphics.com */

function enableTooltips(id,orient){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
try{
h=document.createElement("div");
h.id="btc";
h.setAttribute("id","btc");
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++){
    Prepare(orient,links[i]);
    }
}catch(e){
    document.getElementsByTagName("body")[0].removeChild(h);
}
}

function Prepare(o,el){
var tooltip,t,b,s,l,n,hl;
t=el.getAttribute("title");
n=el.getAttribute("name");
if(t!=null && t.length!=0){
  el.removeAttribute("title");
  tooltip=CreateEl("div","tooltip_" + o);
  hl=CreateEl("div","tool_head");
  hl.innerHTML=n;
  tooltip.appendChild(hl);
  s=CreateEl("div","tool_text");
  //s.appendChild(document.createTextNode(t));
  s.innerHTML=t
  tooltip.appendChild(s);
  b=CreateEl("b","tool_bottom");
  l=el.getAttribute("subtitle");
  if((l==="")||(l===null)) { l=""; }
  if(l=="les") { l="Trykk på linken for å lese mer." }
  b.appendChild(document.createTextNode(l));
  tooltip.appendChild(b);
  setOpacity(tooltip);
  el.tooltip=tooltip;
  el.onmouseout=hideTooltip;
  if(o=="l") { el.onmouseover=showTooltip_l; el.onmousemove=Locate_l; }
  if(o=="r") { el.onmouseover=showTooltip_r; el.onmousemove=Locate_r; }
  }
}

function showTooltip_l(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate_l(e);
}
function showTooltip_r(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate_r(e);
}

function hideTooltip(e){
var d=document.getElementById("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
el.style.filter="alpha(opacity:95)";
el.style.KHTMLOpacity="0.95";
el.style.MozOpacity="0.95";
el.style.opacity="0.95";
}

function CreateEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function AddCss(){
var l=CreateEl("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 Locate_l(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;
        }
    }
if(document.getElementById("btc").offsetHeight){
    divHeight=document.getElementById("btc").offsetHeight;
}			
    else if(document.getElementById("btc").style.pixelHeight){
        divHeight=document.getElementById("btc").style.pixelHeight;
}
document.getElementById("btc").style.top=(posy-3)+"px";
document.getElementById("btc").style.left=(posx+20)+"px";
}
function Locate_r(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;
        }
    }
if(document.getElementById("btc").offsetHeight){
    divHeight=document.getElementById("btc").offsetHeight;
}			
    else if(document.getElementById("btc").style.pixelHeight){
        divHeight=document.getElementById("btc").style.pixelHeight;
}
document.getElementById("btc").style.top=(posy-3)+"px";
document.getElementById("btc").style.left=(posx-335)+"px";
}
//window.onload=function(){
//	enableTooltips('visitvikedal','l'); 
//	enableTooltips('artistforslag','l'); 
//	enableTooltips('kulturkort','l'); 
//	enableTooltips('presse','r'); 
//	enableTooltips('historie','r'); 
//	initLightbox();
//}
//window.onload=function(){enableTooltips()};
