var DH = 0;
var an = 0;
var al = 0;
var ai = 0;
var TooltipIsShowing = false;
var MouseIsOverItemWithTooltip = false;
var SwitchIsPending = false;
var CurrentMouseoverElement = null;
var CurrentTooltip = null;
var CurrentFadingElement = null;
var IsFadingIn = false;
var FadeOpacity = 0;

function tt_over(element) {
    MouseIsOverItemWithTooltip = true;
    
    if (isIE && CurrentFadingElement && (IsFadingIn == false)) {
        //alert("TooltipIsShowing = " + TooltipIsShowing);
    }
    
    CurrentMouseoverElement = element;
    
    if (isIE) {
        if (TooltipIsShowing) {
            tt_hide(CurrentTooltip);
            tt_show(element);
            CurrentTooltip = element;
            if (CurrentFadingElement) {
                var ds = fd(CurrentFadingElement, 1);
                ds.opacity = 1.0;
                if (isIE) ds.filter = "alpha(opacity=100)";
                CurrentFadingElement = null;
            }
            SwitchIsPending = false;
        } else if (!SwitchIsPending) {
            setTimeout(tt_start, 500);
            SwitchIsPending = true;
        }
    } else {
        if (TooltipIsShowing) {
            tt_hide(CurrentTooltip);
            tt_show(element);
            CurrentTooltip = element;
        }
        
        if (!SwitchIsPending) {
            setTimeout(tt_start, 500);
            SwitchIsPending = true;
        }
    }
}
function tt_out(element) {
    MouseIsOverItemWithTooltip = false;
    CurrentMouseoverElement = null;
    if (!SwitchIsPending) {
        setTimeout(tt_stop, 1000);
        SwitchIsPending = true;
    }
}
function tt_start() {
    SwitchIsPending = false;
    if (CurrentFadingElement) return; // Don't start a 2nd animation if one's already happening
    
    if (MouseIsOverItemWithTooltip) {
        CurrentFadingElement = CurrentMouseoverElement;
        IsFadingIn = true;
        tt_fade_in();
        CurrentTooltip = CurrentMouseoverElement;
        TooltipIsShowing = true;
    }
}
function tt_stop() {
    SwitchIsPending = false;
    if (!CurrentTooltip) return;
    if (CurrentFadingElement) return; // Don't start a 2nd animation
    
    if (!MouseIsOverItemWithTooltip) {
        CurrentFadingElement = CurrentTooltip;
        IsFadingIn = false;
        tt_fade_out();
        if (!isIE) TooltipIsShowing = false;
    }
}

function tt_fade_in() {
    if (!CurrentFadingElement) return;
    var ds = fd(CurrentFadingElement,1); 
    ds.display = "block";
    ds.opacity = "0.0";
    if (isIE) ds.filter = "alpha(opacity=0)";
    FadeOpacity = 0;
    setTimeout(tt_fade_in_step, 10);
}
function tt_fade_in_step() {
    if (!CurrentFadingElement) return;
    var ds = fd(CurrentFadingElement, 1);
    FadeOpacity = FadeOpacity + 4;
    window.status = FadeOpacity;
   
    if (ds.opacity) ds.opacity = FadeOpacity/100;
    //if (ds.MozOpacity) ds.MozOpacity = FadeOpacity/100;
    //if (ds.KhtmlOpacity) ds.KhtmlOpacity = FadeOpacity/100;
    if (isIE) ds.filter = "alpha(opacity=" + FadeOpacity + ")";
    if (FadeOpacity >= 100) {
        CurrentFadingElement = null;
        ds.opacity = "1.0";
        if (isIE) ds.filter = "alpha(opacity=100)";
    } else {
        setTimeout(tt_fade_in_step, 5);
    }
}
function tt_fade_out() {
    if (!CurrentFadingElement) return;
    var ds = fd(CurrentFadingElement,1); 
    ds.display = "block";
    ds.opacity = "1.0";
    if (isIE) ds.filter = "alpha(opacity=100)";
    FadeOpacity = 100;
    setTimeout(tt_fade_out_step, 10);
}
function tt_fade_out_step() {
    if (!CurrentFadingElement) return;
    var ds = fd(CurrentFadingElement, 1);
    FadeOpacity = FadeOpacity - 4;
    
    if (ds.opacity) ds.opacity = FadeOpacity/100;
    //if (ds.MozOpacity) ds.MozOpacity = FadeOpacity/100;
    //if (ds.KhtmlOpacity) ds.KhtmlOpacity = FadeOpacity/100;
    if (isIE) ds.filter = "alpha(opacity=" + FadeOpacity + ")";
    if (FadeOpacity <= 0) {
        CurrentFadingElement = null;
        ds.display = "none";
        ds.opacity = "1.0";
        if (isIE) ds.filter = "alpha(opacity=100)";
        TooltipIsShowing = false;
    } else {
        setTimeout(tt_fade_out_step, 5);
    }
}

function tt_show(oi) 
{
    if (DH) {
		ds = fd(oi,1); 
		dm = fd(oi,0); 
		st = ds.left; 
		ds.display = "block";
		
    }
}

function tt_hide(oi) 
{
    if (DH) {
		ds = fd(oi,1); 
		dm = fd(oi,0); 
		st = ds.left; 
		//ds.left = "-9999px";  
		ds.display = "none";
    }
}
     


if (document.getElementById) {
	ai = 1; 
	DH = 1;
} else {
	if (document.all) {
		al = 1; 
		DH = 1;
	} else { 
		browserVersion = parseInt(navigator.appVersion); 
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			an = 1; 
			DH = 1;
			}
		}
	} 

function fd(oi, wS) {
	if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi); 
	if (al) return wS ? document.all[oi].style: document.all[oi]; 
	if (an) return document.layers[oi];
}

function pw() {
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}



             
