//BEGIN for tooltip ------ lifted from Townhall.com, with some mods -------
// <A href=""
//	onmouseover="javaScript:showToolTip('HTML goes here\r\n...')" 
//	onmouseout="javaScript:hideToolTip()">Display text</a>

//detect browser
var IE = (document.all) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;

var mouseTop = 0;
var mouseLeft = 0;

function getMousePositionDOM(e) 
    {
        mouseTop = e.clientY;
        mouseLeft = e.clientX;
    }

function getMousePositionIE() 
    {
        mouseTop = event.clientY;
        mouseLeft = event.clientX;
    }

function showToolTip(s) 
    {
	    var tt = document.getElementById('tooltip')
        var scrolledTop = document.body.scrollTop;
        var scrolledLeft = document.body.scrollLeft;
        var sClean;

        var browserWidth = 0;
        var browserHeight = 0;
        
        if (window.innerWidth) 
        {
	        browserWidth = window.innerWidth;
        }        
        else if (document.documentElement && document.documentElement.clientWidth) 
        {
	        browserWidth = document.documentElement.clientWidth;
        } 
        else if (document.body) 
        {
	        browserWidth = document.body.clientWidth;
        }
        
        if (window.innerHeight) 
        {
	        browserHeight = window.innerHeight;
        }        
        else if (document.documentElement && document.documentElement.clientHeight) 
        {
	        browserHeight = document.documentElement.clientHeight;
        } 
        else if (document.body) 
        {
	        browserHeight = document.body.clientHeight;
        }

        if (scrolledTop == 0)
        {
            if (window.pageYOffset)
                scrolledTop = window.pageYOffset;
            else
                scrolledTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
        }
        
        if (scrolledLeft == 0)
        {
            if (window.pageXOffset)
                scrolledLeft = window.pageXOffset;
            else
                scrolledLeft = (document.body.parentElement) ? document.body.parentElement.scrollLeft : 0;
        }
                
        //'bw=' + browserWidth + 'sl=' + scrolledLeft + 'mL=' + mouseLeft + 'dW=' + divWidth
        //2/23/07 BobS: Clean up the HTML being sent, especially single and double quotes
        var RegExp = /\'/g;
        //sClean = s.replace('\'','&quot;');
        sClean = s.replace('\'','&quot;');
        //sClean = s;
        tt.innerHTML = s;
        
        var divWidth = parseInt(tt.offsetWidth);
        var divHeight = parseInt(tt.offsetHeight);
                
        if ((mouseTop + 10 + divHeight) > browserHeight) //if the mouse is close to the right of the screen
        {
            tt.style.top = scrolledTop + browserHeight - divHeight - 16 + 'px';
        }
        else
        {
            tt.style.top = scrolledTop + mouseTop + 10 + 'px';
        }
                
        if ((mouseLeft + 10 + divWidth) > browserWidth) //if the mouse is close to the right of the screen
        {
            tt.style.left = scrolledLeft + browserWidth - divWidth - 16 + 'px';
        }
        else
        {
            tt.style.left = scrolledLeft + mouseLeft + 10 + 'px';
        }
        tt.style.visibility = "visible";
        
	    return;
	}

function hideToolTip() 
    {
        document.getElementById('tooltip').style.visibility = "hidden";
        return;
    }

if (IE) 
{
    document.onmousemove = getMousePositionIE;
}
else if (DOM) 
{
    document.onmousemove = getMousePositionDOM;
}

//END for tooltip---------------------------------------------------------------------------------------

