﻿// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
var ttDH = 0;
var ttAN = 0;
var ttAL = 0;
var ttAI = 0;

if (document.getElementById) {
    ttAI = 1; 
    ttDH = 1;
}else {
    if (document.all) {
        ttAL = 1; 
        ttDH = 1;
    } else { 
        browserVersion = parseInt(navigator.appVersion); 
        if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
            ttAN = 1; 
            ttDH = 1;
        }
    }
} 

function fd(oi, wS) 
{
    if (ttAI) return wS ? document.getElementById(oi).style:document.getElementById(oi); 
    if (ttAL) return wS ? document.all[oi].style: document.all[oi]; 
    if (ttAN) return document.layers[oi];
}

function pw() 
{
    return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}

function ttMouseX(evt) 
{
    if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return null;
}

function ttMouseY(evt) 
{
    if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;
}

// Use this method to produce a tool tip that is placed below the cursor location
function toolTipPopUp(evt,oi) 
{
    if (ttDH) {
        ds = fd(oi,1); 
        dm = fd(oi,0); 
        st = ds.visibility; 
        if (st == "visible" || st == "show") 
        { 
            ds.visibility = "hidden"; 
        } else {
            var wp = pw(); 
            if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; 
            tv = ttMouseY(evt) + 20; 
            lv = ttMouseX(evt) - (ew/4); 
            if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2;
            if (!ttAN) {lv += 'px';tv += 'px';} 
            ds.left =  lv; 
            ds.top = tv; 
            ds.visibility = "visible";
        }
    }
}

function toolTipPopUp2(evt,oi) 
{
    //evt = event
    //oi = name of the element
    //ew = total width of the element
    //hw = total height of the element
    //tv = height as measured from the top of the page to the mouse Y location
    //lv = width as measured from the top of the page to the mouse X location
    if (ttDH) {
        ds = fd(oi,1); 
        dm = fd(oi,0); 
        st = ds.visibility; 
        if (st == "visible" || st == "show") 
        { 
            ds.visibility = "hidden"; 
        } else {
            screenX = document.body.offsetWidth;
            var wp = pw(); 
            if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; 
            ds.left = (screenX - ew)/2 + 'px'; 
            ds.top = '150px'; 
            ds.visibility = "visible";
        }
    }
}      

// Use this method to produce a tool tip that is placed above the cursor location
function toolTipPopUp3(evt,oi) 
{
    if (ttDH) {
        var wp = pw(); 
        ds = fd(oi,1); 
        dm = fd(oi,0); 
        st = ds.visibility; 
        if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; 
        if (dm.offsetHeight) hw = dm.offsetHeight; else if (dm.clip.height) hw = dm.clip.height; 
        if (st == "visible" || st == "show") 
        { 
            ds.visibility = "hidden"; 
        } else {
            tv = ttMouseY(evt) - hw; 
            lv = ttMouseX(evt) + 20; 
            if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; if (!ttAN) {lv += 'px';tv += 'px';} ds.left = lv; ds.top = tv; ds.visibility = "visible";
        }
    }
}

// Use this method to produce a tool tip that is placed below the cursor location and to the right
function toolTipPopUp4(evt,oi) 
{
    if (ttDH) {
        var wp = pw(); 
        ds = fd(oi,1); 
        dm = fd(oi,0); 
        st = ds.visibility; 
        if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; 
        if (dm.offsetHeight) hw = dm.offsetHeight; else if (dm.clip.height) hw = dm.clip.height; 
        if (st == "visible" || st == "show") 
        { 
            ds.visibility = "hidden"; 
        } else {
            tv = ttMouseY(evt) + 5; 
            lv = ttMouseX(evt) + 5; 
            if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; if (!ttAN) {lv += 'px';tv += 'px';} ds.left = lv; ds.top = tv; ds.visibility = "visible";
        }
    }
}
  