
function enableTooltips(){

var links,i,h,j;
var imgSplit;
if(!document.getElementById || !document.getElementsByTagName) return;
AddCss();
h=document.getElementById("btc");
document.getElementsByTagName("body")[0].appendChild(h);
links=document.getElementsByTagName("img");

for(i=0;i<links.length;i++)
{
imgSplit = links[i].getAttribute("src").split("/");
for(j=0; j<imgSplit.length; j++)
  {
   
    if(imgSplit[j] == 'helpQuestionMark.gif')
    {    
       Prepare(links[i]);
     }
   }
}
}

function Prepare(el)
{

var tooltip,t,b,s,l,theClass;
t=el.getAttribute("alt");
l=el.getAttribute("title");

if(l == null){
    return;
} else if (l.length > 70 || t.length > 25) {
    theClass = "tooltipWide";
} else {
   theClass = "tooltip";
}
tooltip=CreateEl("span",theClass);

s=CreateEl("span","top");
s.appendChild(document.createTextNode(t));
tooltip.appendChild(s);

b=CreateEl("b","bottom");

el.removeAttribute("title");
b.appendChild(document.createTextNode(l));
tooltip.appendChild(b);

setOpacity(tooltip);
el.tooltip=tooltip;
el.onmouseover=showTooltip;
el.onmouseout=hideTooltip;
el.onmousemove=Locate;
  
}

function showTooltip(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate(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:1000)";
el.style.KHTMLOpacity="5.95";
el.style.MozOpacity="5.95";
el.style.opacity="5.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","/CustomControls/Css/bt.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Locate(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("btc").style.bottom=(windowHeight() - posy)+"px";
document.getElementById("btc").style.left=(posx+2)+"px";

//SC 15/08/09.  Code added by Contigo IR54809
//Need to increase the zindex from 500 to 100500 in order to work with AJAX modal 
//popups which are set to 10001 by default for IE, but 100001 for firefox
document.getElementById("btc").style.zIndex = 100500;


}

function windowHeight() {
    var myWidth = 0, myHeight = 0, version = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  version = getBrowserVersion();
  if(version == 6)
  {
    myHeight = myHeight + document.documentElement.scrollTop;
  }
    
  return myHeight;
}

function getBrowserVersion()
 {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //get MSIE x.x;
        var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
        return ieversion;
    }
}
