//M:tooltip bsim改良版
var ns4 = document.layers;
try{
if(ns4=="undefined") ns4=false;}
catch(e){ns4=false;} 
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = 0;
offsetY = 20;
var toolTipSTYLE="";
function initToolTips()
{
   if(ns4||ns6||ie4)
   {
     if(ns4) toolTipSTYLE = document.toolTipLayer;
     else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
     else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
     if(ns4) document.captureEvents(Event.MOUSEMOVE);
     else
     {
       toolTipSTYLE.visibility = "visible";
       toolTipSTYLE.display = "none";
     }
     document.onmousemove = moveToMouseLoc;
   }
}
function toolTip(msg, mleft, mtop, bg, fg)
{
   if(toolTip.arguments.length < 1) // hide
   {
     if(ns4) toolTipSTYLE.visibility = "hidden";
     else toolTipSTYLE.display = "none";
   }
   else 
   {
     if(!mleft) mleft = 0; 
     if(!mtop) mtop = 0; 
     if(!fg) fg = "#777777"; 
     if(!bg) bg = ""; 
     var content = '<div style="background:' + bg + '; margin-left:'+ mleft +'px; margin-top:'+ mtop +'px; text-align:center; z-index:100;">' + msg + '</div>';
     if(ns4)
     {
       toolTipSTYLE.document.write(content);
       toolTipSTYLE.document.close();
       toolTipSTYLE.visibility = "visible";
     }
     if(ns6)
     {
       document.getElementById("toolTipLayer").innerHTML = content;
       toolTipSTYLE.display='block';
     }
     if(ie4)
     {
       document.all("toolTipLayer").innerHTML=content;
       toolTipSTYLE.display='block';
     }
   }
}
function moveToMouseLoc(e)
{
   if(ns4||ns6)
   {
     x = e.pageX-220;
     y = e.pageY;
   }
   else
   {
     x = event.x + document.body.scrollLeft-220;
     
     //M:ie6、ie8和maxthon显示方式优化
        function isMaxthon(){
            try{
            window.external.max_invoke("GetHotKey");
            return true;
            }catch(ex){
            return false;
            }
            }  
            
        var isIE=!!window.ActiveXObject;
        var isIE6=isIE&&!window.XMLHttpRequest;
        var isIE8=isIE&&!!document.documentMode;
        if (isIE6){
             y = event.y + document.documentElement.scrollTop;
        }else if(isMaxthon()) {
             y = event.y + document.documentElement.scrollTop;
        }else {
             y = event.y + document.body.scrollTop;
        }
        
        if(isIE8) {
        if(isMaxthon()) {
             y = event.y + document.documentElement.scrollTop;
        }
        else
             y = event.y + document.body.scrollTop;
        }
   }
   toolTipSTYLE.left = x + offsetX + "px";
   toolTipSTYLE.top = y + offsetY + "px";
   return true;
}