<!--
/*
	============================================================
	ToolTip
	============================================================
*/

var myDivId = 'tooltip';
var movingX = 15;
var movingY = 0;

var positionX = 0;
var positionY = 0;

var divElement;
divElement = document.createElement('div');
divElement.setAttribute('id', myDivId);
divElement.style.visibility = 'hidden';
divElement.style.position = 'absolute';
divElement.style.left = '0px';
divElement.style.top = '0px';

function ToolTipGetMouseXY(e) {
    var browserIE = document.all?true:false
    if (!browserIE) document.captureEvents(Event.MOUSEMOVE)
    positionX = browserIE?event.clientX + document.body.scrollLeft:e.pageX;
    positionY = browserIE?event.clientY + document.body.scrollTop:e.pageY;
     ToolTipSetPosition();
    return true;
}

function ToolTipSetPosition(){
    var windowWidth = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        windowWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth ) {
        windowWidth = document.documentElement.clientWidth;
    } else if( document.body && document.body.clientWidth  ) {
        windowWidth = document.body.clientWidth;
    }
    if( ( positionX +  parseInt(divElement.style.width ) + movingX + 50 ) > windowWidth ){
        positionX -= ( movingX + parseInt(divElement.style.width ) );
    }
    divElement.style.left = (movingX + positionX) + 'px';
    divElement.style.top = (movingY + positionY) + 'px';
}

function ToolTipSetOpacity(element, alpha){
    var el = document.getElementById(element);
    
    if(el.style.opacity != undefined){
        el.style.opacity = alpha;
    }
    else if(el.style.MozOpacity != undefined){ 
        el.style.MozOpacity = alpha;
    }
    else if(el.style.filter != undefined){
        el.style.filter = "alpha(opacity=0)";
        el.filters.alpha.opacity = ( alpha * 100 );
    }
    return true;
}

function ToolTipPulseOn(){
    for(i = 0; i <= 10; i++){
        setTimeout("ToolTipSetOpacity('" + myDivId + "'," + i/10 + ");", 25*i);
    }   
}

function ToolTip( str, el, width ){
    if(!document.getElementById(myDivId))
        document.body.appendChild(divElement);
    divElement.style.width = width + 'px';
    ToolTipSetOpacity(myDivId, 0 );
    divElement.style.visibility = 'visible';
    ToolTipPulseOn();
    divElement.innerHTML = str;
    el.onmousemove=ToolTipGetMouseXY;
    el.onmouseout = ToolTipHideTip;
}

function ToolTipHideTip(){
    divElement.style.visibility = 'hidden';
}

//-->
